// File: /workspace/github_c_makefile_star2_O1/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, %ecx
shrl $0xc, %ecx
movl %ecx, %eax
andb $0x7, %al
cmpb $0x7, %al
ja 0x4ab5
movl %esi, %edx
shrl $0x19, %edx
movl %ecx, %eax
andl $0x7, %eax
leaq 0x37bc(%rip), %r8       # 0x8120
movslq (%r8,%rax,4), %rax
addq %r8, %rax
jmpq *%rax
movl %esi, %eax
shrl $0x7, %eax
andl $0x1f, %eax
movl $0xf8, %r8d
andl %r8d, %ecx
movq 0x8008(%rdi,%rcx), %rcx
shrl $0x11, %esi
andl %r8d, %esi
movq 0x8008(%rdi,%rsi), %rsi
cmpl $0x1, %edx
je 0x4a7a
testl %edx, %edx
jne 0x4a95
addq %rcx, %rsi
jmp 0x4a7e
cmpl $0x1, %edx
jne 0x4ab5
popq %rbp
jmp 0x471a
cmpl $0x1, %edx
jne 0x4ab5
popq %rbp
jmp 0x48df
movl $0xf8, %eax
andl %eax, %ecx
movq 0x8008(%rdi,%rcx), %rdx
movl %esi, %ecx
shrl $0x11, %ecx
andl %eax, %ecx
movb 0x8008(%rdi,%rcx), %cl
andb $0x1f, %cl
shlq %cl, %rdx
movl %edx, %ecx
movslq %edx, %rdx
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
andq %rdx, %r8
orq %rcx, %r8
shrl $0x4, %esi
andl %eax, %esi
movq %r8, 0x8008(%rdi,%rsi)
jmp 0x4ab5
cmpl $0x20, %edx
je 0x4abd
cmpl $0x1, %edx
je 0x4ab7
testl %edx, %edx
jne 0x4ab5
movl $0xf8, %eax
andl %eax, %ecx
movl 0x8008(%rdi,%rcx), %edx
movl %esi, %ecx
shrl $0x11, %ecx
andl %eax, %ecx
movb 0x8008(%rdi,%rcx), %cl
shrl %cl, %edx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
orq %rdx, %rcx
testl %edx, %edx
cmovnsq %rdx, %rcx
shrl $0x4, %esi
andl %eax, %esi
movq %rcx, 0x8008(%rdi,%rsi)
jmp 0x4ab5
cmpl $0x1, %edx
jne 0x4ab5
popq %rbp
jmp 0x4886
imulq %rcx, %rsi
movl %esi, %ecx
movslq %esi, %rdx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rdx, %rsi
orq %rcx, %rsi
jmp 0x4aad
subq %rsi, %rcx
movl %ecx, %edx
movslq %ecx, %rcx
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rcx, %rsi
orq %rdx, %rsi
movq %rsi, 0x8008(%rdi,%rax,8)
popq %rbp
retq
popq %rbp
jmp 0x47d6
movl $0xf8, %eax
andl %eax, %ecx
movl 0x8008(%rdi,%rcx), %edx
movl %esi, %ecx
shrl $0x11, %ecx
andl %eax, %ecx
movb 0x8008(%rdi,%rcx), %cl
sarl %cl, %edx
movslq %edx, %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
orq %rcx, %rdx
testl %ecx, %ecx
cmovnsq %rcx, %rdx
shrl $0x4, %esi
andl %eax, %esi
movq %rdx, 0x8008(%rdi,%rsi)
jmp 0x4ab5