// File: /workspace/github_c_makefile_star2_O0/hobo0xcc[P]rve/src/cpu.c
// Function: ExecInstruction
void ExecInstruction(State *state, uint32_t instr) {
    uint8_t opcode = instr & SetNBits(7);
    // If an instruction is compressed.
    if ((opcode & SetNBits(2)) ^ SetNBits(2)) {
        ExecCompressedInstr(state, (uint16_t)(instr & SetNBits(16)));
        return;
    }

    // 32-bit Instruction.
    switch (opcode) {
    case OP_IMM:
        ExecOpImmInstr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case OP_AUIPC:
        ExecAuipc(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case OP_LUI:
        ExecLui(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case OP:
        ExecOpInstr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case JAL:
        ExecJal(state, instr);
        if (state->excepted) return;
        break;
    case JALR:
        ExecJalr(state, instr);
        if (state->excepted) return;
        break;
    case LOAD:
        ExecLoadInstr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case STORE:
        ExecStoreInstr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case BRANCH:
        ExecBranchInstr(state, instr);
        if (state->excepted) return;
        break;
    case OP_IMM_32:
        ExecOpImm32Instr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case OP_32:
        ExecOp32Instr(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case SYSTEM:
        ExecSystemInstr(state, instr);
        if (state->excepted) return;
        break;
    case MISC_MEM:
        ExecMiscMem(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    case AMO:
        ExecAmo(state, instr);
        if (state->excepted) return;
        state->pc += sizeof(instr);
        break;
    default:
        Error("Unknown opcode: 0x%.2x.", opcode);
        break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x28(%rbp)
movl $0x7, %edi
callq 0x12b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
andq %rcx, %rax
movb %al, -0xd(%rbp)
movzbl -0xd(%rbp), %eax
movq %rax, -0x20(%rbp)
movl $0x2, %edi
callq 0x12b0
movq %rax, %rcx
movq -0x20(%rbp), %rax
andq %rcx, %rax
movq %rax, -0x18(%rbp)
movl $0x2, %edi
callq 0x12b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
xorq %rcx, %rax
cmpq $0x0, %rax
je 0x248b
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x30(%rbp)
movl $0x10, %edi
callq 0x12b0
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movq -0x30(%rbp), %rax
andq %rcx, %rax
movzwl %ax, %esi
callq 0x9f20
jmp 0x272b
movzbl -0xd(%rbp), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x70, %eax
ja 0x2719
movq -0x40(%rbp), %rax
leaq 0xcb58(%rip), %rcx      # 0xf004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4b20
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x24d3
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4c60
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2504
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4cf0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2535
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x5bb0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2566
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x5df0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2597
jmp 0x272b
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x5f10
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x25ba
jmp 0x272b
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x6550
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x25dd
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x69e0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x260e
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x72c0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x263f
jmp 0x272b
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x76a0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2662
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x81c0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2693
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xb2a0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x26c1
jmp 0x272b
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xb4f0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x26de
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xd0b0
movq -0x8(%rbp), %rax
testb $0x1, 0x8138(%rax)
je 0x2709
jmp 0x272b
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x272b
movzbl -0xd(%rbp), %esi
leaq 0xcf63(%rip), %rdi      # 0xf687
movb $0x0, %al
callq 0xd690
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)