#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, float *);
int main() {
  float integral(float (*)(float), float, float, int);
  float fsin(float);
  float fcos(float);
  float fexp(float);
  float a1, b1, a2, b2, a3, b3, c, (*p)(float);
  int n = 20;
  printf("input a1 b1:");
  scanf("%f %f", &a1, &b1);
  printf("input a2 b2:");
  scanf("%f %f", &a2, &b2);
  printf("input a3 b3:");
  scanf("%f %f", &a3, &b3);
  p = fsin;
  c = integral(p, a1, b1, n);
  printf("the integral of sinx = %f\n", c);
  p = fcos;
  c = integral(p, a2, b2, n);
  printf("the integral of cosx = %f\n", c);
  p = fexp;
  c = integral(p, a3, b3, n);
  printf("the integral of expx = %f\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x14,-0x2c(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <scanf@plt>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <scanf@plt>
mov    0x2e3d(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
call   1030 <integral@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2dd8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
call   1030 <integral@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe29(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2db3(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
call   1030 <integral@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rbx
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
mov    0x2e41(%rip),%rdi
mov    $0x14,%esi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mov    0x2dea(%rip),%rdi
mov    $0x14,%esi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
mov    0x2dd3(%rip),%rdi
mov    $0x14,%esi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"input a1 b1:\00"
@.str.1 = [6 x i8] c"%f %f\00"
@.str.2 = [13 x i8] c"input a2 b2:\00"
@.str.3 = [13 x i8] c"input a3 b3:\00"
@.str.4 = [27 x i8] c"the integral of sinx = %f\0A\00"
@.str.5 = [27 x i8] c"the integral of cosx = %f\0A\00"
@.str.6 = [27 x i8] c"the integral of expx = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float (float)*
%10 = alloca i32
store i32 0, i32* %1
store i32 20, i32* %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %2, float* %3)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %4, float* %5)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %6, float* %7)
store float (float)* @fsin, float (float)** %9
%17 = load float (float)*, float (float)** %9
%18 = load float, float* %2
%19 = load float, float* %3
%20 = load i32, i32* %10
%21 = call float @integral(float (float)* %17, float %18, float %19, i32 %20)
store float %21, float* %8
%22 = load float, float* %8
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %23)
store float (float)* @fcos, float (float)** %9
%25 = load float (float)*, float (float)** %9
%26 = load float, float* %4
%27 = load float, float* %5
%28 = load i32, i32* %10
%29 = call float @integral(float (float)* %25, float %26, float %27, i32 %28)
store float %29, float* %8
%30 = load float, float* %8
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %31)
store float (float)* @fexp, float (float)** %9
%33 = load float (float)*, float (float)** %9
%34 = load float, float* %6
%35 = load float, float* %7
%36 = load i32, i32* %10
%37 = call float @integral(float (float)* %33, float %34, float %35, i32 %36)
store float %37, float* %8
%38 = load float, float* %8
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"input a1 b1:\00"
@.str.1 = [6 x i8] c"%f %f\00"
@.str.2 = [13 x i8] c"input a2 b2:\00"
@.str.3 = [13 x i8] c"input a3 b3:\00"
@.str.4 = [27 x i8] c"the integral of sinx = %f\0A\00"
@.str.5 = [27 x i8] c"the integral of cosx = %f\0A\00"
@.str.6 = [27 x i8] c"the integral of expx = %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = bitcast float* %1 to i8*
%8 = bitcast float* %2 to i8*
%9 = bitcast float* %3 to i8*
%10 = bitcast float* %4 to i8*
%11 = bitcast float* %5 to i8*
%12 = bitcast float* %6 to i8*
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %1, float* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %3, float* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float* %5, float* %6)
%19 = load float, float* %1
%20 = load float, float* %2
%21 = call float @integral(float (float)* @fsin, float %19, float %20, i32 20)
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), double %22)
%24 = load float, float* %3
%25 = load float, float* %4
%26 = call float @integral(float (float)* @fcos, float %24, float %25, i32 20)
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), double %27)
%29 = load float, float* %5
%30 = load float, float* %6
%31 = call float @integral(float (float)* @fexp, float %29, float %30, i32 20)
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), double %32)
ret i32 0
}