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

    if (funct3 == 0x2) {
        switch (funct5) {
        case 0x00:
            ExecAmoaddw(state, instr);
            break;
        case 0x01:
            ExecAmoswapw(state, instr);
            break;
        case 0x02:
            ExecLrw(state, instr);
            break;
        case 0x03:
            ExecScw(state, instr);
            break;
        case 0x04:
            ExecAmoxorw(state, instr);
            break;
        case 0x08:
            ExecAmoorw(state, instr);
            break;
        case 0x0c:
            ExecAmoandw(state, instr);
            break;
        case 0x10:
            ExecAmominw(state, instr);
            break;
        case 0x14:
            ExecAmomaxw(state, instr);
            break;
        case 0x18:
            ExecAmominuw(state, instr);
            break;
        case 0x1c:
            ExecAmomaxuw(state, instr);
            break;
        default:
            Error("Unknown amo instruction: %.2x", funct5);
            break;
        }
    } else if (funct3 == 0x3) {
        switch (funct5) {
        case 0x00:
            ExecAmoaddd(state, instr);
            break;
        case 0x01:
            ExecAmoswapd(state, instr);
            break;
        case 0x02:
            ExecLrd(state, instr);
            break;
        case 0x03:
            ExecScd(state, instr);
            break;
        case 0x04:
            ExecAmoxord(state, instr);
            break;
        case 0x08:
            ExecAmoord(state, instr);
            break;
        case 0x0c:
            ExecAmoandd(state, instr);
            break;
        case 0x10:
            ExecAmomind(state, instr);
            break;
        case 0x14:
            ExecAmomaxd(state, instr);
            break;
        case 0x18:
            ExecAmominud(state, instr);
            break;
        case 0x1c:
            ExecAmomaxud(state, instr);
            break;
        default:
            Error("Unknown amo instruction: %.2x", funct5);
            break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
shrl $0x1b, %esi
movl %ebx, %eax
shrl $0xc, %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x3, %ecx
je 0x679c
cmpl $0x2, %ecx
jne 0x6956
cmpl $0x18, %esi
ja 0x67c7
movl %esi, %ecx
leaq 0x1a71(%rip), %rdx      # 0x81f0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5d1c
cmpl $0x18, %esi
ja 0x67e0
movl %esi, %ecx
leaq 0x19e2(%rip), %rdx      # 0x818c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6284
cmpl $0x1c, %esi
jne 0x67f9
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x61fb
cmpl $0x1c, %esi
jne 0x67f9
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x66d0
leaq 0x1c80(%rip), %rdi      # 0x8480
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6c10
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5da1
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5ed1
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x62f7
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6412
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6172
movl $0xf8, %r15d
andl %r15d, %eax
movq 0x8008(%r14,%rax), %rsi
movq %r14, %rdi
callq 0x2298
movl %eax, %ecx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
orq %rcx, %rdx
testl %eax, %eax
cmovnsq %rcx, %rdx
shrl $0x4, %ebx
andl %r15d, %ebx
movq %rdx, 0x8008(%r14,%rbx)
jmp 0x6956
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6659
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5f56
movl $0xf8, %r15d
andl %r15d, %eax
movq 0x8008(%r14,%rax), %rsi
movq %r14, %rdi
callq 0x2239
shrl $0x4, %ebx
andl %r15d, %ebx
movq %rax, 0x8008(%r14,%rbx)
jmp 0x6956
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6485
movl $0xf8, %r15d
andl %r15d, %eax
movq 0x8008(%r14,%rax), %rsi
movl %ebx, %eax
shrl $0x11, %eax
andl %r15d, %eax
movl 0x8008(%r14,%rax), %edx
movq %r14, %rdi
callq 0x2cc0
shrl $0x4, %ebx
andl %r15d, %ebx
movq $0x0, 0x8008(%r14,%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x63aa
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5fdb
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6060
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x60e9
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x64f8
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x656b
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x65e2
nopl (%rax)