#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 */
double erf(double);
int /*<<< orphan*/ printf(char *, double, double);
int main() {
  double x = 0;
  double y = erf(0);
  double dx = 0.0001;
  for (int i = 0; i < 50000; i++, x += dx) {
    y += erf(x) * dx;
    printf("%lf %lf\n", x, erf(x));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
call   1040 <erf@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xc350,-0x24(%rbp)
jge    11cb <main+0xab>
movsd  -0x10(%rbp),%xmm0
call   1040 <erf@plt>
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <erf@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1158 <main+0x38>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
call   1040 <erf@plt>
mov    $0xc350,%ebp
lea    0xec7(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
call   1040 <erf@plt>
movsd  (%rsp),%xmm0
call   1040 <erf@plt>
movaps %xmm0,%xmm1
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xe7f(%rip),%xmm0
movsd  %xmm0,(%rsp)
add    $0xffffffff,%ebp
jne    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%lf %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store i32 0, i32* %1
store double 0.000000e+00, double* %2
%6 = call double @erf(double 0.000000e+00)
store double %6, double* %3
store double 1.000000e-04, double* %4
store i32 0, i32* %5
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 50000
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load double, double* %2
%12 = call double @erf(double %11)
%13 = load double, double* %4
%14 = load double, double* %3
%15 = call double @llvm.fmuladd.f64(double %12, double %13, double %14)
store double %15, double* %3
%16 = load double, double* %2
%17 = load double, double* %2
%18 = call double @erf(double %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %16, double %18)
br label %20
20: ; preds = %10
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
%23 = load double, double* %4
%24 = load double, double* %2
%25 = fadd double %24, %23
store double %25, double* %2
br label %7
26: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"%lf %lf\0A\00"
define i32 @main() {
%1 = tail call double @erf(double 0.000000e+00)
br label %3
2: ; preds = %3
ret i32 0
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %9, %3 ]
%5 = phi double [ 0.000000e+00, %0 ], [ %10, %3 ]
%6 = tail call double @erf(double %5)
%7 = tail call double @erf(double %5)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %5, double %7)
%9 = add nuw nsw i32 %4, 1
%10 = fadd double %5, 1.000000e-04
%11 = icmp eq i32 %9, 50000
br i1 %11, label %2, label %3
}