// File: /workspace/github_cpp_makefile_star2_O1/sokolcom[P]tp-blockchain-task06/uint256_t/uint256_t.cpp
// Function: uint256_t::operator*(uint256_t const&) const
uint256_t uint256_t::operator*(const uint256_t & rhs) const{
    // split values into 4 64-bit parts
    uint128_t top[4] = {UPPER.upper(), UPPER.lower(), LOWER.upper(), LOWER.lower()};
    uint128_t bottom[4] = {rhs.upper().upper(), rhs.upper().lower(), rhs.lower().upper(), rhs.lower().lower()};
    uint128_t products[4][4];

    // multiply each component of the values
    for(int y = 3; y > -1; y--){
        for(int x = 3; x > -1; x--){
            products[3 - y][x] = top[x] * bottom[y];
        }
    }

    // first row
    uint128_t fourth64 = uint128_t(products[0][3].lower());
    uint128_t third64  = uint128_t(products[0][2].lower()) + uint128_t(products[0][3].upper());
    uint128_t second64 = uint128_t(products[0][1].lower()) + uint128_t(products[0][2].upper());
    uint128_t first64  = uint128_t(products[0][0].lower()) + uint128_t(products[0][1].upper());

    // second row
    third64  += uint128_t(products[1][3].lower());
    second64 += uint128_t(products[1][2].lower()) + uint128_t(products[1][3].upper());
    first64  += uint128_t(products[1][1].lower()) + uint128_t(products[1][2].upper());

    // third row
    second64 += uint128_t(products[2][3].lower());
    first64  += uint128_t(products[2][2].lower()) + uint128_t(products[2][3].upper());

    // fourth row
    first64  += uint128_t(products[3][3].lower());

    // combines the values, taking care of carry over
    return uint256_t(first64 << uint128_64, uint128_0) +
           uint256_t(third64.upper(), third64 << uint128_64) +
           uint256_t(second64, uint128_0) +
           uint256_t(fourth64);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, 0x28(%rsp)
leaq 0x10(%rsi), %r15
movq %r15, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, 0xc0(%rsp)
xorl %r12d, %r12d
movq %r12, 0xc8(%rsp)
movq %r15, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, 0xd0(%rsp)
movq %r12, 0xd8(%rsp)
movq %rbx, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, 0xe0(%rsp)
movq %r12, 0xe8(%rsp)
movq %rbx, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
movq %r12, 0xf8(%rsp)
leaq 0x10(%r14), %rbx
movq %rbx, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, 0x80(%rsp)
movq %r12, 0x88(%rsp)
movq %rbx, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, 0x90(%rsp)
movq %r12, 0x98(%rsp)
movq %r14, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq %r12, 0xa8(%rsp)
movq %r14, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, 0xb0(%rsp)
movq %r12, 0xb8(%rsp)
movl $0x3, %r14d
leaq 0x120(%rsp), %r15
movq %r14, %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %rbx
addq $0x80, %rbx
movl $0x30, %r12d
leaq (%rsp,%r12), %rdi
addq $0xc0, %rdi
movq %rbx, %rsi
callq 0x283e
movq %rax, (%r15,%r12)
movq %rdx, 0x8(%r15,%r12)
addq $-0x10, %r12
cmpq $-0x10, %r12
jne 0x46a3
addq $0x40, %r15
subq $0x1, %r14
jae 0x468b
leaq 0x150(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x140(%rsp), %r14
movq %r14, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rsp, %r13
movq %rax, (%r13)
xorl %r15d, %r15d
movq %r15, 0x8(%r13)
movq %rbx, %rdi
callq 0x2d8c
movq (%rax), %rax
leaq 0x30(%rsp), %rbx
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x27fa
leaq 0x70(%rsp), %rcx
movq %rax, (%rcx)
movq %rdx, 0x8(%rcx)
leaq 0x130(%rsp), %r12
movq %r12, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%r13)
movq %r15, 0x8(%r13)
movq %r14, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %rsp, %rbx
leaq 0x30(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x27fa
leaq 0x60(%rsp), %rcx
movq %rax, (%rcx)
movq %rdx, 0x8(%rcx)
leaq 0x120(%rsp), %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %r12, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, (%r13)
movq %r15, 0x8(%r13)
movq %rsp, %rbx
leaq 0x30(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x27fa
leaq 0x50(%rsp), %rcx
movq %rax, (%rcx)
movq %rdx, 0x8(%rcx)
leaq 0x190(%rsp), %r14
movq %r14, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %rsp, %rbx
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x280a
leaq 0x180(%rsp), %r13
movq %r13, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbp)
movq %r15, 0x8(%rbp)
movq %r14, %rdi
callq 0x2d8c
movq (%rax), %rax
leaq 0x100(%rsp), %rbp
movq %rax, (%rbp)
movq %r15, 0x8(%rbp)
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x27fa
movq %rax, (%rbx)
movq %rdx, 0x8(%rbx)
movq %rsp, %rbx
leaq 0x60(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x280a
leaq 0x170(%rsp), %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%r14)
movq %r15, 0x8(%r14)
movq %r13, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, (%rbp)
movq %r15, 0x8(%rbp)
leaq 0x30(%rsp), %rbp
leaq 0x100(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rsi
callq 0x27fa
movq %rax, (%rbx)
movq %rdx, 0x8(%rbx)
movq %rsp, %rbx
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x280a
leaq 0x1d0(%rsp), %r14
movq %r14, %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %rsp, %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x280a
leaq 0x1c0(%rsp), %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbp)
movq %r15, 0x8(%rbp)
movq %r14, %rdi
callq 0x2d8c
movq (%rax), %rax
movq %rax, (%r13)
movq %r15, 0x8(%r13)
leaq 0x30(%rsp), %rdi
leaq 0x100(%rsp), %r13
movq %r13, %rsi
callq 0x27fa
movq %rax, (%rbx)
movq %rdx, 0x8(%rbx)
movq %rsp, %rbx
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x280a
leaq 0x210(%rsp), %rdi
callq 0x2d92
movq (%rax), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq %rsp, %rsi
movq %r14, %rdi
callq 0x280a
leaq 0x880b(%rip), %rbx      # 0xd168
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2636
leaq 0x3699(%rip), %r12      # 0x8008
movups (%r12), %xmm0
movaps %xmm0, (%r13)
movq %rax, 0x10(%r13)
movq %rdx, 0x18(%r13)
leaq 0x70(%rsp), %r13
movq %r13, %rdi
callq 0x2d8c
movq %rax, %r14
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2636
leaq 0x268(%rsp), %rcx
movq %rax, (%rcx)
movq %rdx, 0x8(%rcx)
movq (%r14), %rax
movq %rax, 0x10(%rcx)
movq %r15, 0x18(%rcx)
leaq 0x30(%rsp), %rbx
leaq 0x100(%rsp), %rsi
movq %rbx, %rdi
movq %rcx, %rdx
callq 0x435c
movups (%r12), %xmm0
leaq 0x220(%rsp), %rdx
movaps %xmm0, (%rdx)
leaq 0x60(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rdx)
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x435c
leaq 0x248(%rsp), %rdx
movq 0x20(%rsp), %rax
movq %rax, (%rdx)
movq %r15, 0x8(%rdx)
movups (%r12), %xmm0
movups %xmm0, 0x10(%rdx)
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x435c
movq %rbx, %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq