// File: /workspace/github_c_makefile_star2_O1/wjmelements[P]evm/src/uint256.c
// Function: mul512
void mul512(const uint512_t *number1, const uint512_t *number2, uint512_t *target) {
    uint256_t top[4];
    uint256_t bottom[4];
    clear128(&UPPER(top[0]));
    copy128(&LOWER(top[0]), &UPPER(UPPER_P(number1)));
    clear128(&UPPER(top[1]));
    copy128(&LOWER(top[1]), &LOWER(UPPER_P(number1)));
    clear128(&UPPER(top[2]));
    copy128(&LOWER(top[2]), &UPPER(LOWER_P(number1)));
    clear128(&UPPER(top[3]));
    copy128(&LOWER(top[3]), &LOWER(LOWER_P(number1)));
    clear128(&UPPER(bottom[0]));
    copy128(&LOWER(bottom[0]), &UPPER(UPPER_P(number2)));
    clear128(&UPPER(bottom[1]));
    copy128(&LOWER(bottom[1]), &LOWER(UPPER_P(number2)));
    clear128(&UPPER(bottom[2]));
    copy128(&LOWER(bottom[2]), &UPPER(LOWER_P(number2)));
    clear128(&UPPER(bottom[3]));
    copy128(&LOWER(bottom[3]), &LOWER(LOWER_P(number2)));

    uint256_t products[4][4];
    for (uint8_t y = 4; y --> 0;) {
        for (uint8_t x = 4; x --> 0;) {
            mul256(&top[x], &bottom[y], &products[x][y]);
        }
    }

    uint256_t tmp, tmp2, fourth64, third64, second64, first64;
    clear128(&UPPER(fourth64));
    copy128(&LOWER(fourth64), &LOWER(products[3][3]));
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[3][2]));
    clear128(&UPPER(tmp2));
    copy128(&LOWER(tmp2), &UPPER(products[3][3]));
    add256(&tmp, &tmp2, &third64);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[3][1]));
    clear128(&UPPER(tmp2));
    copy128(&LOWER(tmp2), &UPPER(products[3][2]));
    add256(&tmp, &tmp2, &second64);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[3][0]));
    clear128(&UPPER(tmp2));
    copy128(&LOWER(tmp2), &UPPER(products[3][1]));
    add256(&tmp, &tmp2, &first64);

    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[2][3]));
    add256(&tmp, &third64, &third64);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[2][2]));
    add256(&tmp, &second64, &tmp2);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &UPPER(products[2][3]));
    add256(&tmp, &tmp2, &second64);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[2][1]));
    add256(&tmp, &first64, &tmp2);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &UPPER(products[2][2]));
    add256(&tmp, &tmp2, &first64);

    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[1][3]));
    add256(&tmp, &second64, &second64);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[1][2]));
    add256(&tmp, &first64, &tmp2);
    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &UPPER(products[1][3]));
    add256(&tmp, &tmp2, &first64);

    clear128(&UPPER(tmp));
    copy128(&LOWER(tmp), &LOWER(products[0][3]));
    add256(&tmp, &first64, &first64);

    uint512_t target1, target2;
    clear512(&target1);
    copy128(&UPPER(UPPER(target1)), &LOWER(first64));
    clear512(&target2);
    copy128(&LOWER(UPPER(target2)), &UPPER(third64));
    copy128(&UPPER(LOWER(target2)), &LOWER(third64));
    add512(&target1, &target2, target);
    clear512(&target1);
    copy256(&UPPER(target1), &second64);
    add512(&target1, target, &target2);
    clear512(&target1);
    copy256(&LOWER(target1), &fourth64);
    add512(&target1, &target2, target);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdx, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq (%rdi), %rax
movq %rax, 0xa0(%rsp)
movq 0x8(%rdi), %rax
movq %rax, 0xa8(%rsp)
movaps %xmm0, 0xb0(%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0xc0(%rsp)
movq 0x18(%rdi), %rax
movq %rax, 0xc8(%rsp)
movaps %xmm0, 0xd0(%rsp)
movq 0x20(%rdi), %rax
movq %rax, 0xe0(%rsp)
movq 0x28(%rdi), %rax
movq %rax, 0xe8(%rsp)
movaps %xmm0, 0xf0(%rsp)
movq 0x30(%rdi), %rax
movq %rax, 0x100(%rsp)
movq 0x38(%rdi), %rax
movq %rax, 0x108(%rsp)
movaps %xmm0, 0x10(%rsp)
movq (%rsi), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x28(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x10(%rsi), %rax
movq %rax, 0x40(%rsp)
movq 0x18(%rsi), %rax
movq %rax, 0x48(%rsp)
movaps %xmm0, 0x50(%rsp)
movq 0x20(%rsi), %rax
movq %rax, 0x60(%rsp)
movq 0x28(%rsi), %rax
movq %rax, 0x68(%rsp)
movaps %xmm0, 0x70(%rsp)
movq 0x30(%rsi), %rax
movq %rax, 0x80(%rsp)
movq 0x38(%rsi), %rax
movq %rax, 0x88(%rsp)
movl $0x3, %r12d
leaq 0x2f0(%rsp), %r13
movq %r12, %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %r14
addq $0x10, %r14
movl $0x60, %ebp
movq %r13, %r15
leaq (%rsp,%rbp), %rdi
addq $0x90, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4247
addq $-0x20, %rbp
addq $-0x80, %r15
cmpq $-0x20, %rbp
jne 0x456a
addq $-0x20, %r13
subq $0x1, %r12
jae 0x4553
movaps 0x2e0(%rsp), %xmm0
movaps 0x2f0(%rsp), %xmm1
movaps 0x300(%rsp), %xmm2
movaps %xmm2, (%rsp)
xorps %xmm2, %xmm2
leaq 0x330(%rsp), %r12
movaps %xmm2, (%r12)
movaps %xmm0, 0x10(%r12)
leaq 0x310(%rsp), %r13
movaps %xmm2, (%r13)
movaps %xmm1, 0x10(%r13)
leaq 0x370(%rsp), %r14
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x3862
xorps %xmm2, %xmm2
movaps %xmm2, (%r12)
movaps 0x2c0(%rsp), %xmm0
movaps 0x2d0(%rsp), %xmm1
movaps %xmm0, 0x10(%r12)
movaps %xmm2, (%r13)
movaps %xmm1, 0x10(%r13)
leaq 0x350(%rsp), %r15
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3862
xorps %xmm2, %xmm2
movaps %xmm2, (%r12)
movaps 0x2a0(%rsp), %xmm0
movaps 0x2b0(%rsp), %xmm1
movaps %xmm0, 0x10(%r12)
movaps %xmm2, (%r13)
movaps %xmm1, 0x10(%r13)
leaq 0x390(%rsp), %rbp
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x280(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x260(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x270(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x240(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x250(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x200(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r15, %rsi
movq %r15, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x1e0(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x1f0(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x3862
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movaps 0x180(%rsp), %xmm0
movaps %xmm0, 0x10(%r12)
movq %r12, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x3862
leaq 0x3f0(%rsp), %r12
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%r12)
movaps %xmm1, 0x20(%r12)
movaps %xmm1, 0x30(%r12)
movups 0x10(%rbp), %xmm0
movaps %xmm0, (%r12)
leaq 0x3b0(%rsp), %r13
movaps %xmm1, 0x20(%r13)
movaps %xmm1, (%r13)
movaps %xmm1, 0x30(%r13)
movups (%r14), %xmm0
movaps %xmm0, 0x10(%r13)
movq 0x10(%r14), %rax
movq %rax, 0x20(%r13)
movq 0x18(%r14), %rax
movq %rax, 0x28(%r13)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3dbd
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r12)
movaps %xmm0, 0x20(%r12)
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movaps %xmm0, (%r12)
movaps %xmm1, 0x10(%r12)
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x3dbd
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%r12)
movaps %xmm0, 0x10(%r12)
movaps %xmm0, (%r12)
movaps (%rsp), %xmm0
movaps %xmm0, 0x30(%r12)
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3dbd
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq