		.text
		.align  2
		.globl  _start

_start:
		addi a0, x0, 1123
		addi a1, x0, 5
		nop
		nop
		nop
		jal ra, fast_multiply
		nop
   		nop
   		nop
loop:
		jal x0, loop
		nop
		nop
		nop

fast_multiply:
   add  t0, zero, zero      # to keep track of result
   
next_digit:
   andi t1, a1, 1           # is rightmost bit 1?
   srai a1, a1, 1
   nop
   nop
   
   beq  t1, zero, skip      # if right most bit 0, don't add
   nop
   nop
   nop

   add  t0, t0, a0
skip:
   slli a0, a0, 1           # double first argument
   bne  a1, zero, next_digit
   nop
   nop
   nop
   add  a0, zero, t0        # move accum result to a0
   jalr x0, ra, 0
   nop
   nop
   nop

		.end _start
		.size _start, .-_start
