// File: /workspace/github_c_makefile_star2_O1/agl[P]obstcp/curve25519/donna_c64/smult.c
// Function: fsquare
static void
fsquare(felem *output, const felem *in) {
  uint128_t t[9];

  t[0] = ((uint128_t) in[0]) * in[0];
  t[1] = ((uint128_t) in[0]) * in[1] * 2;
  t[2] = ((uint128_t) in[0]) * in[2] * 2 +
         ((uint128_t) in[1]) * in[1];
  t[3] = ((uint128_t) in[0]) * in[3] * 2 +
         ((uint128_t) in[1]) * in[2] * 2;
  t[4] = ((uint128_t) in[0]) * in[4] * 2 +
         ((uint128_t) in[3]) * in[1] * 2 +
         ((uint128_t) in[2]) * in[2];
  t[5] = ((uint128_t) in[4]) * in[1] * 2 +
         ((uint128_t) in[2]) * in[3] * 2;
  t[6] = ((uint128_t) in[4]) * in[2] * 2 +
         ((uint128_t) in[3]) * in[3];
  t[7] = ((uint128_t) in[3]) * in[4] * 2;
  t[8] = ((uint128_t) in[4]) * in[4];

  t[0] += t[5] * 19;
  t[1] += t[6] * 19;
  t[2] += t[7] * 19;
  t[3] += t[8] * 19;

  t[1] += t[0] >> 51;
  t[0] &= 0x7ffffffffffff;
  t[2] += t[1] >> 51;
  t[1] &= 0x7ffffffffffff;
  t[3] += t[2] >> 51;
  t[2] &= 0x7ffffffffffff;
  t[4] += t[3] >> 51;
  t[3] &= 0x7ffffffffffff;
  t[0] += 19 * (t[4] >> 51);
  t[4] &= 0x7ffffffffffff;
  t[1] += t[0] >> 51;
  t[0] &= 0x7ffffffffffff;

  output[0] = t[0];
  output[1] = t[1];
  output[2] = t[2];
  output[3] = t[3];
  output[4] = t[4];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rsi), %r9
movq 0x8(%rsi), %rbx
movq %r9, %rax
mulq %r9
movq %rax, -0x28(%rsp)
movq %rdx, -0x18(%rsp)
leaq (%r9,%r9), %rcx
movq %r9, %r10
shrq $0x3f, %r10
movq %r10, %r8
imulq %rbx, %r8
movq %rcx, %rax
mulq %rbx
movq %rax, -0x8(%rsp)
addq %r8, %rdx
movq %rdx, -0x30(%rsp)
movq 0x10(%rsi), %r15
imulq %r15, %r10
movq %rcx, %rax
mulq %r15
movq %rax, %rcx
movq %rdx, %r8
addq %r10, %r8
movq %rbx, %rax
mulq %rbx
movq %rax, %r14
addq %rcx, %r14
adcq %r8, %rdx
movq %rdx, -0x38(%rsp)
movq 0x18(%rsi), %r13
movq %r13, %rax
mulq %r9
movq %rdx, %r12
movq %rax, %rbp
movq %r15, %rax
mulq %rbx
movq %rdx, %rcx
movq %rax, %r8
addq %rbp, %r8
adcq %r12, %rcx
shldq $0x1, %r8, %rcx
addq %r8, %r8
movq 0x20(%rsi), %rbp
movq %rbp, %rax
mulq %r9
movq %rdx, %rsi
movq %rax, %r9
movq %r13, %rax
mulq %rbx
movq %rdx, %r12
movq %rax, %r10
addq %r9, %r10
adcq %rsi, %r12
shldq $0x1, %r10, %r12
addq %r10, %r10
movq %r15, %rax
mulq %r15
addq %r10, %rax
movq %rax, -0x10(%rsp)
adcq %r12, %rdx
movq %rdx, -0x20(%rsp)
movq %rbp, %rax
mulq %rbx
movq %rdx, %r10
movq %rax, %rbx
movq %r13, %rax
mulq %r15
movq %rdx, %r12
movq %rax, %rsi
addq %rbx, %rsi
adcq %r10, %r12
movq %r15, %rax
mulq %rbp
movq %rdx, %r10
movq %rax, %rbx
shldq $0x1, %rax, %r10
addq %rax, %rbx
movq %r13, %rax
mulq %r13
movq %rdx, %r15
movq %rax, %r9
addq %rbx, %r9
adcq %r10, %r15
movl $0x26, %r11d
movq %rsi, %rax
mulq %r11
movq %rax, %rbx
imulq $0x26, %r12, %r10
addq %rdx, %r10
addq -0x28(%rsp), %rbx
adcq -0x18(%rsp), %r10
leaq (%r15,%r15,8), %rax
leaq (%r15,%rax,2), %rsi
movl $0x13, %edx
movq %r9, %rax
mulq %rdx
movq %rax, %r12
movq %rdx, %r15
addq %rsi, %r15
addq -0x8(%rsp), %r12
adcq -0x30(%rsp), %r15
movq %r13, %rax
mulq %rbp
movq %rdx, %rsi
mulq %r11
movq %rax, %r11
imulq $0x26, %rsi, %r9
addq %rdx, %r9
addq %r14, %r11
adcq -0x38(%rsp), %r9
movq %rbp, %rax
mulq %rbp
movq %rdx, %rsi
movl $0x13, %r13d
mulq %r13
leaq (%rsi,%rsi,8), %r14
leaq (%rsi,%r14,2), %r14
addq %rdx, %r14
addq %r8, %rax
adcq %rcx, %r14
movq %r10, %rcx
shrq $0x33, %rcx
shldq $0xd, %rbx, %r10
addq %r12, %r10
adcq %r15, %rcx
movabsq $0x7ffffffffffff, %rsi  # imm = 0x7FFFFFFFFFFFF
andq %rsi, %rbx
movq %rcx, %r8
shrq $0x33, %r8
shldq $0xd, %r10, %rcx
addq %r11, %rcx
adcq %r9, %r8
andq %rsi, %r10
movq %r8, %r9
shrq $0x33, %r9
shldq $0xd, %rcx, %r8
addq %rax, %r8
adcq %r14, %r9
movq %r9, %rdx
shrq $0x33, %rdx
shldq $0xd, %r8, %r9
addq -0x10(%rsp), %r9
adcq -0x20(%rsp), %rdx
movq %rdx, %rax
shrq $0x33, %rdx
leaq (%rdx,%rdx,8), %r11
leaq (%rdx,%r11,2), %r11
shldq $0xd, %r9, %rax
mulq %r13
addq %rbx, %rax
adcq %r11, %rdx
shldq $0xd, %rax, %rdx
addq %r10, %rdx
andq %rsi, %rax
movq %rax, (%rdi)
movq %rdx, 0x8(%rdi)
andq %rsi, %rcx
movq %rcx, 0x10(%rdi)
andq %rsi, %r8
movq %r8, 0x18(%rdi)
andq %rsi, %r9
movq %r9, 0x20(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq