#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*/ print_info(double, unsigned long long, char *, int);
int /*<<< orphan*/ printf(char *, ...);
double test_falcon();
double test_rijndael(int);
void test_enc_speed() {
  double falcon = 0, aes_128 = 0, aes_192 = 0, aes_256 = 0;
  double t;
  int i;
  for (i = 0; i < 2; i++) {
    printf("\nTrial #%d: encrypting %llu MB of data...\n", i + 1, (2000ull));
    t = test_rijndael(128);
    aes_128 += t;
    print_info(t, (2000ull) * 1e6 / 16, "AES-128", 10);
    t = test_rijndael(192);
    aes_192 += t;
    print_info(t, (2000ull) * 1e6 / 16, "AES-192", 12);
    t = test_rijndael(256);
    aes_256 += t;
    print_info(t, (2000ull) * 1e6 / 16, "AES-256", 14);
    t = test_falcon();
    print_info(t, (2000ull) * 1e6 / 32, "FALCON", 16);
    falcon += t;
  }
  aes_128 /= 2;
  aes_192 /= 2;
  aes_256 /= 2;
  falcon /= 2;
  printf("\n\n-----AVERAGE RESULTS-----\n");
  print_info(aes_128, (2000ull) * 1e6 / 16, "AES-128", 10);
  print_info(aes_192, (2000ull) * 1e6 / 16, "AES-192", 12);
  print_info(aes_256, (2000ull) * 1e6 / 16, "AES-256", 14);
  print_info(falcon, (2000ull) * 1e6 / 32, "FALCON", 16);
}


x86 assembly (clang, -O0):
<test_enc_speed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    1281 <test_enc_speed+0x141>
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
lea    0xe82(%rip),%rdi
mov    $0x7d0,%edx
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x80,%edi
call   1050 <test_rijndael@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xe72(%rip),%rsi
mov    $0xa,%edx
call   1060 <print_info@plt>
mov    $0xc0,%edi
call   1050 <test_rijndael@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xe41(%rip),%rsi
mov    $0xc,%edx
call   1060 <print_info@plt>
mov    $0x100,%edi
call   1050 <test_rijndael@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xe10(%rip),%rsi
mov    $0xe,%edx
call   1060 <print_info@plt>
mov    $0x0,%al
call   1040 <test_falcon@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    $0x3b9aca0,%edi
lea    0xdf1(%rip),%rsi
mov    $0x10,%edx
call   1060 <print_info@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116f <test_enc_speed+0x2f>
movsd  -0x10(%rbp),%xmm0
movsd  0xd72(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xd5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xd46(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xd30(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xd3b(%rip),%rsi
mov    $0xa,%edx
call   1060 <print_info@plt>
movsd  -0x18(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xd28(%rip),%rsi
mov    $0xc,%edx
call   1060 <print_info@plt>
movsd  -0x20(%rbp),%xmm0
mov    $0x7735940,%edi
lea    0xd15(%rip),%rsi
mov    $0xe,%edx
call   1060 <print_info@plt>
movsd  -0x8(%rbp),%xmm0
mov    $0x3b9aca0,%edi
lea    0xd02(%rip),%rsi
mov    $0x10,%edx
call   1060 <print_info@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_enc_speed>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xeac(%rip),%r13
mov    $0x7d0,%edx
mov    %r13,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x80,%edi
call   1060 <test_rijndael@plt>
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
lea    0xea0(%rip),%r14
mov    $0x7735940,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1070 <print_info@plt>
mov    $0xc0,%edi
call   1060 <test_rijndael@plt>
movapd %xmm0,%xmm1
addsd  0xe45(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
lea    0xe73(%rip),%r15
mov    $0x7735940,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1070 <print_info@plt>
mov    $0x100,%edi
call   1060 <test_rijndael@plt>
movapd %xmm0,%xmm1
addsd  0xe10(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
lea    0xe46(%rip),%r12
mov    $0x7735940,%edi
mov    %r12,%rsi
mov    $0xe,%edx
call   1070 <print_info@plt>
xor    %eax,%eax
call   1050 <test_falcon@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe28(%rip),%rbx
mov    $0x3b9aca0,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1070 <print_info@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xdbd(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x7d0,%edx
mov    %r13,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x80,%edi
call   1060 <test_rijndael@plt>
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    $0x7735940,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1070 <print_info@plt>
mov    $0xc0,%edi
call   1060 <test_rijndael@plt>
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    $0x7735940,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1070 <print_info@plt>
mov    $0x100,%edi
call   1060 <test_rijndael@plt>
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    $0x7735940,%edi
mov    %r12,%rsi
mov    $0xe,%edx
call   1070 <print_info@plt>
xor    %eax,%eax
call   1050 <test_falcon@plt>
movsd  %xmm0,0x28(%rsp)
mov    $0x3b9aca0,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1070 <print_info@plt>
movsd  0x8(%rsp),%xmm2
addsd  0x28(%rsp),%xmm2
movsd  0xce4(%rip),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
lea    0xcfd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7735940,%edi
movsd  0x20(%rsp),%xmm0
mov    %r14,%rsi
mov    $0xa,%edx
call   1070 <print_info@plt>
mov    $0x7735940,%edi
movsd  0x18(%rsp),%xmm0
mov    %r15,%rsi
mov    $0xc,%edx
call   1070 <print_info@plt>
mov    $0x7735940,%edi
movsd  0x10(%rsp),%xmm0
mov    %r12,%rsi
mov    $0xe,%edx
call   1070 <print_info@plt>
mov    $0x3b9aca0,%edi
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rsi
mov    $0x10,%edx
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <print_info@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"\0ATrial #%d: encrypting %llu MB of data...\0A\00"
@.str.1 = [8 x i8] c"AES-128\00"
@.str.2 = [8 x i8] c"AES-192\00"
@.str.3 = [8 x i8] c"AES-256\00"
@.str.4 = [7 x i8] c"FALCON\00"
@.str.5 = [29 x i8] c"\0A\0A-----AVERAGE RESULTS-----\0A\00"
define void @test_enc_speed() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double 0.000000e+00, double* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %6
br label %7
7: ; preds = %38, %0
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %41
10: ; preds = %7
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %12, i64 2000)
%14 = call double @test_rijndael(i32 128)
store double %14, double* %5
%15 = load double, double* %5
%16 = load double, double* %2
%17 = fadd double %16, %15
store double %17, double* %2
%18 = load double, double* %5
%19 = call i32 @print_info(double %18, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 10)
%20 = call double @test_rijndael(i32 192)
store double %20, double* %5
%21 = load double, double* %5
%22 = load double, double* %3
%23 = fadd double %22, %21
store double %23, double* %3
%24 = load double, double* %5
%25 = call i32 @print_info(double %24, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 12)
%26 = call double @test_rijndael(i32 256)
store double %26, double* %5
%27 = load double, double* %5
%28 = load double, double* %4
%29 = fadd double %28, %27
store double %29, double* %4
%30 = load double, double* %5
%31 = call i32 @print_info(double %30, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 14)
%32 = call double (...) @test_falcon()
store double %32, double* %5
%33 = load double, double* %5
%34 = call i32 @print_info(double %33, i64 62500000, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 16)
%35 = load double, double* %5
%36 = load double, double* %1
%37 = fadd double %36, %35
store double %37, double* %1
br label %38
38: ; preds = %10
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %7
41: ; preds = %7
%42 = load double, double* %2
%43 = fdiv double %42, 2.000000e+00
store double %43, double* %2
%44 = load double, double* %3
%45 = fdiv double %44, 2.000000e+00
store double %45, double* %3
%46 = load double, double* %4
%47 = fdiv double %46, 2.000000e+00
store double %47, double* %4
%48 = load double, double* %1
%49 = fdiv double %48, 2.000000e+00
store double %49, double* %1
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%51 = load double, double* %2
%52 = call i32 @print_info(double %51, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 10)
%53 = load double, double* %3
%54 = call i32 @print_info(double %53, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 12)
%55 = load double, double* %4
%56 = call i32 @print_info(double %55, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 14)
%57 = load double, double* %1
%58 = call i32 @print_info(double %57, i64 62500000, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 16)
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"\0ATrial #%d: encrypting %llu MB of data...\0A\00"
@.str.1 = [8 x i8] c"AES-128\00"
@.str.2 = [8 x i8] c"AES-192\00"
@.str.3 = [8 x i8] c"AES-256\00"
@.str.4 = [7 x i8] c"FALCON\00"
@str = [28 x i8] c"\0A\0A-----AVERAGE RESULTS-----\00"
define void @test_enc_speed() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 1, i64 2000)
%2 = tail call double @test_rijndael(i32 128)
%3 = fadd double %2, 0.000000e+00
%4 = tail call i32 @print_info(double %2, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 10)
%5 = tail call double @test_rijndael(i32 192)
%6 = fadd double %5, 0.000000e+00
%7 = tail call i32 @print_info(double %5, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 12)
%8 = tail call double @test_rijndael(i32 256)
%9 = fadd double %8, 0.000000e+00
%10 = tail call i32 @print_info(double %8, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 14)
%11 = tail call double (...) @test_falcon()
%12 = tail call i32 @print_info(double %11, i64 62500000, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 16)
%13 = fadd double %11, 0.000000e+00
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 2, i64 2000)
%15 = tail call double @test_rijndael(i32 128)
%16 = fadd double %3, %15
%17 = tail call i32 @print_info(double %15, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 10)
%18 = tail call double @test_rijndael(i32 192)
%19 = fadd double %6, %18
%20 = tail call i32 @print_info(double %18, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 12)
%21 = tail call double @test_rijndael(i32 256)
%22 = fadd double %9, %21
%23 = tail call i32 @print_info(double %21, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 14)
%24 = tail call double (...) @test_falcon()
%25 = tail call i32 @print_info(double %24, i64 62500000, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 16)
%26 = fadd double %13, %24
%27 = fmul double %16, 5.000000e-01
%28 = fmul double %19, 5.000000e-01
%29 = fmul double %22, 5.000000e-01
%30 = fmul double %26, 5.000000e-01
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%32 = tail call i32 @print_info(double %27, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 10)
%33 = tail call i32 @print_info(double %28, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 12)
%34 = tail call i32 @print_info(double %29, i64 125000000, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 14)
%35 = tail call i32 @print_info(double %30, i64 62500000, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 16)
ret void
}