ans1.jas

b:
     push #4                  / Allocate i
     st %r2 -> [sp]--         / Spill r2 since you'll use it
     ld [fp+12] -> %r0        / i = j
     st %r0 -> [fp]
l1:     
     ld [fp] -> %r0           / while (i > 0)
     cmp %r0, %g0
     ble l2
     ld [fp] -> %r0           / j = (i*j) + (k*3)
     ld [fp+12] -> %r1
     mul %r0, %r1 -> %r0
     ld [fp+16] -> %r1
     mov #3 -> %r2
     mul %r1, %r2 -> %r1
     add %r0, %r1 -> %r0
     st %r0 -> [fp+12]
     ld [fp] -> %r0           / i--
     add %r0, %gm1 -> %r0
     st %r0 -> [fp]
     b l1
l2:
     ld ++[sp] -> %r2         / Unspill r2
     ld [fp+12] -> %r0        / return j
     ret