// File: /workspace/github_c_makefile_star2_O2/hamsternz[P]emulate-risc-v/riscv.c
// Function: riscv_run
int riscv_run(void) {
  ///////////////////////////////////////
  // Update counters 
  ////////////////////////////////////
  csr[CSR_RDCYCLE]++;
  if(csr[CSR_RDCYCLE] == 0)
    csr[CSR_RDCYCLEH]++;
  csr[CSR_MCYCLE] = csr[CSR_RDCYCLE];

  if(do_op()) {
    csr[CSR_RDTIME]++;
    if(csr[CSR_RDTIME] == 0)
      csr[CSR_RDTIMEH]++;
    return 1;
  } else {
    char buffer[100];
    sprintf(buffer,"Instruction : %08x",current_instr);
    display_log(buffer);
  }
  return 0;
}

// Assembly:
movl 0xcc1e(%rip), %eax      # 0xfa10
incl %eax
movl %eax, 0xcc16(%rip)      # 0xfa10
jne 0x2e02
incl 0xce1a(%rip)            # 0xfc1c
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %eax, 0xc7fa(%rip)      # 0xf610
movl 0x9be4(%rip), %edi      # 0xca00
testb $0x3, %dil
je 0x2e63
leaq 0x4f31(%rip), %rdi      # 0x7d5a
callq 0x4b7e
movl 0xdc6c(%rip), %edx      # 0x10aa0
leaq 0x4a92(%rip), %rsi      # 0x78cd
xorl %ebx, %ebx
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x21f0
movq %r14, %rdi
callq 0x4b7e
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0xdc4e(%rip)      # 0x10ab8
jne 0x2fac
cmpb $0x0, 0xdc6d(%rip)      # 0x10ae4
je 0x3006
callq 0x5e23
testl %eax, %eax
jne 0x2fac
xorl %eax, %eax
movb %al, 0xdc52(%rip)       # 0x10ae4
callq 0x5e7a
movl %eax, 0xdc03(%rip)      # 0x10aa0
movl %eax, %ebx
notl %ebx
movl %eax, %r9d
shrl $0x14, %r9d
movl %eax, %edx
shrl $0xf, %edx
movl %edx, %esi
andb $0x1f, %sil
movl %r9d, %edi
movl %r9d, %r8d
movl %r9d, %r10d
movl %r9d, 0xdc0d(%rip)      # 0x10ad0
movl %r9d, %r11d
andb $0x1f, %r11b
movl %eax, %r9d
shrl $0x7, %r9d
movl %r9d, %ebp
andb $0x1f, %bpl
andl $0x1f, %edx
andl $0x1f, %edi
movl $0xfffff000, %r15d      # imm = 0xFFFFF000
movl %eax, %r14d
andl %r15d, %r14d
movl %eax, %r12d
sarl $0xb, %r12d
andl $0xfff00000, %r12d      # imm = 0xFFF00000
movl %eax, %r13d
andl $0xff000, %r13d         # imm = 0xFF000
orl %r12d, %r13d
movl %eax, %r12d
shrl $0x9, %r12d
movl $0x800, %ecx            # imm = 0x800
andl %ecx, %r12d
orl %r13d, %r12d
movl %eax, %r13d
sarl $0x14, %r13d
andl $0x7fe, %r8d            # imm = 0x7FE
orl %r12d, %r8d
movl %eax, %r12d
sarl $0x13, %r12d
andl %r15d, %r12d
shll $0x4, %eax
andl %ecx, %eax
orl %r12d, %eax
andl $0x7e0, %r10d           # imm = 0x7E0
orl %eax, %r10d
movl %r9d, %eax
andl $0x1e, %eax
orl %r10d, %eax
movl %r13d, 0xdb74(%rip)     # 0x10ac8
andl $-0x20, %r13d
andl $0x1f, %r9d
orl %r13d, %r9d
movb %sil, 0xdb5e(%rip)      # 0x10ac4
movb %r11b, 0xdb5f(%rip)     # 0x10acc
movb %bpl, 0xdb3c(%rip)      # 0x10ab0
movl %edx, 0xdb5a(%rip)      # 0x10ad4
movl %edi, 0xdb60(%rip)      # 0x10ae0
movl %r14d, 0xdb2d(%rip)     # 0x10ab4
movl %r8d, 0xdb32(%rip)      # 0x10ac0
movl %eax, 0xdb28(%rip)      # 0x10abc
movl %r9d, 0xdb3d(%rip)      # 0x10ad8
xorl %eax, %eax
movb %al, 0xdb39(%rip)       # 0x10adc
testb $0x3, %bl
jne 0x2e2e
movb 0xdb32(%rip), %al       # 0x10ae4
movb 0xdb00(%rip), %cl       # 0x10ab8
orb %al, %cl
testb $0x1, %cl
je 0x2fc9
incl 0xda4b(%rip)            # 0x10a10
testb $0x1, %al
jne 0x301c
leaq 0x9138(%rip), %rdx      # 0xc108
pushq $0x39
popq %rax
movl 0xdac7(%rip), %ecx      # 0x10aa0
decq %rax
je 0x2e2e
leaq 0x28(%rdx), %rsi
movl 0x4c(%rdx), %edi
andl %ecx, %edi
cmpl 0x48(%rdx), %edi
movq %rsi, %rdx
jne 0x2fd9
movq %rsi, 0xdaae(%rip)      # 0x10aa8
callq *0x8(%rsi)
testl %eax, %eax
jne 0x301c
jmp 0x2e2e
callq 0x5dd7
testl %eax, %eax
je 0x3036
movb $0x1, 0xdace(%rip)      # 0x10ae4
incl 0xd9f4(%rip)            # 0x10a10
pushq $0x1
popq %rbx
incl 0xc9ef(%rip)            # 0xfa14
jne 0x2e52
incl 0xcbe3(%rip)            # 0xfc14
jmp 0x2e52
leaq 0x4d3f(%rip), %rdi      # 0x7d7c
jmp 0x2e29