// File: /workspace/github_c_makefile_star2_O2/wjmelements[P]evm/tst/uint256.c
// Function: test_math
void test_math() {
    uint256_t a, b, c, d, e;

    LOWER(LOWER(a)) = 2ull;
    UPPER(LOWER(a)) = 3ull;
    LOWER(UPPER(a)) = 5ull;
    UPPER(UPPER(a)) = 7ull;

    LOWER(LOWER(b)) = 11ull;
    UPPER(LOWER(b)) = 13ull;
    LOWER(UPPER(b)) = 17ull;
    UPPER(UPPER(b)) = 19ull;

    add256(&a, &b, &d);
    assert(LOWER(LOWER(d)) == 13ull);
    assert(UPPER(LOWER(d)) == 16ull);
    assert(LOWER(UPPER(d)) == 22ull);
    assert(UPPER(UPPER(d)) == 26ull);

    minus256(&d, &b, &c);
    assert(equal256(&a, &c));

    clear128(&UPPER(a));
    clear128(&UPPER(b));
    mul256(&a, &b, &d);
    assert(!zero256(&d));
    divmod256(&d, &b, &c, &e);
    assert(zero256(&e));
    assert(equal256(&c, &a));

    // 10e425c56daffabc35c1
    clear128(&UPPER(a));
    assert(UPPER(UPPER(a)) == 0);
    assert(LOWER(UPPER(a)) == 0);
    UPPER(LOWER(a)) = 0x10e4;
    LOWER(LOWER(a)) = 0x25c56daffabc35c1;
    mul256(&a, &a, &a);
    // 11d500bfaf40ac5044981798db5fb39f2c17b81
    assert(UPPER(UPPER(a)) == 0);
    assert(LOWER(UPPER(a)) == 0x11d500b);
    assert(UPPER(LOWER(a)) == 0xfaf40ac504498179);
    assert(LOWER(LOWER(a)) == 0x8db5fb39f2c17b81);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xa0, %rsp
movq %rsp, %rdi
movq $0x2, 0x18(%rdi)
movq $0x3, 0x10(%rdi)
movq $0x5, 0x8(%rdi)
movq $0x7, (%rdi)
leaq 0x40(%rsp), %rsi
movq $0xb, 0x18(%rsi)
movq $0xd, 0x10(%rsi)
movq $0x11, 0x8(%rsi)
movq $0x13, (%rsi)
leaq 0x20(%rsp), %rbx
movq %rbx, %rdx
callq 0x36e3
cmpq $0xd, 0x18(%rbx)
jne 0x1d65
cmpq $0x10, 0x30(%rsp)
jne 0x1d7e
cmpq $0x16, 0x28(%rsp)
jne 0x1d97
cmpq $0x1a, 0x20(%rsp)
jne 0x1db0
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rbx
movq %rbx, %rdx
callq 0x3bbe
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x39c0
testb %al, %al
je 0x1dc9
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x32ba
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x32ba
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3f32
movq %r15, %rdi
callq 0x322d
testb %al, %al
jne 0x1de6
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x80(%rsp), %rbx
movq %rbx, %rcx
callq 0x4767
movq %rbx, %rdi
callq 0x322d
testb %al, %al
je 0x1e05
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0x39c0
testb %al, %al
je 0x1e24
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x32ba
cmpq $0x0, (%rbx)
jne 0x1e43
cmpq $0x0, 0x8(%rsp)
jne 0x1e62
movq %rsp, %rbx
movq $0x10e4, 0x10(%rbx)     # imm = 0x10E4
movabsq $0x25c56daffabc35c1, %rax # imm = 0x25C56DAFFABC35C1
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x3f32
cmpq $0x0, (%rbx)
jne 0x1e81
cmpq $0x11d500b, 0x8(%rsp)   # imm = 0x11D500B
jne 0x1ea0
movabsq $-0x50bf53afbb67e87, %rax # imm = 0xFAF40AC504498179
cmpq %rax, 0x10(%rsp)
jne 0x1ebf
movabsq $-0x724a04c60d3e847f, %rax # imm = 0x8DB5FB39F2C17B81
cmpq %rax, 0x18(%rsp)
jne 0x1ede
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x3a4e(%rip), %rdi      # 0x57ba
leaq 0x3304(%rip), %rsi      # 0x5077
leaq 0x3a59(%rip), %rcx      # 0x57d3
pushq $0x78
jmp 0x1de0
leaq 0x3a5f(%rip), %rdi      # 0x57e4
leaq 0x32eb(%rip), %rsi      # 0x5077
leaq 0x3a40(%rip), %rcx      # 0x57d3
pushq $0x79
jmp 0x1de0
leaq 0x3a5f(%rip), %rdi      # 0x57fd
leaq 0x32d2(%rip), %rsi      # 0x5077
leaq 0x3a27(%rip), %rcx      # 0x57d3
pushq $0x7a
jmp 0x1de0
leaq 0x3a5f(%rip), %rdi      # 0x5816
leaq 0x32b9(%rip), %rsi      # 0x5077
leaq 0x3a0e(%rip), %rcx      # 0x57d3
pushq $0x7b
jmp 0x1de0
leaq 0x3a5f(%rip), %rdi      # 0x582f
leaq 0x32a0(%rip), %rsi      # 0x5077
leaq 0x39f5(%rip), %rcx      # 0x57d3
pushq $0x7e
popq %rdx
callq 0x1030
leaq 0x3a53(%rip), %rdi      # 0x5840
leaq 0x3283(%rip), %rsi      # 0x5077
leaq 0x39d8(%rip), %rcx      # 0x57d3
movl $0x83, %edx
callq 0x1030
leaq 0x3a41(%rip), %rdi      # 0x584d
leaq 0x3264(%rip), %rsi      # 0x5077
leaq 0x39b9(%rip), %rcx      # 0x57d3
movl $0x85, %edx
callq 0x1030
leaq 0x3a2e(%rip), %rdi      # 0x5859
leaq 0x3245(%rip), %rsi      # 0x5077
leaq 0x399a(%rip), %rcx      # 0x57d3
movl $0x86, %edx
callq 0x1030
leaq 0x3a20(%rip), %rdi      # 0x586a
leaq 0x3226(%rip), %rsi      # 0x5077
leaq 0x397b(%rip), %rcx      # 0x57d3
movl $0x8a, %edx
callq 0x1030
leaq 0x3a16(%rip), %rdi      # 0x587f
leaq 0x3207(%rip), %rsi      # 0x5077
leaq 0x395c(%rip), %rcx      # 0x57d3
movl $0x8b, %edx
callq 0x1030
leaq 0x39e2(%rip), %rdi      # 0x586a
leaq 0x31e8(%rip), %rsi      # 0x5077
leaq 0x393d(%rip), %rcx      # 0x57d3
movl $0x90, %edx
callq 0x1030
leaq 0x39ed(%rip), %rdi      # 0x5894
leaq 0x31c9(%rip), %rsi      # 0x5077
leaq 0x391e(%rip), %rcx      # 0x57d3
movl $0x91, %edx
callq 0x1030
leaq 0x39eb(%rip), %rdi      # 0x58b1
leaq 0x31aa(%rip), %rsi      # 0x5077
leaq 0x38ff(%rip), %rcx      # 0x57d3
movl $0x92, %edx
callq 0x1030
leaq 0x39f2(%rip), %rdi      # 0x58d7
leaq 0x318b(%rip), %rsi      # 0x5077
leaq 0x38e0(%rip), %rcx      # 0x57d3
movl $0x93, %edx
callq 0x1030