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

    LOWER(LOWER(a)) = 2ull;
    UPPER(LOWER(a)) = 3ull << 8;
    LOWER(UPPER(a)) = 5ull << 16;
    UPPER(UPPER(a)) = 7ull << 24;

    LOWER(LOWER(b)) = 11ull << 32;
    UPPER(LOWER(b)) = (13ull << 40) + (7ull << 8);
    LOWER(UPPER(b)) = 17ull << 48;
    UPPER(UPPER(b)) = 19ull << 56;

    LOWER(LOWER(c)) = 23ull;
    UPPER(LOWER(c)) = 29ull;
    LOWER(UPPER(c)) = 31ull;
    UPPER(UPPER(c)) = 37ull;

    and256(&a, &b, &d);
    assert((LOWER(LOWER(a)) & LOWER(LOWER(b))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) & UPPER(LOWER(b))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) & LOWER(UPPER(b))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) & UPPER(UPPER(b))) == UPPER(UPPER(d)));

    and256(&a, &c, &d);
    assert((LOWER(LOWER(a)) & LOWER(LOWER(c))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) & UPPER(LOWER(c))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) & LOWER(UPPER(c))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) & UPPER(UPPER(c))) == UPPER(UPPER(d)));

    or256(&a, &b, &d);
    assert((LOWER(LOWER(a)) | LOWER(LOWER(b))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) | UPPER(LOWER(b))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) | LOWER(UPPER(b))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) | UPPER(UPPER(b))) == UPPER(UPPER(d)));

    or256(&a, &c, &d);
    assert((LOWER(LOWER(a)) | LOWER(LOWER(c))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) | UPPER(LOWER(c))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) | LOWER(UPPER(c))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) | UPPER(UPPER(c))) == UPPER(UPPER(d)));

    xor256(&a, &b, &d);
    assert((LOWER(LOWER(a)) ^ LOWER(LOWER(b))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) ^ UPPER(LOWER(b))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) ^ LOWER(UPPER(b))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) ^ UPPER(UPPER(b))) == UPPER(UPPER(d)));

    xor256(&a, &c, &d);
    assert((LOWER(LOWER(a)) ^ LOWER(LOWER(c))) == LOWER(LOWER(d)));
    assert((UPPER(LOWER(a)) ^ UPPER(LOWER(c))) == UPPER(LOWER(d)));
    assert((LOWER(UPPER(a)) ^ LOWER(UPPER(c))) == LOWER(UPPER(d)));
    assert((UPPER(UPPER(a)) ^ UPPER(UPPER(c))) == UPPER(UPPER(d)));

    xor256(&a, &b, &a);
    xor256(&a, &b, &b);
    xor256(&a, &b, &a);
    assert(LOWER(LOWER(b)) == 2ull);
    assert(UPPER(LOWER(b)) == 3ull << 8);
    assert(LOWER(UPPER(b)) == 5ull << 16);
    assert(UPPER(UPPER(b)) == 7ull << 24);
    assert(LOWER(LOWER(a)) == 11ull << 32);
    assert(UPPER(LOWER(a)) == (13ull << 40) + (7ull << 8));
    assert(LOWER(UPPER(a)) == 17ull << 48);
    assert(UPPER(UPPER(a)) == 19ull << 56);

    clear256(&d);
    assert(LOWER(LOWER(d)) == 0);
    assert(UPPER(LOWER(d)) == 0);
    assert(LOWER(UPPER(d)) == 0);
    assert(UPPER(UPPER(d)) == 0);

    assert(!zero256(&a));
    assert(!zero256(&b));
    assert(!zero256(&c));
    assert(zero256(&d));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movabsq $0x1300000000000000, %rax # imm = 0x1300000000000000
movabsq $0x11000000000000, %r13 # imm = 0x11000000000000
movabsq $0xd0000000700, %rbp    # imm = 0xD0000000700
movabsq $0xb00000000, %r12      # imm = 0xB00000000
leaq 0x8(%rsp), %rbx
movq $0x2, 0x18(%rbx)
movq $0x300, 0x10(%rbx)      # imm = 0x300
movq $0x50000, 0x8(%rbx)     # imm = 0x50000
movq $0x7000000, (%rbx)      # imm = 0x7000000
leaq 0x68(%rsp), %r14
movq %r12, 0x18(%r14)
movq %rbp, 0x10(%r14)
movq %r13, 0x8(%r14)
movq %rax, (%r14)
movq $0x17, 0x60(%rsp)
movq $0x1d, 0x58(%rsp)
movq $0x1f, 0x50(%rsp)
movq $0x25, 0x48(%rsp)
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3d4a
movq 0x18(%r14), %rax
andq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x15a3
movq 0x78(%rsp), %rax
andq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x15bf
movq 0x70(%rsp), %rax
andq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x15db
movq 0x68(%rsp), %rax
andq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x15f7
leaq 0x8(%rsp), %rbx
leaq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3d4a
movq 0x18(%r14), %rax
andq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x1613
movq 0x58(%rsp), %rax
andq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x162f
movq 0x50(%rsp), %rax
andq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x164b
movq 0x48(%rsp), %rax
andq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x1667
leaq 0x8(%rsp), %rbx
leaq 0x68(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3cd4
movq 0x18(%r14), %rax
orq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x1683
movq 0x78(%rsp), %rax
orq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x169f
movq 0x70(%rsp), %rax
orq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x16bb
movq 0x68(%rsp), %rax
orq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x16d7
leaq 0x8(%rsp), %rbx
leaq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3cd4
movq 0x18(%r14), %rax
orq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x16f3
movq 0x58(%rsp), %rax
orq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x170f
movq 0x50(%rsp), %rax
orq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x172b
movq 0x48(%rsp), %rax
orq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x1747
leaq 0x8(%rsp), %rbx
leaq 0x68(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3d8e
movq 0x18(%r14), %rax
xorq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x1763
movq 0x78(%rsp), %rax
xorq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x177f
movq 0x70(%rsp), %rax
xorq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x179b
movq 0x68(%rsp), %rax
xorq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x17b7
leaq 0x8(%rsp), %rbx
leaq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3d8e
movq 0x18(%r14), %rax
xorq 0x18(%rbx), %rax
cmpq 0x18(%r15), %rax
jne 0x17d3
movq 0x58(%rsp), %rax
xorq 0x18(%rsp), %rax
cmpq 0x38(%rsp), %rax
jne 0x17ef
movq 0x50(%rsp), %rax
xorq 0x10(%rsp), %rax
cmpq 0x30(%rsp), %rax
jne 0x180b
movq 0x48(%rsp), %rax
xorq 0x8(%rsp), %rax
cmpq 0x28(%rsp), %rax
jne 0x1827
leaq 0x68(%rsp), %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3d8e
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x3d8e
movq %r14, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3d8e
cmpq $0x2, 0x18(%rbx)
jne 0x1843
cmpq $0x300, 0x78(%rsp)      # imm = 0x300
jne 0x185f
cmpq $0x50000, 0x70(%rsp)    # imm = 0x50000
jne 0x187b
cmpq $0x7000000, 0x68(%rsp)  # imm = 0x7000000
jne 0x1897
cmpq %r12, 0x20(%rsp)
jne 0x18b3
cmpq %rbp, 0x18(%rsp)
jne 0x18cf
cmpq %r13, 0x10(%rsp)
jne 0x18eb
movabsq $0x1300000000000000, %rax # imm = 0x1300000000000000
cmpq %rax, 0x8(%rsp)
jne 0x1907
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x32c1
cmpq $0x0, 0x18(%rbx)
jne 0x1923
cmpq $0x0, 0x38(%rsp)
jne 0x193f
cmpq $0x0, 0x30(%rsp)
jne 0x195b
cmpq $0x0, 0x28(%rsp)
jne 0x1974
leaq 0x8(%rsp), %rdi
callq 0x322d
testb %al, %al
jne 0x198d
leaq 0x68(%rsp), %rdi
callq 0x322d
testb %al, %al
jne 0x19a6
leaq 0x48(%rsp), %rdi
callq 0x322d
testb %al, %al
jne 0x19bf
leaq 0x28(%rsp), %rdi
callq 0x322d
testb %al, %al
je 0x19d8
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a96(%rip), %rdi      # 0x5040
leaq 0x3ac6(%rip), %rsi      # 0x5077
leaq 0x3acd(%rip), %rcx      # 0x5085
pushq $0x1a
jmp 0x19ef
leaq 0x3ad3(%rip), %rdi      # 0x5099
leaq 0x3aaa(%rip), %rsi      # 0x5077
leaq 0x3ab1(%rip), %rcx      # 0x5085
pushq $0x1b
jmp 0x19ef
leaq 0x3aee(%rip), %rdi      # 0x50d0
leaq 0x3a8e(%rip), %rsi      # 0x5077
leaq 0x3a95(%rip), %rcx      # 0x5085
pushq $0x1c
jmp 0x19ef
leaq 0x3b09(%rip), %rdi      # 0x5107
leaq 0x3a72(%rip), %rsi      # 0x5077
leaq 0x3a79(%rip), %rcx      # 0x5085
pushq $0x1d
jmp 0x19ef
leaq 0x3b24(%rip), %rdi      # 0x513e
leaq 0x3a56(%rip), %rsi      # 0x5077
leaq 0x3a5d(%rip), %rcx      # 0x5085
pushq $0x20
jmp 0x19ef
leaq 0x3b3f(%rip), %rdi      # 0x5175
leaq 0x3a3a(%rip), %rsi      # 0x5077
leaq 0x3a41(%rip), %rcx      # 0x5085
pushq $0x21
jmp 0x19ef
leaq 0x3b5a(%rip), %rdi      # 0x51ac
leaq 0x3a1e(%rip), %rsi      # 0x5077
leaq 0x3a25(%rip), %rcx      # 0x5085
pushq $0x22
jmp 0x19ef
leaq 0x3b75(%rip), %rdi      # 0x51e3
leaq 0x3a02(%rip), %rsi      # 0x5077
leaq 0x3a09(%rip), %rcx      # 0x5085
pushq $0x23
jmp 0x19ef
leaq 0x3b90(%rip), %rdi      # 0x521a
leaq 0x39e6(%rip), %rsi      # 0x5077
leaq 0x39ed(%rip), %rcx      # 0x5085
pushq $0x26
jmp 0x19ef
leaq 0x3bab(%rip), %rdi      # 0x5251
leaq 0x39ca(%rip), %rsi      # 0x5077
leaq 0x39d1(%rip), %rcx      # 0x5085
pushq $0x27
jmp 0x19ef
leaq 0x3bc6(%rip), %rdi      # 0x5288
leaq 0x39ae(%rip), %rsi      # 0x5077
leaq 0x39b5(%rip), %rcx      # 0x5085
pushq $0x28
jmp 0x19ef
leaq 0x3be1(%rip), %rdi      # 0x52bf
leaq 0x3992(%rip), %rsi      # 0x5077
leaq 0x3999(%rip), %rcx      # 0x5085
pushq $0x29
jmp 0x19ef
leaq 0x3bfc(%rip), %rdi      # 0x52f6
leaq 0x3976(%rip), %rsi      # 0x5077
leaq 0x397d(%rip), %rcx      # 0x5085
pushq $0x2c
jmp 0x19ef
leaq 0x3c17(%rip), %rdi      # 0x532d
leaq 0x395a(%rip), %rsi      # 0x5077
leaq 0x3961(%rip), %rcx      # 0x5085
pushq $0x2d
jmp 0x19ef
leaq 0x3c32(%rip), %rdi      # 0x5364
leaq 0x393e(%rip), %rsi      # 0x5077
leaq 0x3945(%rip), %rcx      # 0x5085
pushq $0x2e
jmp 0x19ef
leaq 0x3c4d(%rip), %rdi      # 0x539b
leaq 0x3922(%rip), %rsi      # 0x5077
leaq 0x3929(%rip), %rcx      # 0x5085
pushq $0x2f
jmp 0x19ef
leaq 0x3c68(%rip), %rdi      # 0x53d2
leaq 0x3906(%rip), %rsi      # 0x5077
leaq 0x390d(%rip), %rcx      # 0x5085
pushq $0x32
jmp 0x19ef
leaq 0x3c83(%rip), %rdi      # 0x5409
leaq 0x38ea(%rip), %rsi      # 0x5077
leaq 0x38f1(%rip), %rcx      # 0x5085
pushq $0x33
jmp 0x19ef
leaq 0x3c9e(%rip), %rdi      # 0x5440
leaq 0x38ce(%rip), %rsi      # 0x5077
leaq 0x38d5(%rip), %rcx      # 0x5085
pushq $0x34
jmp 0x19ef
leaq 0x3cb9(%rip), %rdi      # 0x5477
leaq 0x38b2(%rip), %rsi      # 0x5077
leaq 0x38b9(%rip), %rcx      # 0x5085
pushq $0x35
jmp 0x19ef
leaq 0x3cd4(%rip), %rdi      # 0x54ae
leaq 0x3896(%rip), %rsi      # 0x5077
leaq 0x389d(%rip), %rcx      # 0x5085
pushq $0x38
jmp 0x19ef
leaq 0x3cef(%rip), %rdi      # 0x54e5
leaq 0x387a(%rip), %rsi      # 0x5077
leaq 0x3881(%rip), %rcx      # 0x5085
pushq $0x39
jmp 0x19ef
leaq 0x3d0a(%rip), %rdi      # 0x551c
leaq 0x385e(%rip), %rsi      # 0x5077
leaq 0x3865(%rip), %rcx      # 0x5085
pushq $0x3a
jmp 0x19ef
leaq 0x3d25(%rip), %rdi      # 0x5553
leaq 0x3842(%rip), %rsi      # 0x5077
leaq 0x3849(%rip), %rcx      # 0x5085
pushq $0x3b
jmp 0x19ef
leaq 0x3d40(%rip), %rdi      # 0x558a
leaq 0x3826(%rip), %rsi      # 0x5077
leaq 0x382d(%rip), %rcx      # 0x5085
pushq $0x40
jmp 0x19ef
leaq 0x3d3c(%rip), %rdi      # 0x55a2
leaq 0x380a(%rip), %rsi      # 0x5077
leaq 0x3811(%rip), %rcx      # 0x5085
pushq $0x41
jmp 0x19ef
leaq 0x3d3d(%rip), %rdi      # 0x55bf
leaq 0x37ee(%rip), %rsi      # 0x5077
leaq 0x37f5(%rip), %rcx      # 0x5085
pushq $0x42
jmp 0x19ef
leaq 0x3d3f(%rip), %rdi      # 0x55dd
leaq 0x37d2(%rip), %rsi      # 0x5077
leaq 0x37d9(%rip), %rcx      # 0x5085
pushq $0x43
jmp 0x19ef
leaq 0x3d41(%rip), %rdi      # 0x55fb
leaq 0x37b6(%rip), %rsi      # 0x5077
leaq 0x37bd(%rip), %rcx      # 0x5085
pushq $0x44
jmp 0x19ef
leaq 0x3d44(%rip), %rdi      # 0x561a
leaq 0x379a(%rip), %rsi      # 0x5077
leaq 0x37a1(%rip), %rcx      # 0x5085
pushq $0x45
jmp 0x19ef
leaq 0x3d57(%rip), %rdi      # 0x5649
leaq 0x377e(%rip), %rsi      # 0x5077
leaq 0x3785(%rip), %rcx      # 0x5085
pushq $0x46
jmp 0x19ef
leaq 0x3d5a(%rip), %rdi      # 0x5668
leaq 0x3762(%rip), %rsi      # 0x5077
leaq 0x3769(%rip), %rcx      # 0x5085
pushq $0x47
jmp 0x19ef
leaq 0x3d5d(%rip), %rdi      # 0x5687
leaq 0x3746(%rip), %rsi      # 0x5077
leaq 0x374d(%rip), %rcx      # 0x5085
pushq $0x4a
jmp 0x19ef
leaq 0x3d56(%rip), %rdi      # 0x569c
leaq 0x372a(%rip), %rsi      # 0x5077
leaq 0x3731(%rip), %rcx      # 0x5085
pushq $0x4b
jmp 0x19ef
leaq 0x3d4f(%rip), %rdi      # 0x56b1
leaq 0x370e(%rip), %rsi      # 0x5077
leaq 0x3715(%rip), %rcx      # 0x5085
pushq $0x4c
jmp 0x19ef
leaq 0x3d4b(%rip), %rdi      # 0x56c6
leaq 0x36f5(%rip), %rsi      # 0x5077
leaq 0x36fc(%rip), %rcx      # 0x5085
pushq $0x4d
jmp 0x19ef
leaq 0x3d47(%rip), %rdi      # 0x56db
leaq 0x36dc(%rip), %rsi      # 0x5077
leaq 0x36e3(%rip), %rcx      # 0x5085
pushq $0x4f
jmp 0x19ef
leaq 0x3d3b(%rip), %rdi      # 0x56e8
leaq 0x36c3(%rip), %rsi      # 0x5077
leaq 0x36ca(%rip), %rcx      # 0x5085
pushq $0x50
jmp 0x19ef
leaq 0x3d2f(%rip), %rdi      # 0x56f5
leaq 0x36aa(%rip), %rsi      # 0x5077
leaq 0x36b1(%rip), %rcx      # 0x5085
pushq $0x51
jmp 0x19ef
leaq 0x3e62(%rip), %rdi      # 0x5841
leaq 0x3691(%rip), %rsi      # 0x5077
leaq 0x3698(%rip), %rcx      # 0x5085
pushq $0x52
popq %rdx
callq 0x1030