#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ curve25519_athlon_fromdouble(unsigned char *, double *);
int /*<<< orphan*/ curve25519_athlon_init();
int /*<<< orphan*/ curve25519_athlon_mainloop(double *, unsigned char const *);
int /*<<< orphan*/ curve25519_athlon_mult(double *, double *, double *);
int /*<<< orphan*/ curve25519_athlon_recip(double *, double *);
int /*<<< orphan*/ curve25519_athlon_todouble(double *, unsigned char const *);
void curve25519_athlon(unsigned char ek[32], const unsigned char e[32],
                       const unsigned char k[32]) {
  double work[30];
  curve25519_athlon_init();
  curve25519_athlon_todouble(work, k);
  curve25519_athlon_mainloop(work, e);
  curve25519_athlon_recip(work + 10, work + 10);
  curve25519_athlon_mult(work + 20, work, work + 10);
  curve25519_athlon_fromdouble(ek, work + 20);
}


x86 assembly (clang, -O0):
<curve25519_athlon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1070 <curve25519_athlon_init@plt>
lea    -0x110(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <curve25519_athlon_todouble@plt>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <curve25519_athlon_mainloop@plt>
lea    -0x110(%rbp),%rdi
add    $0x50,%rdi
lea    -0x110(%rbp),%rsi
add    $0x50,%rsi
call   1060 <curve25519_athlon_recip@plt>
lea    -0x110(%rbp),%rdi
add    $0xa0,%rdi
lea    -0x110(%rbp),%rsi
lea    -0x110(%rbp),%rdx
add    $0x50,%rdx
call   1050 <curve25519_athlon_mult@plt>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
add    $0xa0,%rsi
call   1040 <curve25519_athlon_fromdouble@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<curve25519_athlon>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1070 <curve25519_athlon_init@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <curve25519_athlon_todouble@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <curve25519_athlon_mainloop@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <curve25519_athlon_recip@plt>
lea    0xa0(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <curve25519_athlon_mult@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <curve25519_athlon_fromdouble@plt>
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @curve25519_athlon(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [30 x double]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = call i32 (...) @curve25519_athlon_init()
%9 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%10 = load i8*, i8** %6
%11 = call i32 @curve25519_athlon_todouble(double* %9, i8* %10)
%12 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @curve25519_athlon_mainloop(double* %12, i8* %13)
%15 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%16 = getelementptr inbounds double, double* %15, i64 10
%17 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%18 = getelementptr inbounds double, double* %17, i64 10
%19 = call i32 @curve25519_athlon_recip(double* %16, double* %18)
%20 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%21 = getelementptr inbounds double, double* %20, i64 20
%22 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%23 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%24 = getelementptr inbounds double, double* %23, i64 10
%25 = call i32 @curve25519_athlon_mult(double* %21, double* %22, double* %24)
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [30 x double], [30 x double]* %7, i64 0, i64 0
%28 = getelementptr inbounds double, double* %27, i64 20
%29 = call i32 @curve25519_athlon_fromdouble(i8* %26, double* %28)
ret void
}

LLVM IR (-O2):
define void @curve25519_athlon(i8* %0, i8* %1, i8* %2) {
%4 = alloca [30 x double]
%5 = bitcast [30 x double]* %4 to i8*
%6 = tail call i32 (...) @curve25519_athlon_init()
%7 = getelementptr inbounds [30 x double], [30 x double]* %4, i64 0, i64 0
%8 = call i32 @curve25519_athlon_todouble(double* %7, i8* %2)
%9 = call i32 @curve25519_athlon_mainloop(double* %7, i8* %1)
%10 = getelementptr inbounds [30 x double], [30 x double]* %4, i64 0, i64 10
%11 = call i32 @curve25519_athlon_recip(double* %10, double* %10)
%12 = getelementptr inbounds [30 x double], [30 x double]* %4, i64 0, i64 20
%13 = call i32 @curve25519_athlon_mult(double* %12, double* %7, double* %10)
%14 = call i32 @curve25519_athlon_fromdouble(i8* %0, double* %12)
ret void
}