#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*/ scalarmult(unsigned char *, unsigned char *,
                              unsigned char *);
int /*<<< orphan*/ test_scalarmult(unsigned char *, unsigned char *,
                                   unsigned char *, char *);
int main() {
  unsigned char p[32] = {9};
  unsigned char tmp[32] = {0};
  unsigned char fp[32] = {0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54,
                          0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
                          0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4,
                          0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a};
  unsigned char f[32] = {0x70, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d,
                         0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45,
                         0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a,
                         0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a};
  unsigned char gp[32] = {0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4,
                          0xd3, 0x5b, 0x61, 0xc2, 0xec, 0xe4, 0x35, 0x37,
                          0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d,
                          0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f};
  unsigned char g[32] = {0x58, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b,
                         0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, 0x0e, 0xe6,
                         0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd,
                         0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb};
  unsigned char k[32] = {0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1,
                         0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35, 0x0f, 0x25,
                         0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 0x9e, 0x33,
                         0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42};
  test_scalarmult(fp, f, p, "f, 9");
  test_scalarmult(gp, g, p, "g, 9");
  test_scalarmult(k, f, gp, "f, gp");
  test_scalarmult(k, g, fp, "g, fp");
  scalarmult(tmp, f, p);
  test_scalarmult(k, g, tmp, "g, Curve25519(f, 9)");
  scalarmult(tmp, g, p);
  test_scalarmult(k, f, tmp, "f, Curve25519(g, 9)");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    0xebe(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    0xea2(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe9f(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe78(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    0xe6c(%rip),%rax
mov    %rax,-0xb8(%rbp)
mov    0xe66(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe60(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    0xe54(%rip),%rax
mov    %rax,-0xd8(%rbp)
mov    0xe4e(%rip),%rax
mov    %rax,-0xd0(%rbp)
mov    0xe48(%rip),%rax
mov    %rax,-0xc8(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe36(%rip),%rcx
call   1030 <test_scalarmult@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    0xe1d(%rip),%rcx
call   1030 <test_scalarmult@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    0xe04(%rip),%rcx
call   1030 <test_scalarmult@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xdec(%rip),%rcx
call   1030 <test_scalarmult@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <scalarmult@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xdc3(%rip),%rcx
call   1030 <test_scalarmult@plt>
lea    -0x40(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <scalarmult@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xda8(%rip),%rcx
call   1030 <test_scalarmult@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeda(%rip),%rcx
lea    0x80(%rsp),%r13
lea    0x60(%rsp),%r14
lea    0xc0(%rsp),%r15
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <test_scalarmult@plt>
lea    0xeb5(%rip),%rcx
lea    0x40(%rsp),%rbp
lea    0x20(%rsp),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <test_scalarmult@plt>
lea    0xe9b(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1030 <test_scalarmult@plt>
lea    0xe89(%rip),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <test_scalarmult@plt>
lea    0xa0(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1040 <scalarmult@plt>
lea    0xe64(%rip),%rcx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <test_scalarmult@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <scalarmult@plt>
lea    0xe55(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1030 <test_scalarmult@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.p = <{ i8, [31 x i8] }> <{ i8 9, [31 x i8] zeroinitializer }>
@__const.main.fp = [32 x i8] c"\85 \F0\09\890\A7Tt\8B}\DC\B4>\F7Z\0D\BF:\0D&8\1A\F4\EB\A4\A9\8E\AA\9BNj"
@__const.main.f = [32 x i8] c"p\07m\0As\18\A5}<\16\C1rQ\B2fE\DFL/\87\EB\C0\99*\B1w\FB\A5\1D\B9,*"
@__const.main.gp = [32 x i8] c"\DE\9E\DB}{}\C1\B4\D3[a\C2\EC\E457?\83C\C8[xgM\AD\FC~\14o\88+O"
@__const.main.g = [32 x i8] c"X\AB\08~bJ\8AKy\E1\7F\8B\83\80\0E\E6o;\B1)&\18\B6\FD\1C/\8B'\FF\88\E0\EB"
@__const.main.k = [32 x i8] c"J]\9D[\A4\CE-\E1r\8E;\F4\805\0F%\E0~!\C9G\D1\9E3v\F0\9B<\1E\16\17B"
@.str = [5 x i8] c"f, 9\00"
@.str.1 = [5 x i8] c"g, 9\00"
@.str.2 = [6 x i8] c"f, gp\00"
@.str.3 = [6 x i8] c"g, fp\00"
@.str.4 = [20 x i8] c"g, Curve25519(f, 9)\00"
@.str.5 = [20 x i8] c"f, Curve25519(g, 9)\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = bitcast [32 x i8]* %1 to i8*
%9 = bitcast [32 x i8]* %2 to i8*
%10 = bitcast [32 x i8]* %3 to i8*
%11 = bitcast [32 x i8]* %4 to i8*
%12 = bitcast [32 x i8]* %5 to i8*
%13 = bitcast [32 x i8]* %6 to i8*
%14 = bitcast [32 x i8]* %7 to i8*
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%18 = call i32 @test_scalarmult(i8* %15, i8* %16, i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%22 = call i32 @test_scalarmult(i8* %19, i8* %20, i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%26 = call i32 @test_scalarmult(i8* %23, i8* %24, i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%30 = call i32 @test_scalarmult(i8* %27, i8* %28, i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%34 = call i32 @scalarmult(i8* %31, i8* %32, i8* %33)
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%36 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%38 = call i32 @test_scalarmult(i8* %35, i8* %36, i8* %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%42 = call i32 @scalarmult(i8* %39, i8* %40, i8* %41)
%43 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%46 = call i32 @test_scalarmult(i8* %43, i8* %44, i8* %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.p = <{ i8, [31 x i8] }> <{ i8 9, [31 x i8] zeroinitializer }>
@__const.main.fp = [32 x i8] c"\85 \F0\09\890\A7Tt\8B}\DC\B4>\F7Z\0D\BF:\0D&8\1A\F4\EB\A4\A9\8E\AA\9BNj"
@__const.main.f = [32 x i8] c"p\07m\0As\18\A5}<\16\C1rQ\B2fE\DFL/\87\EB\C0\99*\B1w\FB\A5\1D\B9,*"
@__const.main.gp = [32 x i8] c"\DE\9E\DB}{}\C1\B4\D3[a\C2\EC\E457?\83C\C8[xgM\AD\FC~\14o\88+O"
@__const.main.g = [32 x i8] c"X\AB\08~bJ\8AKy\E1\7F\8B\83\80\0E\E6o;\B1)&\18\B6\FD\1C/\8B'\FF\88\E0\EB"
@__const.main.k = [32 x i8] c"J]\9D[\A4\CE-\E1r\8E;\F4\805\0F%\E0~!\C9G\D1\9E3v\F0\9B<\1E\16\17B"
@.str = [5 x i8] c"f, 9\00"
@.str.1 = [5 x i8] c"g, 9\00"
@.str.2 = [6 x i8] c"f, gp\00"
@.str.3 = [6 x i8] c"g, fp\00"
@.str.4 = [20 x i8] c"g, Curve25519(f, 9)\00"
@.str.5 = [20 x i8] c"f, Curve25519(g, 9)\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = alloca [32 x i8]
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%15 = call i32 @test_scalarmult(i8* %10, i8* %11, i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @test_scalarmult(i8* %12, i8* %13, i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @test_scalarmult(i8* %14, i8* %11, i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @test_scalarmult(i8* %14, i8* %13, i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scalarmult(i8* %9, i8* %11, i8* %8)
%20 = call i32 @test_scalarmult(i8* %14, i8* %13, i8* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @scalarmult(i8* %9, i8* %13, i8* %8)
%22 = call i32 @test_scalarmult(i8* %14, i8* %11, i8* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}