#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*/ printf(char *, ...);
int /*<<< orphan*/ run_dual_test(int, char *, double);
void run_perf_tests(void) {
  struct {
    unsigned int iter;
    char *fmt;
    double val;
  } tab[] = {{(1000000), "%f", 1.0},
             {(1000000), "%20f", 4.0 / 3.0},
             {(1000000), "%.20f", 4.0 / 3.0},
             {0, NULL, 0.0}};
  int i;
  static unsigned int id = 1;
  for (i = 0; tab[i].fmt; i++) {
    printf("\n>> Test %u: %u iterations of \"", id++, tab[i].iter);
    printf(tab[i].fmt, tab[i].val);
    printf("\"\n");
    run_dual_test(tab[i].iter, tab[i].fmt, tab[i].val);
  }
}


x86 assembly (clang, -O0):
<run_perf_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x60(%rbp),%rdi
lea    0x2c7d(%rip),%rsi
mov    $0x60,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpq   $0x0,0x8(%rax)
je     1225 <run_perf_tests+0xf5>
mov    0x2ec4(%rip),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,0x2eb9(%rip)
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdi
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%edi
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
call   1050 <run_dual_test@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1154 <run_perf_tests+0x24>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_perf_tests>:
push   %r15
push   %r14
push   %rbx
mov    0x2efd(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2ef4(%rip)
lea    0xed3(%rip),%r14
mov    %r14,%rdi
mov    $0xf4240,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rbx
movsd  0xe97(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
mov    %rbx,%rsi
movsd  0xe6e(%rip),%xmm0
call   1050 <run_dual_test@plt>
mov    0x2e9b(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e92(%rip)
mov    %r14,%rdi
mov    $0xf4240,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe57(%rip),%rbx
movsd  0xe44(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
mov    %rbx,%rsi
movsd  0xe22(%rip),%xmm0
call   1050 <run_dual_test@plt>
mov    0x2e47(%rip),%esi
lea    0x1(%rsi),%eax
mov    %eax,0x2e3e(%rip)
mov    %r14,%rdi
mov    $0xf4240,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe08(%rip),%rbx
mov    %rbx,%rdi
movsd  0xded(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0xf4240,%edi
mov    %rbx,%rsi
movsd  0xdce(%rip),%xmm0
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <run_dual_test@plt>

LLVM IR (-O0):
%struct.anon = type { i32, i8*, double }
@.str = [3 x i8] c"%f\00"
@.str.1 = [5 x i8] c"%20f\00"
@.str.2 = [6 x i8] c"%.20f\00"
@__const.run_perf_tests.tab = [4 x %struct.anon] [%struct.anon { i32 1000000, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), double 1.000000e+00 }, %struct.anon { i32 1000000, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), double 0x3FF5555555555555 }, %struct.anon { i32 1000000, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), double 0x3FF5555555555555 }, %struct.anon zeroinitializer]
@run_perf_tests.id = internal global i32 1
@.str.3 = [32 x i8] c"\0A>> Test %u: %u iterations of \22\00"
@.str.4 = [3 x i8] c"\22\0A\00"
define void @run_perf_tests() {
%1 = alloca [4 x %struct.anon]
%2 = alloca i32
%3 = bitcast [4 x %struct.anon]* %1 to i8*
store i32 0, i32* %2
br label %4
4: ; preds = %48, %0
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %6
%8 = getelementptr inbounds %struct.anon, %struct.anon* %7, i32 0, i32 1
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %51
11: ; preds = %4
%12 = load i32, i32* @run_perf_tests.id
%13 = add i32 %12, 1
store i32 %13, i32* @run_perf_tests.id
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %15
%17 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %18)
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %21
%23 = getelementptr inbounds %struct.anon, %struct.anon* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %26
%28 = getelementptr inbounds %struct.anon, %struct.anon* %27, i32 0, i32 2
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* %24, double %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %33
%35 = getelementptr inbounds %struct.anon, %struct.anon* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %38
%40 = getelementptr inbounds %struct.anon, %struct.anon* %39, i32 0, i32 1
%41 = load i8*, i8** %40
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [4 x %struct.anon], [4 x %struct.anon]* %1, i64 0, i64 %43
%45 = getelementptr inbounds %struct.anon, %struct.anon* %44, i32 0, i32 2
%46 = load double, double* %45
%47 = call i32 @run_dual_test(i32 %36, i8* %41, double %46)
br label %48
48: ; preds = %11
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
br label %4
51: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [5 x i8] c"%20f\00"
@.str.2 = [6 x i8] c"%.20f\00"
@run_perf_tests.id = internal unnamed_addr global i32 1
@.str.3 = [32 x i8] c"\0A>> Test %u: %u iterations of \22\00"
@str = [2 x i8] c"\22\00"
define void @run_perf_tests() {
%1 = load i32, i32* @run_perf_tests.id
%2 = add i32 %1, 1
store i32 %2, i32* @run_perf_tests.id
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %1, i32 1000000)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @run_dual_test(i32 1000000, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%7 = load i32, i32* @run_perf_tests.id
%8 = add i32 %7, 1
store i32 %8, i32* @run_perf_tests.id
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 1000000)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 0x3FF5555555555555)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @run_dual_test(i32 1000000, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 0x3FF5555555555555)
%13 = load i32, i32* @run_perf_tests.id
%14 = add i32 %13, 1
store i32 %14, i32* @run_perf_tests.id
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 1000000)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 0x3FF5555555555555)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @run_dual_test(i32 1000000, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 0x3FF5555555555555)
ret void
}