#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 double b;
typedef double a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
int main() {
  int n = 100;
  double a = -5, b = 5;
  double h = (b - a) / n;
  double I = 0;
  int i;
  I = I + 0.5 * (((a)-5) * ((a)-5)) - (0);
  for (i = 1; i < n - 1; i++) {
    I = I + (((a + i * h) - 5) * ((a + i * h) - 5)) - (0);
  }
  I = I + 0.5 * (((b)-5) * ((b)-5)) - (0);
  I = I * h;
  printf("Area is: %lf \n", I);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movsd  0xee2(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xecd(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe96(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xe85(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe6d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    122c <main+0x11c>
movsd  -0x28(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe25(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  -0x10(%rbp),%xmm3
cvtsi2sdl -0x2c(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movsd  0xe02(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ae <main+0x9e>
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xdca(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xdb9(%rip),%xmm3
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
movsd  0xda1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xd8a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xee7(%rip),%xmm0
movsd  0xee7(%rip),%xmm1
mov    $0x2,%eax
movsd  0xee2(%rip),%xmm2
movsd  0xee2(%rip),%xmm3
movsd  0xee2(%rip),%xmm4
xchg   %ax,%ax
movapd %xmm1,%xmm5
mulsd  %xmm2,%xmm5
addsd  %xmm3,%xmm5
addsd  %xmm3,%xmm5
mulsd  %xmm5,%xmm5
addsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm5,%xmm0
addsd  %xmm4,%xmm1
add    $0x2,%eax
cmp    $0x64,%eax
jne    1140 <main+0x30>
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
mulsd  0xe81(%rip),%xmm0
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"Area is: %lf \0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 1, %0 ], [ %13, %1 ]
%3 = phi double [ 5.000000e+01, %0 ], [ %12, %1 ]
%4 = sitofp i32 %2 to double
%5 = tail call double @llvm.fmuladd.f64(double %4, double 1.000000e-01, double -5.000000e+00)
%6 = fadd double %5, -5.000000e+00
%7 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %3)
%8 = add nuw nsw i32 %2, 1
%9 = sitofp i32 %8 to double
%10 = tail call double @llvm.fmuladd.f64(double %9, double 1.000000e-01, double -5.000000e+00)
%11 = fadd double %10, -5.000000e+00
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %7)
%13 = add nuw nsw i32 %2, 2
%14 = icmp eq i32 %13, 99
br i1 %14, label %15, label %1
15: ; preds = %1
%16 = fadd double %12, 0.000000e+00
%17 = fmul double %16, 1.000000e-01
%18 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %17)
ret i32 0
}