#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 int32_t;

/* Variables and functions */
double inverseGaussian(double, double, double);
double logCauchy(double, double, double);
double pareto(double, double, double);
int32_t integrate() {
  double start = 1.0;
  double end = 1000.0;
  double p0 = 0.0;
  for (double x = start; x < end; x += (0.0002)) {
    p0 += (0.0002) * inverseGaussian(x, 4.5, 2.1);
  }
  double p1 = 0.0;
  for (double x = start; x < end; x += (0.0002)) {
    p1 += (0.0002) * logCauchy(x, 2.1, 1.6);
  }
  double p2 = 0.0;
  for (double x = start; x < end; x += (0.0002)) {
    p2 += (0.0002) * pareto(x, 1.0, 0.5);
  }
  double checksum = p0 + p1 + p2;
  return (int)(checksum * 100);
}


x86 assembly (clang, -O0):
<integrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c3 <integrate+0x93>
movsd  -0x20(%rbp),%xmm0
movsd  0xeb3(%rip),%xmm1
movsd  0xe9b(%rip),%xmm2
call   1030 <inverseGaussian@plt>
movsd  -0x18(%rbp),%xmm1
movsd  0xe79(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe64(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1164 <integrate+0x34>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1234 <integrate+0x104>
movsd  -0x30(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
movsd  0xe32(%rip),%xmm2
call   1050 <logCauchy@plt>
movsd  -0x28(%rbp),%xmm1
movsd  0xe08(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdf3(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11d5 <integrate+0xa5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a5 <integrate+0x175>
movsd  -0x40(%rbp),%xmm0
movsd  0xda1(%rip),%xmm1
movsd  0xdb1(%rip),%xmm2
call   1040 <pareto@plt>
movsd  -0x38(%rbp),%xmm1
movsd  0xd97(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xd82(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1246 <integrate+0x116>
movsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd4f(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integrate>:
sub    $0x28,%rsp
movsd  0xec4(%rip),%xmm0
xorps  %xmm3,%xmm3
nop
movsd  %xmm0,0x8(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  0xeb4(%rip),%xmm1
movsd  0xeb4(%rip),%xmm2
call   1030 <inverseGaussian@plt>
movsd  0xeaf(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe9b(%rip),%xmm1
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
ucomisd 0x8(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
ja     1140 <integrate+0x10>
xorpd  %xmm2,%xmm2
movsd  0xe4b(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xe36(%rip),%xmm1
movsd  0xe46(%rip),%xmm2
call   1050 <logCauchy@plt>
movsd  0x18(%rsp),%xmm2
movsd  0xe23(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe0b(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0x8(%rsp),%xmm0
ja     11c0 <integrate+0x90>
movsd  %xmm2,0x18(%rsp)
xorpd  %xmm2,%xmm2
movsd  0xdcb(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x8(%rsp)
movsd  %xmm2,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xda6(%rip),%xmm1
movsd  0xdce(%rip),%xmm2
call   1040 <pareto@plt>
movsd  0x20(%rsp),%xmm2
movsd  0xda3(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xd8b(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  0x8(%rsp),%xmm0
ja     1240 <integrate+0x110>
movsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
addsd  %xmm2,%xmm0
mulsd  0xd7d(%rip),%xmm0
cvttsd2si %xmm0,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @integrate() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double 1.000000e+00, double* %1
store double 1.000000e+03, double* %2
store double 0.000000e+00, double* %3
%10 = load double, double* %1
store double %10, double* %4
br label %11
11: ; preds = %20, %0
%12 = load double, double* %4
%13 = load double, double* %2
%14 = fcmp olt double %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load double, double* %4
%17 = call double @inverseGaussian(double %16, double 4.500000e+00, double 2.100000e+00)
%18 = load double, double* %3
%19 = call double @llvm.fmuladd.f64(double 2.000000e-04, double %17, double %18)
store double %19, double* %3
br label %20
20: ; preds = %15
%21 = load double, double* %4
%22 = fadd double %21, 2.000000e-04
store double %22, double* %4
br label %11
23: ; preds = %11
store double 0.000000e+00, double* %5
%24 = load double, double* %1
store double %24, double* %6
br label %25
25: ; preds = %34, %23
%26 = load double, double* %6
%27 = load double, double* %2
%28 = fcmp olt double %26, %27
br i1 %28, label %29, label %37
29: ; preds = %25
%30 = load double, double* %6
%31 = call double @logCauchy(double %30, double 2.100000e+00, double 1.600000e+00)
%32 = load double, double* %5
%33 = call double @llvm.fmuladd.f64(double 2.000000e-04, double %31, double %32)
store double %33, double* %5
br label %34
34: ; preds = %29
%35 = load double, double* %6
%36 = fadd double %35, 2.000000e-04
store double %36, double* %6
br label %25
37: ; preds = %25
store double 0.000000e+00, double* %7
%38 = load double, double* %1
store double %38, double* %8
br label %39
39: ; preds = %48, %37
%40 = load double, double* %8
%41 = load double, double* %2
%42 = fcmp olt double %40, %41
br i1 %42, label %43, label %51
43: ; preds = %39
%44 = load double, double* %8
%45 = call double @pareto(double %44, double 1.000000e+00, double 5.000000e-01)
%46 = load double, double* %7
%47 = call double @llvm.fmuladd.f64(double 2.000000e-04, double %45, double %46)
store double %47, double* %7
br label %48
48: ; preds = %43
%49 = load double, double* %8
%50 = fadd double %49, 2.000000e-04
store double %50, double* %8
br label %39
51: ; preds = %39
%52 = load double, double* %3
%53 = load double, double* %5
%54 = fadd double %52, %53
%55 = load double, double* %7
%56 = fadd double %54, %55
store double %56, double* %9
%57 = load double, double* %9
%58 = fmul double %57, 1.000000e+02
%59 = fptosi double %58 to i32
ret i32 %59
}

LLVM IR (-O2):
define i32 @integrate() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 0.000000e+00, %0 ], [ %5, %1 ]
%3 = phi double [ 1.000000e+00, %0 ], [ %6, %1 ]
%4 = tail call double @inverseGaussian(double %3, double 4.500000e+00, double 2.100000e+00)
%5 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e-04, double %2)
%6 = fadd double %3, 2.000000e-04
%7 = fcmp olt double %6, 1.000000e+03
br i1 %7, label %1, label %8
8: ; preds = %1, %8
%9 = phi double [ %13, %8 ], [ 1.000000e+00, %1 ]
%10 = phi double [ %12, %8 ], [ 0.000000e+00, %1 ]
%11 = tail call double @logCauchy(double %9, double 2.100000e+00, double 1.600000e+00)
%12 = tail call double @llvm.fmuladd.f64(double %11, double 2.000000e-04, double %10)
%13 = fadd double %9, 2.000000e-04
%14 = fcmp olt double %13, 1.000000e+03
br i1 %14, label %8, label %20
15: ; preds = %20
%16 = fadd double %5, %12
%17 = fadd double %16, %24
%18 = fmul double %17, 1.000000e+02
%19 = fptosi double %18 to i32
ret i32 %19
20: ; preds = %8, %20
%21 = phi double [ %25, %20 ], [ 1.000000e+00, %8 ]
%22 = phi double [ %24, %20 ], [ 0.000000e+00, %8 ]
%23 = tail call double @pareto(double %21, double 1.000000e+00, double 5.000000e-01)
%24 = tail call double @llvm.fmuladd.f64(double %23, double 2.000000e-04, double %22)
%25 = fadd double %21, 2.000000e-04
%26 = fcmp olt double %25, 1.000000e+03
br i1 %26, label %20, label %15
}