// File: /workspace/github_cpp_makefile_star2_O1/msotoodeh[P]asymmetric-passwords/common/curve25519/curve25519_mehdi.c
// Function: ecp_Inverse
void ecp_Inverse(U32 *out, const U32 *z) 
{
  int i;
  U32 t0[8],t1[8],z2[8],z9[8],z11[8];
  U32 z2_5_0[8],z2_10_0[8],z2_20_0[8],z2_50_0[8],z2_100_0[8];

  /* 2 */               ecp_SqrReduce(z2,z);
  /* 4 */               ecp_SqrReduce(t1,z2);
  /* 8 */               ecp_SqrReduce(t0,t1);
  /* 9 */               ecp_MulReduce(z9,t0,z);
  /* 11 */              ecp_MulReduce(z11,z9,z2);
  /* 22 */              ecp_SqrReduce(t0,z11);
  /* 2^5 - 2^0 = 31 */  ecp_MulReduce(z2_5_0,t0,z9);

  /* 2^6 - 2^1 */       ecp_SqrReduce(t0,z2_5_0);
  /* 2^7 - 2^2 */       ecp_SqrReduce(t1,t0);
  /* 2^8 - 2^3 */       ecp_SqrReduce(t0,t1);
  /* 2^9 - 2^4 */       ecp_SqrReduce(t1,t0);
  /* 2^10 - 2^5 */      ecp_SqrReduce(t0,t1);
  /* 2^10 - 2^0 */      ecp_MulReduce(z2_10_0,t0,z2_5_0);

  /* 2^11 - 2^1 */      ecp_SqrReduce(t0,z2_10_0);
  /* 2^12 - 2^2 */      ecp_SqrReduce(t1,t0);
  /* 2^20 - 2^10 */     for (i = 2;i < 10;i += 2) { 
                            ecp_SqrReduce(t0,t1); 
                            ecp_SqrReduce(t1,t0); }
  /* 2^20 - 2^0 */      ecp_MulReduce(z2_20_0,t1,z2_10_0);

  /* 2^21 - 2^1 */      ecp_SqrReduce(t0,z2_20_0);
  /* 2^22 - 2^2 */      ecp_SqrReduce(t1,t0);
  /* 2^40 - 2^20 */     for (i = 2;i < 20;i += 2) { 
                            ecp_SqrReduce(t0,t1); 
                            ecp_SqrReduce(t1,t0); }
  /* 2^40 - 2^0 */      ecp_MulReduce(t0,t1,z2_20_0);

  /* 2^41 - 2^1 */      ecp_SqrReduce(t1,t0);
  /* 2^42 - 2^2 */      ecp_SqrReduce(t0,t1);
  /* 2^50 - 2^10 */     for (i = 2;i < 10;i += 2) { 
                            ecp_SqrReduce(t1,t0); 
                            ecp_SqrReduce(t0,t1); }
  /* 2^50 - 2^0 */      ecp_MulReduce(z2_50_0,t0,z2_10_0);

  /* 2^51 - 2^1 */      ecp_SqrReduce(t0,z2_50_0);
  /* 2^52 - 2^2 */      ecp_SqrReduce(t1,t0);
  /* 2^100 - 2^50 */    for (i = 2;i < 50;i += 2) { 
                            ecp_SqrReduce(t0,t1); 
                            ecp_SqrReduce(t1,t0); }
  /* 2^100 - 2^0 */     ecp_MulReduce(z2_100_0,t1,z2_50_0);

  /* 2^101 - 2^1 */     ecp_SqrReduce(t1,z2_100_0);
  /* 2^102 - 2^2 */     ecp_SqrReduce(t0,t1);
  /* 2^200 - 2^100 */   for (i = 2;i < 100;i += 2) { 
                            ecp_SqrReduce(t1,t0); 
                            ecp_SqrReduce(t0,t1); }
  /* 2^200 - 2^0 */     ecp_MulReduce(t1,t0,z2_100_0);

  /* 2^201 - 2^1 */     ecp_SqrReduce(t0,t1);
  /* 2^202 - 2^2 */     ecp_SqrReduce(t1,t0);
  /* 2^250 - 2^50 */    for (i = 2;i < 50;i += 2) { 
                            ecp_SqrReduce(t0,t1); 
                            ecp_SqrReduce(t1,t0); }
  /* 2^250 - 2^0 */     ecp_MulReduce(t0,t1,z2_50_0);

  /* 2^251 - 2^1 */     ecp_SqrReduce(t1,t0);
  /* 2^252 - 2^2 */     ecp_SqrReduce(t0,t1);
  /* 2^253 - 2^3 */     ecp_SqrReduce(t1,t0);
  /* 2^254 - 2^4 */     ecp_SqrReduce(t0,t1);
  /* 2^255 - 2^5 */     ecp_SqrReduce(t1,t0);
  /* 2^255 - 21 */      ecp_MulReduce(out,t1,z11);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x120(%rsp), %r13
movq %r13, %rdi
callq 0x40a578
movq %rsp, %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x40a578
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
leaq 0x100(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40a2f0
leaq 0xc0(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x40a2f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x40a578
leaq 0xe0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x40a2f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
leaq 0x60(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x40a2f0
movq %r15, %rdi
movq %r13, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x8, %ebp
jb 0x40a733
leaq 0xa0(%rsp), %r12
movq %rsp, %r14
leaq 0x60(%rsp), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x40a2f0
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x12, %ebp
jb 0x40a789
leaq 0x20(%rsp), %r14
movq %rsp, %r15
leaq 0xa0(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a2f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x8, %ebp
jb 0x40a7da
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %r14
leaq 0x60(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a2f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x30, %ebp
jb 0x40a82d
leaq 0x80(%rsp), %r15
movq %rsp, %r14
leaq 0x40(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a2f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x62, %ebp
jb 0x40a883
movq %rsp, %r14
leaq 0x20(%rsp), %r15
leaq 0x80(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a2f0
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
xorl %ebp, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
addl $0x2, %ebp
cmpl $0x30, %ebp
jb 0x40a8d4
leaq 0x20(%rsp), %r15
movq %rsp, %r14
leaq 0x40(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a2f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
movq %r15, %rdi
movq %r14, %rsi
callq 0x40a578
movq %r14, %rdi
movq %r15, %rsi
callq 0x40a578
leaq 0xc0(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40a2f0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop