// File: /workspace/github_c_makefile_star2_O1/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 0x66fd
cmpl $0x2, %ecx
jne 0x68b7
cmpl $0x18, %esi
ja 0x6728
movl %esi, %ecx
leaq 0x1b10(%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 0x5c7d
cmpl $0x18, %esi
ja 0x6741
movl %esi, %ecx
leaq 0x1a81(%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 0x61e5
cmpl $0x1c, %esi
jne 0x675a
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x615c
cmpl $0x1c, %esi
jne 0x675a
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6631
leaq 0x1d1f(%rip), %rdi      # 0x8480
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6b70
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5d02
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5e32
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6258
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6373
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x60d3
movl $0xf8, %r15d
andl %r15d, %eax
movq 0x8008(%r14,%rax), %rsi
movq %r14, %rdi
callq 0x229e
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 0x68b7
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x65ba
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5eb7
movl $0xf8, %r15d
andl %r15d, %eax
movq 0x8008(%r14,%rax), %rsi
movq %r14, %rdi
callq 0x223f
shrl $0x4, %ebx
andl %r15d, %ebx
movq %rax, 0x8008(%r14,%rbx)
jmp 0x68b7
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x63e6
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 0x2d33
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 0x630b
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5f3c
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5fc1
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x604a
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6459
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x64cc
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x6543
nop