// File: /workspace/github_c_makefile_star2_O0/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
subq $0x10, %rsp
movl $0x3e8, %edi            # imm = 0x3E8
callq 0xd880
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd8d0
movq -0x8(%rbp), %rax
movq $0x0, 0x1808(%rax)
movq -0x8(%rbp), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
movl $0x1, %ecx
movl $0x3, %r8d
callq 0x1690
movq -0x8(%rbp), %rax
cmpq $0x3, 0x1808(%rax)
jne 0xdf29
jmp 0xdf48
leaq 0x188a(%rip), %rdi      # 0xf7ba
leaq 0x189c(%rip), %rsi      # 0xf7d3
movl $0x27, %edx
leaq 0x189b(%rip), %rcx      # 0xf7de
callq 0x10b0
movq -0x8(%rbp), %rax
movq $0x0, 0x1808(%rax)
movq -0x8(%rbp), %rdi
movl $0x300, %esi            # imm = 0x300
movl $0x2, %ecx
movl $0x1, %r8d
movl %ecx, %edx
callq 0x1690
movq -0x8(%rbp), %rax
cmpq $0x4, 0x1808(%rax)
jne 0xdf82
jmp 0xdfa1
leaq 0x1864(%rip), %rdi      # 0xf7ed
leaq 0x1843(%rip), %rsi      # 0xf7d3
movl $0x2b, %edx
leaq 0x1842(%rip), %rcx      # 0xf7de
callq 0x10b0
movq -0x8(%rbp), %rax
movq $0x0, 0x1808(%rax)
movq -0x8(%rbp), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
movl $0x3f, %ecx
movl $0x14, %r8d
callq 0x1690
movq -0x8(%rbp), %rdi
movl $0x300, %esi            # imm = 0x300
xorl %edx, %edx
movl $0x4, %ecx
callq 0x1600
cmpq $0x14, %rax
jne 0xdfe8
jmp 0xe007
leaq 0x1817(%rip), %rdi      # 0xf806
leaq 0x17dd(%rip), %rsi      # 0xf7d3
movl $0x2f, %edx
leaq 0x17dc(%rip), %rcx      # 0xf7de
callq 0x10b0
movq -0x8(%rbp), %rdi
movl $0x2000000, %esi        # imm = 0x2000000
movl $0xe, %edx
callq 0x31c0
movq -0x8(%rbp), %rdi
movl $0x2000000, %esi        # imm = 0x2000000
callq 0x3160
movzbl %al, %eax
cmpl $0xe, %eax
jne 0xe032
jmp 0xe051
leaq 0x17f1(%rip), %rdi      # 0xf82a
leaq 0x1793(%rip), %rsi      # 0xf7d3
movl $0x32, %edx
leaq 0x1792(%rip), %rcx      # 0xf7de
callq 0x10b0
movl $0xa, %edi
movl $0x2, %esi
movl $0x3, %edx
callq 0x1310
cmpq $0x2, %rax
jne 0xe06d
jmp 0xe08c
leaq 0x17d7(%rip), %rdi      # 0xf84b
leaq 0x1758(%rip), %rsi      # 0xf7d3
movl $0x34, %edx
leaq 0x1757(%rip), %rcx      # 0xf7de
callq 0x10b0
movq -0x8(%rbp), %rax
movq $-0x80000000, 0x8010(%rax) # imm = 0x80000000
movq -0x8(%rbp), %rax
movq $-0x8000, 0x8018(%rax) # imm = 0x8000
movq -0x8(%rbp), %rax
movq 0x8010(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8018(%rax), %rsi
callq 0xde40
movq %rax, %rsi
leaq 0x1794(%rip), %rdi      # 0xf863
movb $0x0, %al
callq 0x10a0
movl $0x220a733, -0xc(%rbp)  # imm = 0x220A733
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x51b0
movq -0x8(%rbp), %rax
movq 0x8010(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x8018(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x8078(%rax), %rcx
leaq 0x175b(%rip), %rdi      # 0xf86c
movb $0x0, %al
callq 0x10a0
addq $0x10, %rsp
popq %rbp
retq