#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 fun(int, double);
int /*<<< orphan*/ printf(char *, int, double, double, double);
int main() {
  int i;
  double h = 0.1;
  double f[6];
  double y[6];
  y[0] = 1;
  f[0] = fun(0, y[0]);
  for (i = 1; i < 6; ++i) {
    y[i] = y[i - 1] + h * f[i - 1];
    f[i] = fun(i * h, y[i]);
  }
  for (i = 0; i < 6; ++i) {
    printf("i=%d x=%f y=%f f(x,y)=%f\n", i, h * i, y[i], f[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    11d3 <main+0xb3>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x70(%rbp,%rax,8),%xmm1
movsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x40(%rbp,%rax,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x70(%rbp,%rax,8)
cvtsi2sdl -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
movslq -0x8(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm0
call   1030 <fun@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1161 <main+0x41>
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    1223 <main+0x103>
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movslq -0x8(%rbp),%rax
movsd  -0x70(%rbp,%rax,8),%xmm1
movslq -0x8(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm2
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11da <main+0xba>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movsd  0xed3(%rip),%xmm0
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x48(%rsp)
mulsd  0xec6(%rip),%xmm0
addsd  0xeb6(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x40(%rsp)
mulsd  0xea3(%rip),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x38(%rsp)
mulsd  0xe82(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x30(%rsp)
mulsd  0xe61(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x28(%rsp)
mulsd  0xe40(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
xor    %edi,%edi
call   1030 <fun@plt>
movsd  %xmm0,0x50(%rsp)
lea    0xe48(%rip),%rbx
xorpd  %xmm0,%xmm0
mov    %rbx,%rdi
xor    %esi,%esi
movsd  0xe07(%rip),%xmm1
movsd  0x48(%rsp),%xmm2
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
movsd  0xdf4(%rip),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
call   1040 <printf@plt>
movsd  0xde3(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x2,%esi
movsd  0x18(%rsp),%xmm1
movsd  0x38(%rsp),%xmm2
call   1040 <printf@plt>
movsd  0xdca(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x3,%esi
movsd  0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
call   1040 <printf@plt>
movsd  0xdb1(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x4,%esi
movsd  0x8(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
call   1040 <printf@plt>
movsd  0xd98(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x5,%esi
movsd  0x58(%rsp),%xmm1
movsd  0x50(%rsp),%xmm2
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"i=%d x=%f y=%f f(x,y)=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [6 x double]
%5 = alloca [6 x double]
store i32 0, i32* %1
store double 1.000000e-01, double* %3
%6 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 0
store double 1.000000e+00, double* %6
%7 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 0
%8 = load double, double* %7
%9 = call double @fun(i32 0, double %8)
%10 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 0
store double %9, double* %10
store i32 1, i32* %2
br label %11
11: ; preds = %43, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 6
br i1 %13, label %14, label %46
14: ; preds = %11
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 %17
%19 = load double, double* %18
%20 = load double, double* %3
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 %23
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %20, double %25, double %19)
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 %28
store double %26, double* %29
%30 = load i32, i32* %2
%31 = sitofp i32 %30 to double
%32 = load double, double* %3
%33 = fmul double %31, %32
%34 = fptosi double %33 to i32
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 %36
%38 = load double, double* %37
%39 = call double @fun(i32 %34, double %38)
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 %41
store double %39, double* %42
br label %43
43: ; preds = %14
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %11
46: ; preds = %11
store i32 0, i32* %2
br label %47
47: ; preds = %65, %46
%48 = load i32, i32* %2
%49 = icmp slt i32 %48, 6
br i1 %49, label %50, label %68
50: ; preds = %47
%51 = load i32, i32* %2
%52 = load double, double* %3
%53 = load i32, i32* %2
%54 = sitofp i32 %53 to double
%55 = fmul double %52, %54
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 %57
%59 = load double, double* %58
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [6 x double], [6 x double]* %4, i64 0, i64 %61
%63 = load double, double* %62
%64 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %51, double %55, double %59, double %63)
br label %65
65: ; preds = %50
%66 = load i32, i32* %2
%67 = add nsw i32 %66, 1
store i32 %67, i32* %2
br label %47
68: ; preds = %47
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@.str = [26 x i8] c"i=%d x=%f y=%f f(x,y)=%f\0A\00"
define i32 @main() {
%1 = tail call double @fun(i32 0, double 1.000000e+00)
%2 = tail call double @llvm.fmuladd.f64(double %1, double 1.000000e-01, double 1.000000e+00)
%3 = tail call double @fun(i32 0, double %2)
%4 = tail call double @llvm.fmuladd.f64(double %3, double 1.000000e-01, double %2)
%5 = tail call double @fun(i32 0, double %4)
%6 = tail call double @llvm.fmuladd.f64(double %5, double 1.000000e-01, double %4)
%7 = tail call double @fun(i32 0, double %6)
%8 = tail call double @llvm.fmuladd.f64(double %7, double 1.000000e-01, double %6)
%9 = tail call double @fun(i32 0, double %8)
%10 = tail call double @llvm.fmuladd.f64(double %9, double 1.000000e-01, double %8)
%11 = tail call double @fun(i32 0, double %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 0, double 0.000000e+00, double 1.000000e+00, double %1)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 1, double 1.000000e-01, double %2, double %3)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 2, double 2.000000e-01, double %4, double %5)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 3, double 0x3FD3333333333334, double %6, double %7)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 4, double 4.000000e-01, double %8, double %9)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 5, double 5.000000e-01, double %10, double %11)
ret i32 0
}