// File: /workspace/github_c_makefile_star2_O3/hobo0xcc[P]rve/src/cpu.c
// Function: ExecOp32Instr
void ExecOp32Instr(State *state, uint32_t instr) {
    uint8_t funct3 = (instr >> 12) & SetNBits(3);
    uint8_t funct7 = (instr >> 25) & SetNBits(7);

    switch (funct3) {
    case 0x0:
        if (funct7 == 0x00) {
            ExecAddw(state, instr);
        } else if (funct7 == 0x01) {
            ExecMulw(state, instr);
        } else {
            ExecSubw(state, instr);
        }
        break;
    case 0x1:
        ExecSllw(state, instr);
        break;
    case 0x4:
        if (funct7 == 0x01) {
            ExecDivw(state, instr);
        }
        break;
    case 0x5:
        if (funct7 == 0x00) {
            ExecSrlw(state, instr);
        } else if (funct7 == 0x01) {
            ExecDivuw(state, instr);
        } else if (funct7 == 0x20) {
            ExecSraw(state, instr);
        }
        break;
    case 0x6:
        if (funct7 == 0x01) {
            ExecRemw(state, instr);
        }
        break;
    case 0x7:
        if (funct7 == 0x01) {
            ExecRemuw(state, instr);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %eax
shrl $0xc, %eax
movl %eax, %ecx
andb $0x7, %cl
cmpb $0x7, %cl
ja 0x4ba1
movl %esi, %edx
shrl $0x19, %edx
movl %eax, %ecx
andl $0x7, %ecx
leaq 0x37d3(%rip), %r8       # 0x8120
movslq (%r8,%rcx,4), %rcx
addq %r8, %rcx
jmpq *%rcx
movl %esi, %ecx
shrl $0x7, %ecx
andl $0x1f, %ecx
movl $0xf8, %r8d
andl %r8d, %eax
movq 0x8008(%rdi,%rax), %rax
shrl $0x11, %esi
andl %r8d, %esi
movq 0x8008(%rdi,%rsi), %rsi
cmpl $0x1, %edx
je 0x4ad3
testl %edx, %edx
jne 0x4aee
addq %rax, %rsi
jmp 0x4ad7
cmpl $0x1, %edx
jne 0x4ba1
popq %rbp
jmp 0x4710
cmpl $0x1, %edx
jne 0x4ba1
movl %esi, %ecx
shrl $0x11, %ecx
movl $0xf8, %edx
andl %edx, %ecx
movq 0x8008(%rdi,%rcx), %rcx
andl %edx, %eax
movq 0x8008(%rdi,%rax), %rax
testq %rcx, %rcx
je 0x4abd
xorl %edx, %edx
divl %ecx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
orq %rdx, %rax
testl %edx, %edx
cmovnsq %rdx, %rax
jmp 0x4abd
movl $0xf8, %edx
andl %edx, %eax
movq 0x8008(%rdi,%rax), %rax
movl %esi, %ecx
shrl $0x11, %ecx
andl %edx, %ecx
movb 0x8008(%rdi,%rcx), %cl
andb $0x1f, %cl
shlq %cl, %rax
movl %eax, %ecx
cltq
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
andq %rax, %r8
orq %rcx, %r8
shrl $0x4, %esi
andl %edx, %esi
movq %r8, 0x8008(%rdi,%rsi)
jmp 0x4ba1
cmpl $0x20, %edx
je 0x4b4f
cmpl $0x1, %edx
je 0x4b12
testl %edx, %edx
jne 0x4ba1
movl $0xf8, %edx
andl %edx, %eax
movl 0x8008(%rdi,%rax), %eax
movl %esi, %ecx
shrl $0x11, %ecx
andl %edx, %ecx
movb 0x8008(%rdi,%rcx), %cl
shrl %cl, %eax
jmp 0x4b6f
cmpl $0x1, %edx
jne 0x4ba1
movl %esi, %ecx
shrl $0x11, %ecx
movl $0xf8, %edx
andl %edx, %ecx
movq 0x8008(%rdi,%rcx), %rcx
andl %edx, %eax
movq 0x8008(%rdi,%rax), %rax
testq %rcx, %rcx
je 0x4abd
cqto
idivq %rcx
movl %edx, %ecx
movslq %edx, %rdx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rdx, %rax
orq %rcx, %rax
shrl $0x4, %esi
andl $0xf8, %esi
movq %rax, 0x8008(%rdi,%rsi)
jmp 0x4ba1
imulq %rax, %rsi
movl %esi, %eax
movslq %esi, %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rdx, %rsi
orq %rax, %rsi
jmp 0x4b05
subq %rsi, %rax
movl %eax, %edx
cltq
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rax, %rsi
orq %rdx, %rsi
movq %rsi, 0x8008(%rdi,%rcx,8)
jmp 0x4ba1
movl %esi, %ecx
shrl $0x11, %ecx
andl $0xf8, %ecx
movq 0x8008(%rdi,%rcx), %rcx
testq %rcx, %rcx
je 0x4b89
andl $0xf8, %eax
movl 0x8008(%rdi,%rax), %eax
xorl %edx, %edx
divl %ecx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
orq %rax, %rcx
testl %eax, %eax
cmovnsq %rax, %rcx
jmp 0x4b90
movl $0xf8, %edx
andl %edx, %eax
movl 0x8008(%rdi,%rax), %eax
movl %esi, %ecx
shrl $0x11, %ecx
andl %edx, %ecx
movb 0x8008(%rdi,%rcx), %cl
sarl %cl, %eax
cltq
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
orq %rax, %rcx
testl %eax, %eax
cmovnsq %rax, %rcx
shrl $0x4, %esi
andl %edx, %esi
jmp 0x4b99
movq $-0x1, %rcx
shrl $0x4, %esi
andl $0xf8, %esi
movq %rcx, 0x8008(%rdi,%rsi)
popq %rbp
retq