#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 rectangles(int, double, double, double);
double simpson(int, double, double, double, double);
int /*<<< orphan*/ sprintf(char *, char *, double, double, double);
char *strdup(char *);
double trapezes(int, double, double, double, double);
char *integ(int f, double n) {
  double a = 0.0;
  double b = 1.0;
  double h = (b - a) / n;
  char str[1024];
  sprintf(str, "%.1E\t\t%.1E\t\t%.1E", rectangles(f, n, a, h),
          trapezes(f, n, a, b, h), simpson(f, n, a, b, h));
  return (strdup(str));
}


x86 assembly (clang, -O0):
<integ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe8d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1040 <rectangles@plt>
movsd  %xmm0,-0x438(%rbp)
ff
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1030 <trapezes@plt>
movsd  %xmm0,-0x440(%rbp)
ff
mov    -0x4(%rbp),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
call   1050 <simpson@plt>
mov    -0x448(%rbp),%rdi
movsd  -0x440(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x438(%rbp),%xmm0
ff
lea    0xdee(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x430(%rbp),%rdi
call   1070 <strdup@plt>
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integ>:
push   %rbx
sub    $0x420,%rsp
movsd  %xmm0,(%rsp)
mov    %edi,%ebx
movsd  0xe99(%rip),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
xorps  %xmm1,%xmm1
call   1040 <rectangles@plt>
movsd  %xmm0,0x18(%rsp)
xorps  %xmm1,%xmm1
mov    %ebx,%edi
movsd  (%rsp),%xmm0
movsd  0xe6f(%rip),%xmm2
movsd  0x8(%rsp),%xmm3
call   1030 <trapezes@plt>
movsd  %xmm0,0x10(%rsp)
xorps  %xmm1,%xmm1
mov    %ebx,%edi
movsd  (%rsp),%xmm0
movsd  0xe4c(%rip),%xmm2
movsd  0x8(%rsp),%xmm3
call   1050 <simpson@plt>
movaps %xmm0,%xmm2
lea    0xe3f(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strdup@plt>
add    $0x420,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%.1E\09\09%.1E\09\09%.1E\00"
define i8* @integ(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca [1024 x i8]
store i32 %0, i32* %3
store double %1, double* %4
store double 0.000000e+00, double* %5
store double 1.000000e+00, double* %6
%9 = load double, double* %6
%10 = load double, double* %5
%11 = fsub double %9, %10
%12 = load double, double* %4
%13 = fdiv double %11, %12
store double %13, double* %7
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%15 = load i32, i32* %3
%16 = load double, double* %4
%17 = load double, double* %5
%18 = load double, double* %7
%19 = call double @rectangles(i32 %15, double %16, double %17, double %18)
%20 = load i32, i32* %3
%21 = load double, double* %4
%22 = load double, double* %5
%23 = load double, double* %6
%24 = load double, double* %7
%25 = call double @trapezes(i32 %20, double %21, double %22, double %23, double %24)
%26 = load i32, i32* %3
%27 = load double, double* %4
%28 = load double, double* %5
%29 = load double, double* %6
%30 = load double, double* %7
%31 = call double @simpson(i32 %26, double %27, double %28, double %29, double %30)
%32 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %19, double %25, double %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = call i8* @strdup(i8* %33)
ret i8* %34
}

LLVM IR (-O2):
@.str = [17 x i8] c"%.1E\09\09%.1E\09\09%.1E\00"
define noalias i8* @integ(i32 %0, double %1) {
%3 = alloca [1024 x i8]
%4 = fdiv double 1.000000e+00, %1
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = tail call double @rectangles(i32 %0, double %1, double 0.000000e+00, double %4)
%7 = tail call double @trapezes(i32 %0, double %1, double 0.000000e+00, double 1.000000e+00, double %4)
%8 = tail call double @simpson(i32 %0, double %1, double 0.000000e+00, double 1.000000e+00, double %4)
%9 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %6, double %7, double %8)
%10 = call i8* @strdup(i8* %5)
ret i8* %10
}