#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 */
scalar_t__ computeArea(double, double, double);
double iterateInterval(double initialPoint, double finalPoint,
                       int trapezeNumber) {
  double result = 0;
  double interval = (finalPoint - initialPoint) / trapezeNumber;
  double partialPoint = initialPoint + interval;
  for (double i = initialPoint; i < finalPoint; i += interval) {
    result += computeArea(interval, i, partialPoint);
    partialPoint += interval;
  }
  return result;
}


x86 assembly (clang, -O0):
<iterateInterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b8 <iterateInterval+0xa8>
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1030 <computeArea@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    115e <iterateInterval+0x4e>
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterateInterval>:
sub    $0x28,%rsp
xorpd  %xmm3,%xmm3
movsd  %xmm1,(%rsp)
ucomisd %xmm0,%xmm1
jbe    11a4 <iterateInterval+0x94>
movapd %xmm0,%xmm4
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  %xmm3,%xmm3
movapd %xmm4,%xmm2
nopl   (%rax)
movsd  %xmm3,0x18(%rsp)
movsd  %xmm4,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm4,%xmm1
call   1030 <computeArea@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm3
addsd  0x8(%rsp),%xmm4
movsd  (%rsp),%xmm0
ucomisd %xmm4,%xmm0
ja     1150 <iterateInterval+0x40>
movapd %xmm3,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @iterateInterval(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %7
%11 = load double, double* %5
%12 = load double, double* %4
%13 = fsub double %11, %12
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to double
%16 = fdiv double %13, %15
store double %16, double* %8
%17 = load double, double* %4
%18 = load double, double* %8
%19 = fadd double %17, %18
store double %19, double* %9
%20 = load double, double* %4
store double %20, double* %10
br label %21
21: ; preds = %36, %3
%22 = load double, double* %10
%23 = load double, double* %5
%24 = fcmp olt double %22, %23
br i1 %24, label %25, label %40
25: ; preds = %21
%26 = load double, double* %8
%27 = load double, double* %10
%28 = load double, double* %9
%29 = call i64 @computeArea(double %26, double %27, double %28)
%30 = sitofp i64 %29 to double
%31 = load double, double* %7
%32 = fadd double %31, %30
store double %32, double* %7
%33 = load double, double* %8
%34 = load double, double* %9
%35 = fadd double %34, %33
store double %35, double* %9
br label %36
36: ; preds = %25
%37 = load double, double* %8
%38 = load double, double* %10
%39 = fadd double %38, %37
store double %39, double* %10
br label %21
40: ; preds = %21
%41 = load double, double* %7
ret double %41
}

LLVM IR (-O2):
define double @iterateInterval(double %0, double %1, i32 %2) {
%4 = fsub double %1, %0
%5 = sitofp i32 %2 to double
%6 = fdiv double %4, %5
%7 = fcmp olt double %0, %1
br i1 %7, label %10, label %8
8: ; preds = %10, %3
%9 = phi double [ 0.000000e+00, %3 ], [ %17, %10 ]
ret double %9
10: ; preds = %3, %10
%11 = phi double [ %18, %10 ], [ %0, %3 ]
%12 = phi double [ %14, %10 ], [ %0, %3 ]
%13 = phi double [ %17, %10 ], [ 0.000000e+00, %3 ]
%14 = fadd double %6, %12
%15 = tail call i64 @computeArea(double %6, double %11, double %14)
%16 = sitofp i64 %15 to double
%17 = fadd double %13, %16
%18 = fadd double %6, %11
%19 = fcmp olt double %18, %1
br i1 %19, label %10, label %8
}