// File: /workspace/github_cpp_makefile_star2_O3/occivink[P]pyct/monocypher.cpp
// Function: fe_tobytes(unsigned char*, int const*)
static void fe_tobytes(u8 s[32], const fe h)
{
    i32 t[10];
    COPY(t, h, 10);
    i32 q = (19 * t[9] + (((i32) 1) << 24)) >> 25;
    //                 |t9|                    < 1.1 * 2^24
    //  -1.1 * 2^24  <  t9                     < 1.1 * 2^24
    //  -21  * 2^24  <  19 * t9                < 21  * 2^24
    //  -2^29        <  19 * t9 + 2^24         < 2^29
    //  -2^29 / 2^25 < (19 * t9 + 2^24) / 2^25 < 2^29 / 2^25
    //  -16          < (19 * t9 + 2^24) / 2^25 < 16
    FOR (i, 0, 5) {
        q += t[2*i  ]; q >>= 26; // q = 0 or -1
        q += t[2*i+1]; q >>= 25; // q = 0 or -1
    }
    // q =  0 iff h >= 0
    // q = -1 iff h <  0
    // Adding q * 19 to h reduces h to its proper range.
    q *= 19;  // Shift carry back to the beginning
    FOR (i, 0, 5) {
        t[i*2  ] += q;  q = t[i*2  ] >> 26;  t[i*2  ] -= q * ((i32)1 << 26);
        t[i*2+1] += q;  q = t[i*2+1] >> 25;  t[i*2+1] -= q * ((i32)1 << 25);
    }
    // h is now fully reduced, and q represents the excess bit.

    store32_le(s +  0, ((u32)t[0] >>  0) | ((u32)t[1] << 26));
    store32_le(s +  4, ((u32)t[1] >>  6) | ((u32)t[2] << 19));
    store32_le(s +  8, ((u32)t[2] >> 13) | ((u32)t[3] << 13));
    store32_le(s + 12, ((u32)t[3] >> 19) | ((u32)t[4] <<  6));
    store32_le(s + 16, ((u32)t[5] >>  0) | ((u32)t[6] << 25));
    store32_le(s + 20, ((u32)t[6] >>  7) | ((u32)t[7] << 19));
    store32_le(s + 24, ((u32)t[7] >> 13) | ((u32)t[8] << 12));
    store32_le(s + 28, ((u32)t[8] >> 20) | ((u32)t[9] <<  6));

    WIPE_BUFFER(t);
}

// Assembly:
movq 0x20(%rsi), %rax
movq %rax, -0x8(%rsp)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movaps %xmm1, -0x18(%rsp)
movaps %xmm0, -0x28(%rsp)
movl -0x4(%rsp), %eax
leal (%rax,%rax,8), %ecx
leal (%rax,%rcx,2), %eax
addl $0x1000000, %eax        # imm = 0x1000000
sarl $0x19, %eax
xorl %ecx, %ecx
addl -0x28(%rsp,%rcx,8), %eax
sarl $0x1a, %eax
addl -0x24(%rsp,%rcx,8), %eax
incq %rcx
sarl $0x19, %eax
cmpq $0x5, %rcx
jne 0x78b5
leal (%rax,%rax,8), %ecx
leal (%rax,%rcx,2), %ecx
xorl %eax, %eax
addl -0x28(%rsp,%rax,8), %ecx
movl %ecx, %edx
sarl $0x1a, %edx
andl $0x3ffffff, %ecx        # imm = 0x3FFFFFF
movl %ecx, -0x28(%rsp,%rax,8)
addl -0x24(%rsp,%rax,8), %edx
movl %edx, %ecx
sarl $0x19, %ecx
andl $0x1ffffff, %edx        # imm = 0x1FFFFFF
movl %edx, -0x24(%rsp,%rax,8)
incq %rax
cmpq $0x5, %rax
jne 0x78d4
movl -0x28(%rsp), %eax
movl -0x24(%rsp), %ecx
movl %ecx, %edx
shll $0x1a, %edx
orl %eax, %edx
movb %al, (%rdi)
movb %ah, 0x1(%rdi)
shrl $0x10, %eax
movb %al, 0x2(%rdi)
shrl $0x18, %edx
movb %dl, 0x3(%rdi)
movl %ecx, %eax
shrl $0x6, %eax
movl -0x20(%rsp), %edx
movl %edx, %esi
shll $0x13, %esi
orl %eax, %esi
movb %al, 0x4(%rdi)
shrl $0xe, %ecx
movb %cl, 0x5(%rdi)
movl %esi, %eax
shrl $0x10, %eax
movb %al, 0x6(%rdi)
shrl $0x18, %esi
movb %sil, 0x7(%rdi)
shrl $0xd, %edx
movl -0x1c(%rsp), %ecx
movl %ecx, %eax
shll $0xd, %eax
orl %edx, %eax
movb %dl, 0x8(%rdi)
movb %ah, 0x9(%rdi)
shrl $0x10, %eax
movb %al, 0xa(%rdi)
movl %ecx, %eax
shrl $0xb, %eax
movb %al, 0xb(%rdi)
shrl $0x13, %ecx
movl -0x18(%rsp), %eax
movl %eax, %edx
shll $0x6, %edx
orl %ecx, %edx
movb %dl, 0xc(%rdi)
movb %dh, 0xd(%rdi)
movl %eax, %ecx
shrl $0xa, %ecx
movb %cl, 0xe(%rdi)
shrl $0x12, %eax
movb %al, 0xf(%rdi)
movl -0x14(%rsp), %eax
movl -0x10(%rsp), %ecx
movl %ecx, %edx
shll $0x19, %edx
orl %eax, %edx
movb %al, 0x10(%rdi)
movb %ah, 0x11(%rdi)
shrl $0x10, %eax
movb %al, 0x12(%rdi)
shrl $0x18, %edx
movb %dl, 0x13(%rdi)
movl %ecx, %eax
shrl $0x7, %eax
movl -0xc(%rsp), %edx
movl %edx, %esi
shll $0x13, %esi
orl %eax, %esi
movb %al, 0x14(%rdi)
shrl $0xf, %ecx
movb %cl, 0x15(%rdi)
movl %esi, %eax
shrl $0x10, %eax
movb %al, 0x16(%rdi)
shrl $0x18, %esi
movb %sil, 0x17(%rdi)
shrl $0xd, %edx
movl -0x8(%rsp), %ecx
movl %ecx, %eax
shll $0xc, %eax
orl %edx, %eax
movb %dl, 0x18(%rdi)
movb %ah, 0x19(%rdi)
shrl $0x10, %eax
movb %al, 0x1a(%rdi)
movl %ecx, %eax
shrl $0xc, %eax
movb %al, 0x1b(%rdi)
shrl $0x14, %ecx
movl -0x4(%rsp), %eax
movl %eax, %edx
shll $0x6, %edx
orl %ecx, %edx
movb %dl, 0x1c(%rdi)
movb %dh, 0x1d(%rdi)
movl %eax, %ecx
shrl $0xa, %ecx
movb %cl, 0x1e(%rdi)
shrl $0x12, %eax
movb %al, 0x1f(%rdi)
xorl %eax, %eax
movb $0x0, -0x28(%rsp,%rax)
incq %rax
cmpq $0x28, %rax
jne 0x7a1e
retq