#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 atof(char *);
int atoi(char *);
int /*<<< orphan*/ printf(char *, float, float, float);
float trap(float, float, int, float);
int main(int argc, char **argv) {
  float left = atof(argv[1]);
  float right = atof(argv[2]);
  int N = atoi(argv[3]);
  float h = (right - left) / N;
  float sum = trap(left, right, N, h);
  printf("The integral from %f to %f = %f\n", left, right, sum);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
mov    -0x1c(%rbp),%edi
movss  -0x20(%rbp),%xmm2
call   1050 <trap@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movss  %xmm0,0xc(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
movss  0x8(%rsp),%xmm1
movaps %xmm1,%xmm2
movss  0xc(%rsp),%xmm0
subss  %xmm0,%xmm2
cvtsi2ss %eax,%xmm3
divss  %xmm3,%xmm2
mov    %eax,%edi
call   1050 <trap@plt>
movaps %xmm0,%xmm2
lea    0xe65(%rip),%rdi
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"The integral from %f to %f = %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca float
%10 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call float @atof(i8* %13)
store float %14, float* %6
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call float @atof(i8* %17)
store float %18, float* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %8
%23 = load float, float* %7
%24 = load float, float* %6
%25 = fsub float %23, %24
%26 = load i32, i32* %8
%27 = sitofp i32 %26 to float
%28 = fdiv float %25, %27
store float %28, float* %9
%29 = load float, float* %6
%30 = load float, float* %7
%31 = load i32, i32* %8
%32 = load float, float* %9
%33 = call float @trap(float %29, float %30, i32 %31, float %32)
store float %33, float* %10
%34 = load float, float* %6
%35 = load float, float* %7
%36 = load float, float* %10
%37 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), float %34, float %35, float %36)
ret i32 1
}

LLVM IR (-O2):
@.str = [33 x i8] c"The integral from %f to %f = %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call float @atof(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call float @atof(i8* %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = fsub float %8, %5
%13 = sitofp i32 %11 to float
%14 = fdiv float %12, %13
%15 = tail call float @trap(float %5, float %8, i32 %11, float %14)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), float %5, float %8, float %15)
ret i32 1
}