// File: /workspace/github_c_makefile_star2_O0/skeeto[P]enchive/src/curve25519-donna.c
// Function: freduce_coefficients
static void
freduce_coefficients(int64_t *output)
{
  unsigned i;

  output[10] = 0;

  for (i = 0; i < 10; i += 2) {
    int64_t over = div_by_2_26(output[i]);
    /* The entry condition (that |output[i]| < 280*2^54) means that over is, at
     * most, 280*2^28 in the first iteration of this loop. This is added to the
     * next limb and we can approximate the resulting bound of that limb by
     * 281*2^54. */
    output[i] -= over << 26;
    output[i+1] += over;

    /* For the first iteration, |output[i+1]| < 281*2^54, thus |over| <
     * 281*2^29. When this is added to the next limb, the resulting bound can
     * be approximated as 281*2^54.
     *
     * For subsequent iterations of the loop, 281*2^54 remains a conservative
     * bound and no overflow occurs. */
    over = div_by_2_25(output[i+1]);
    output[i+1] -= over << 25;
    output[i+2] += over;
  }
  /* Now |output[10]| < 281*2^29 and all other coefficients are reduced. */
  output[0] += output[10] << 4;
  output[0] += output[10] << 1;
  output[0] += output[10];

  output[10] = 0;

  /* Now output[1..9] are reduced, and |output[0]| < 2^26 + 19*281*2^29
   * So |over| will be no more than 2^16. */
  {
    int64_t over = div_by_2_26(output[0]);
    output[0] -= over << 26;
    output[1] += over;
  }

  /* Now output[0,2..9] are reduced, and |output[1]| < 2^25 + 2^16 < 2^26. The
   * bound on |output[1]| is sufficient to meet our needs. */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x50(%rax)
movl $0x0, -0xc(%rbp)
cmpl $0xa, -0xc(%rbp)
jae 0x996d
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x9ab0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
shlq $0x1a, %rsi
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x9af0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
shlq $0x19, %rsi
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rdx
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xc(%rbp)
jmp 0x98bf
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shlq $0x4, %rcx
movq -0x8(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shlq %rcx
movq -0x8(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
movq -0x8(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x9ab0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdx
shlq $0x1a, %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)