// File: /workspace/github_c_makefile_star2_O1/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 0x3862
cmpq $0xd, 0x18(%rbx)
jne 0x1e11
cmpq $0x10, 0x30(%rsp)
jne 0x1e30
cmpq $0x16, 0x28(%rsp)
jne 0x1e4f
cmpq $0x1a, 0x20(%rsp)
jne 0x1e6e
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rbx
movq %rbx, %rdx
callq 0x3e8b
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x3be6
testb %al, %al
je 0x1e8d
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x33c7
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x33c7
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4247
movq %r15, %rdi
callq 0x333a
testb %al, %al
jne 0x1eac
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x80(%rsp), %rbx
movq %rbx, %rcx
callq 0x4b96
movq %rbx, %rdi
callq 0x333a
testb %al, %al
je 0x1ecb
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0x3be6
testb %al, %al
je 0x1eea
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x33c7
cmpq $0x0, (%rbx)
jne 0x1f09
cmpq $0x0, 0x8(%rsp)
jne 0x1f28
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 0x4247
cmpq $0x0, (%rbx)
jne 0x1f47
cmpq $0x11d500b, 0x8(%rsp)   # imm = 0x11D500B
jne 0x1f66
movabsq $-0x50bf53afbb67e87, %rax # imm = 0xFAF40AC504498179
cmpq %rax, 0x10(%rsp)
jne 0x1f85
movabsq $-0x724a04c60d3e847f, %rax # imm = 0x8DB5FB39F2C17B81
cmpq %rax, 0x18(%rsp)
jne 0x1fa4
addq $0xa0, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x49a2(%rip), %rdi      # 0x67ba
leaq 0x4258(%rip), %rsi      # 0x6077
leaq 0x49ad(%rip), %rcx      # 0x67d3
movl $0x78, %edx
callq 0x1030
leaq 0x49ad(%rip), %rdi      # 0x67e4
leaq 0x4239(%rip), %rsi      # 0x6077
leaq 0x498e(%rip), %rcx      # 0x67d3
movl $0x79, %edx
callq 0x1030
leaq 0x49a7(%rip), %rdi      # 0x67fd
leaq 0x421a(%rip), %rsi      # 0x6077
leaq 0x496f(%rip), %rcx      # 0x67d3
movl $0x7a, %edx
callq 0x1030
leaq 0x49a1(%rip), %rdi      # 0x6816
leaq 0x41fb(%rip), %rsi      # 0x6077
leaq 0x4950(%rip), %rcx      # 0x67d3
movl $0x7b, %edx
callq 0x1030
leaq 0x499b(%rip), %rdi      # 0x682f
leaq 0x41dc(%rip), %rsi      # 0x6077
leaq 0x4931(%rip), %rcx      # 0x67d3
movl $0x7e, %edx
callq 0x1030
leaq 0x498d(%rip), %rdi      # 0x6840
leaq 0x41bd(%rip), %rsi      # 0x6077
leaq 0x4912(%rip), %rcx      # 0x67d3
movl $0x83, %edx
callq 0x1030
leaq 0x497b(%rip), %rdi      # 0x684d
leaq 0x419e(%rip), %rsi      # 0x6077
leaq 0x48f3(%rip), %rcx      # 0x67d3
movl $0x85, %edx
callq 0x1030
leaq 0x4968(%rip), %rdi      # 0x6859
leaq 0x417f(%rip), %rsi      # 0x6077
leaq 0x48d4(%rip), %rcx      # 0x67d3
movl $0x86, %edx
callq 0x1030
leaq 0x495a(%rip), %rdi      # 0x686a
leaq 0x4160(%rip), %rsi      # 0x6077
leaq 0x48b5(%rip), %rcx      # 0x67d3
movl $0x8a, %edx
callq 0x1030
leaq 0x4950(%rip), %rdi      # 0x687f
leaq 0x4141(%rip), %rsi      # 0x6077
leaq 0x4896(%rip), %rcx      # 0x67d3
movl $0x8b, %edx
callq 0x1030
leaq 0x491c(%rip), %rdi      # 0x686a
leaq 0x4122(%rip), %rsi      # 0x6077
leaq 0x4877(%rip), %rcx      # 0x67d3
movl $0x90, %edx
callq 0x1030
leaq 0x4927(%rip), %rdi      # 0x6894
leaq 0x4103(%rip), %rsi      # 0x6077
leaq 0x4858(%rip), %rcx      # 0x67d3
movl $0x91, %edx
callq 0x1030
leaq 0x4925(%rip), %rdi      # 0x68b1
leaq 0x40e4(%rip), %rsi      # 0x6077
leaq 0x4839(%rip), %rcx      # 0x67d3
movl $0x92, %edx
callq 0x1030
leaq 0x492c(%rip), %rdi      # 0x68d7
leaq 0x40c5(%rip), %rsi      # 0x6077
leaq 0x481a(%rip), %rcx      # 0x67d3
movl $0x93, %edx
callq 0x1030