    #######################################################
    # (C) 2021 T. Risset
    # Code compiled from the follwing program with -O0 option
    # riscv64-linux-gnu-gcc -S whileLoop.c -o whileLoop.S -O0
    # and manually adapted to qtrvsim
    # int dec(int i)
    # {
    #    int res;
    #    res = i-1;
    #    return res;
    #       }
    #  int main()
    #  {
    #    dec(10);
    #    return 0;
    #   }
    #######################################################

#pragma qtrvsim show terminal
#pragma qtrvsim show registers
#pragma qtrvsim show memory
.globl _start
.globl __start
    
.org 0x00000200

.text
__start:
_start:
       addi     sp,sp,-16
       sw       ra,8(sp)
       li       a5,10
       call     dec
       lw       ra,8(sp)
       addi     sp,sp,16
end:
	jal zero, end

dec:
	addi       sp,sp,-4
        sw         t1, 0(sp)
        addi       t1,a5,-1
        mv         a0,t1
        lw         t1,0(sp)
	addi       sp,sp,4
	ret
       
#pragma qtrvsim tab core
