// File: /workspace/github_c_makefile_star2_O2/hobo0xcc[P]rve/src/test.c
// Function: RunTest
void RunTest() {
    State *state = NewState(1000);
    ResetState(state);

    state->csr[MSTATUS] = 0;
    WriteCSR(state, MSTATUS, 0, 1, 3);
    assert(state->csr[MSTATUS] == 3);

    state->csr[MSTATUS] = 0;
    WriteCSR(state, MSTATUS, 2, 2, 1);
    assert(state->csr[MSTATUS] == 4);

    state->csr[MSTATUS] = 0;
    WriteCSR(state, MSTATUS, 0, 63, 20);
    assert(ReadCSR(state, MSTATUS, 0, 4) == 20);

    Write8(state, CLINT_BASE, 0x0e);
    assert(Read8(state, CLINT_BASE) == 0x0e);

    assert(GetRange(10, 2, 3) == 2);

    state->x[1] = 0xffffffff80000000;
    state->x[2] = 0xffffffffffff8000;
    printf("a: %lld\n", mulhsu(state->x[1], state->x[2]));
    uint32_t instr = 0x0220a733;
    ExecMulhsu(state, instr);
    printf("%lld, %lld, %lld\n", state->x[1], state->x[2], state->x[14]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x5e0b
movq %rax, %rbx
movq %rax, %rdi
callq 0x5e4c
andq $0x0, 0x1808(%rbx)
pushq $0x1
popq %rcx
pushq $0x3
popq %r8
movq %rbx, %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x14c3
cmpq $0x3, 0x1808(%rbx)
jne 0x6323
andq $0x0, 0x1808(%rbx)
pushq $0x2
popq %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
movl $0x300, %esi            # imm = 0x300
movl %ecx, %edx
callq 0x14c3
cmpq $0x4, 0x1808(%rbx)
jne 0x633c
andq $0x0, 0x1808(%rbx)
pushq $0x3f
popq %rcx
pushq $0x14
popq %r8
movq %rbx, %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x14c3
pushq $0x4
popq %rcx
movq %rbx, %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
callq 0x146b
cmpq $0x14, %rax
jne 0x6355
pushq $0xe
popq %rdx
movl $0x2000000, %esi        # imm = 0x2000000
movq %rbx, %rdi
callq 0x20e0
movl $0x2000000, %esi        # imm = 0x2000000
movq %rbx, %rdi
callq 0x20ac
cmpb $0xe, %al
jne 0x636e
pushq $0xa
popq %rdi
pushq $0x2
popq %rsi
pushq $0x3
popq %rdx
callq 0x1303
cmpq $0x2, %rax
jne 0x6387
movq $-0x80000000, 0x8010(%rbx) # imm = 0x80000000
movq $-0x8000, 0x8018(%rbx) # imm = 0x8000
movq $-0x80000000, %rdi      # imm = 0x80000000
movq $-0x8000, %rsi          # imm = 0x8000
callq 0x6197
leaq 0x1429(%rip), %rdi      # 0x770c
movq %rax, %rsi
xorl %eax, %eax
callq 0x10b0
movq %rbx, %rdi
movl $0x220a733, %esi        # imm = 0x220A733
callq 0x2e9e
movq 0x8010(%rbx), %rsi
movq 0x8018(%rbx), %rdx
movq 0x8078(%rbx), %rcx
leaq 0x13ff(%rip), %rdi      # 0x7715
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x10b0
leaq 0x1339(%rip), %rdi      # 0x7663
leaq 0x134b(%rip), %rsi      # 0x767c
leaq 0x134f(%rip), %rcx      # 0x7687
pushq $0x27
jmp 0x639e
leaq 0x1353(%rip), %rdi      # 0x7696
leaq 0x1332(%rip), %rsi      # 0x767c
leaq 0x1336(%rip), %rcx      # 0x7687
pushq $0x2b
jmp 0x639e
leaq 0x1353(%rip), %rdi      # 0x76af
leaq 0x1319(%rip), %rsi      # 0x767c
leaq 0x131d(%rip), %rcx      # 0x7687
pushq $0x2f
jmp 0x639e
leaq 0x135e(%rip), %rdi      # 0x76d3
leaq 0x1300(%rip), %rsi      # 0x767c
leaq 0x1304(%rip), %rcx      # 0x7687
pushq $0x32
jmp 0x639e
leaq 0x1366(%rip), %rdi      # 0x76f4
leaq 0x12e7(%rip), %rsi      # 0x767c
leaq 0x12eb(%rip), %rcx      # 0x7687
pushq $0x34
popq %rdx
callq 0x10c0