// File: /workspace/github_c_makefile_star2_O0/oreparaz[P]dudect/examples/donna/curve25519-donna.c
// Function: freduce_coefficients
static void freduce_coefficients(limb *output) {
  unsigned i;

  output[10] = 0;

  for (i = 0; i < 10; i += 2) {
    limb 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. */
  {
    limb 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:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq $0x0, 0x50(%rax)
movl $0x0, 0x1c(%rsp)
cmpl $0xa, 0x1c(%rsp)
jae 0x4a81
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x4bd0
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rsi
shlq $0x1a, %rsi
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x4c10
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rsi
shlq $0x19, %rsi
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
addl $0x2, %ecx
movl %ecx, %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x1c(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x1c(%rsp)
jmp 0x49be
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rcx
shlq $0x4, %rcx
movq 0x20(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rcx
shlq %rcx
movq 0x20(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x20(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq $0x0, 0x50(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x4bd0
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rdx
shlq $0x1a, %rdx
movq 0x20(%rsp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)