#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 */
float f(float);
int /*<<< orphan*/ printf(char *, int, float);
void trap_iterativo(int i) {
  float h, aux, f_aux;
  h = (1.2 - 0) / i;
  f_aux = 0;
  aux = 0;
  for (int j = 0; j <= i; j++) {
    if (j != 0 && j != i) {
      f_aux += 2 * f(aux);
    } else {
      f_aux += f(aux);
    }
    aux += h;
  }
  f_aux *= (h / 2);
  printf("%d\t\t%.7f\n", i, f_aux);
}


x86 assembly (clang, -O0):
<trap_iterativo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xec8(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11d0 <trap_iterativo+0xb0>
cmpl   $0x0,-0x14(%rbp)
je     119f <trap_iterativo+0x7f>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     119f <trap_iterativo+0x7f>
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
movss  -0x10(%rbp),%xmm1
addss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11b3 <trap_iterativo+0x93>
movss  -0xc(%rbp),%xmm0
call   1030 <f@plt>
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <trap_iterativo+0x3c>
movss  -0x8(%rbp),%xmm0
movss  0xe2b(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%esi
movss  -0x10(%rbp),%xmm0
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trap_iterativo>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
cvtsi2sd %edi,%xmm0
movsd  0xec9(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%rsp)
test   %edi,%edi
js     11b4 <trap_iterativo+0x94>
lea    0x1(%r14),%ebp
xorps  %xmm1,%xmm1
xor    %ebx,%ebx
xorps  %xmm0,%xmm0
movaps %xmm1,%xmm2
jmp    1175 <trap_iterativo+0x55>
nopl   0x0(%rax)
movss  0x8(%rsp),%xmm0
addss  (%rsp),%xmm0
add    $0x1,%ebx
movaps %xmm2,%xmm1
cmp    %ebx,%ebp
je     11b7 <trap_iterativo+0x97>
movss  %xmm1,0x4(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
call   1030 <f@plt>
movss  0xc(%rsp),%xmm2
addss  %xmm0,%xmm2
movaps %xmm2,%xmm1
cmp    %ebx,%r14d
je     11ab <trap_iterativo+0x8b>
addss  %xmm0,%xmm0
addss  0x4(%rsp),%xmm0
movaps %xmm0,%xmm1
test   %ebx,%ebx
je     1160 <trap_iterativo+0x40>
movaps %xmm1,%xmm2
jmp    1160 <trap_iterativo+0x40>
xorps  %xmm2,%xmm2
movss  (%rsp),%xmm0
mulss  0xe44(%rip),%xmm0
mulss  %xmm2,%xmm0
lea    0xe3d(%rip),%rdi
mov    %r14d,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%d\09\09%.7f\0A\00"
define void @trap_iterativo(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sitofp i32 %7 to double
%9 = fdiv double 1.200000e+00, %8
%10 = fptrunc double %9 to float
store float %10, float* %3
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %4
store i32 0, i32* %6
br label %11
11: ; preds = %36, %1
%12 = load i32, i32* %6
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %39
15: ; preds = %11
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %6
%20 = load i32, i32* %2
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %18
%23 = load float, float* %4
%24 = call float @f(float %23)
%25 = load float, float* %5
%26 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %24, float %25)
store float %26, float* %5
br label %32
27: ; preds = %18, %15
%28 = load float, float* %4
%29 = call float @f(float %28)
%30 = load float, float* %5
%31 = fadd float %30, %29
store float %31, float* %5
br label %32
32: ; preds = %27, %22
%33 = load float, float* %3
%34 = load float, float* %4
%35 = fadd float %34, %33
store float %35, float* %4
br label %36
36: ; preds = %32
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %11
39: ; preds = %11
%40 = load float, float* %3
%41 = fdiv float %40, 2.000000e+00
%42 = load float, float* %5
%43 = fmul float %42, %41
store float %43, float* %5
%44 = load i32, i32* %2
%45 = load float, float* %5
%46 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %44, float %45)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d\09\09%.7f\0A\00"
define void @trap_iterativo(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fdiv double 1.200000e+00, %2
%4 = fptrunc double %3 to float
%5 = icmp slt i32 %0, 0
br i1 %5, label %6, label %11
6: ; preds = %11, %1
%7 = phi float [ 0.000000e+00, %1 ], [ %21, %11 ]
%8 = fmul float %4, 5.000000e-01
%9 = fmul float %8, %7
%10 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %0, float %9)
ret void
11: ; preds = %1, %11
%12 = phi i32 [ %23, %11 ], [ 0, %1 ]
%13 = phi float [ %21, %11 ], [ 0.000000e+00, %1 ]
%14 = phi float [ %22, %11 ], [ 0.000000e+00, %1 ]
%15 = icmp eq i32 %12, 0
%16 = icmp eq i32 %12, %0
%17 = or i1 %15, %16
%18 = tail call float @f(float %14)
%19 = tail call float @llvm.fmuladd.f32(float %18, float 2.000000e+00, float %13)
%20 = fadd float %13, %18
%21 = select i1 %17, float %20, float %19
%22 = fadd float %14, %4
%23 = add nuw i32 %12, 1
%24 = icmp eq i32 %12, %0
br i1 %24, label %6, label %11
}