#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double);
double get_het_f(double, double, double, double, double, double);
int main(void) {
  int i;
  FILE *fp;
  int N = 500;
  double r;
  double eps = 1.0 / (2.0 * (double)N);
  double x1 = eps;
  double x2 = 0;
  double x3 = 0.5 - x1;
  double x4 = 0.5;
  double het_i;
  double het_f;
  het_i = 2.0 * (x1 + x3) * (1 - x1 - x3);
  fp = fopen("hitchhikingN500.dat", "w");
  for (i = 0; i < 100; i++) {
    r = (double)i / 2000;
    het_f = get_het_f(x1, x2, x3, x4, r, eps);
    fprintf(fp, "%f\t%f\n", r / (0.1), het_f / het_i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1f4,-0x14(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xea1(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8e(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe7c(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm1
addsd  -0x40(%rbp),%xmm1
movsd  0xe5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe49(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
subsd  -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1269 <main+0x139>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
call   1030 <get_het_f@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x58(%rbp),%xmm1
divsd  -0x50(%rbp),%xmm1
lea    0xde8(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e8 <main+0xb8>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xef1(%rip),%rdi
lea    0xefe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
xorpd  %xmm0,%xmm0
mov    $0x64,%ebp
lea    0xee8(%rip),%r14
xchg   %ax,%ax
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm4
divsd  0xe8e(%rip),%xmm4
movsd  %xmm4,(%rsp)
xorps  %xmm1,%xmm1
movsd  0xe96(%rip),%xmm0
movsd  0xe7e(%rip),%xmm2
movsd  0xe7e(%rip),%xmm3
movapd %xmm0,%xmm5
call   1030 <get_het_f@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
divsd  0xe74(%rip),%xmm0
addsd  %xmm1,%xmm1
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe5f(%rip),%xmm0
add    $0xffffffff,%ebp
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"hitchhikingN500.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%f\09%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 0, i32* %1
store i32 500, i32* %4
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to double
%15 = fmul double 2.000000e+00, %14
%16 = fdiv double 1.000000e+00, %15
store double %16, double* %6
%17 = load double, double* %6
store double %17, double* %7
store double 0.000000e+00, double* %8
%18 = load double, double* %7
%19 = fsub double 5.000000e-01, %18
store double %19, double* %9
store double 5.000000e-01, double* %10
%20 = load double, double* %7
%21 = load double, double* %9
%22 = fadd double %20, %21
%23 = fmul double 2.000000e+00, %22
%24 = load double, double* %7
%25 = fsub double 1.000000e+00, %24
%26 = load double, double* %9
%27 = fsub double %25, %26
%28 = fmul double %23, %27
store double %28, double* %11
%29 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %3
store i32 0, i32* %2
br label %30
30: ; preds = %51, %0
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 100
br i1 %32, label %33, label %54
33: ; preds = %30
%34 = load i32, i32* %2
%35 = sitofp i32 %34 to double
%36 = fdiv double %35, 2.000000e+03
store double %36, double* %5
%37 = load double, double* %7
%38 = load double, double* %8
%39 = load double, double* %9
%40 = load double, double* %10
%41 = load double, double* %5
%42 = load double, double* %6
%43 = call double @get_het_f(double %37, double %38, double %39, double %40, double %41, double %42)
store double %43, double* %12
%44 = load i32*, i32** %3
%45 = load double, double* %5
%46 = fdiv double %45, 1.000000e-01
%47 = load double, double* %12
%48 = load double, double* %11
%49 = fdiv double %47, %48
%50 = call i32 @fprintf(i32* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %46, double %49)
br label %51
51: ; preds = %33
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
store i32 %53, i32* %2
br label %30
54: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"hitchhikingN500.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%f\09%f\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %10, %2 ]
%4 = sitofp i32 %3 to double
%5 = fdiv double %4, 2.000000e+03
%6 = tail call double @get_het_f(double 1.000000e-03, double 0.000000e+00, double 4.990000e-01, double 5.000000e-01, double %5, double 1.000000e-03)
%7 = fdiv double %5, 1.000000e-01
%8 = fmul double %6, 2.000000e+00
%9 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %7, double %8)
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %2
12: ; preds = %2
ret i32 0
}