#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 *, ...);
int main() {
  float integral(float (*p)(float), float a, float b, int n);
  float fsin(float x);
  float fcos(float x);
  float fexp(float x);
  float a1, b1, a2, b2, a3, b3, c, (*p)(float);
  int n;
  printf("Input the num:");
  scanf("%d", &n);
  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 sin(n) is :%f\n", c);
  p = fcos;
  c = integral(p, a2, b2, n);
  printf("The integral of cos(n) is :%f\n", c);
  p = fexp;
  c = integral(p, a3, b3, n);
  printf("The integral of exp(n) is :%f\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    0x2e1e(%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    0xe3e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2db9(%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    0xe20(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d94(%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    0xe02(%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    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rbx
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x1c(%rsp),%xmm0
movss  0x18(%rsp),%xmm1
mov    0x4(%rsp),%esi
mov    0x2e16(%rip),%rdi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
mov    0x4(%rsp),%esi
mov    0x2dc0(%rip),%rdi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
mov    0x4(%rsp),%esi
mov    0x2daa(%rip),%rdi
call   1030 <integral@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Input the num:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"input a1,b1:\00"
@.str.3 = [6 x i8] c"%f,%f\00"
@.str.4 = [13 x i8] c"input a2,b2:\00"
@.str.5 = [13 x i8] c"input a3,b3:\00"
@.str.6 = [31 x i8] c"The integral of sin(n) is :%f\0A\00"
@.str.7 = [31 x i8] c"The integral of cos(n) is :%f\0A\00"
@.str.8 = [31 x i8] c"The integral of exp(n) is :%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
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %2, float* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %4, float* %5)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %6, float* %7)
store float (float)* @fsin, float (float)** %9
%19 = load float (float)*, float (float)** %9
%20 = load float, float* %2
%21 = load float, float* %3
%22 = load i32, i32* %10
%23 = call float @integral(float (float)* %19, float %20, float %21, i32 %22)
store float %23, float* %8
%24 = load float, float* %8
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %25)
store float (float)* @fcos, float (float)** %9
%27 = load float (float)*, float (float)** %9
%28 = load float, float* %4
%29 = load float, float* %5
%30 = load i32, i32* %10
%31 = call float @integral(float (float)* %27, float %28, float %29, i32 %30)
store float %31, float* %8
%32 = load float, float* %8
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %33)
store float (float)* @fexp, float (float)** %9
%35 = load float (float)*, float (float)** %9
%36 = load float, float* %6
%37 = load float, float* %7
%38 = load i32, i32* %10
%39 = call float @integral(float (float)* %35, float %36, float %37, i32 %38)
store float %39, float* %8
%40 = load float, float* %8
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), double %41)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"Input the num:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"input a1,b1:\00"
@.str.3 = [6 x i8] c"%f,%f\00"
@.str.4 = [13 x i8] c"input a2,b2:\00"
@.str.5 = [13 x i8] c"input a3,b3:\00"
@.str.6 = [31 x i8] c"The integral of sin(n) is :%f\0A\00"
@.str.7 = [31 x i8] c"The integral of cos(n) is :%f\0A\00"
@.str.8 = [31 x i8] c"The integral of exp(n) is :%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 = alloca i32
%8 = bitcast float* %1 to i8*
%9 = bitcast float* %2 to i8*
%10 = bitcast float* %3 to i8*
%11 = bitcast float* %4 to i8*
%12 = bitcast float* %5 to i8*
%13 = bitcast float* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %1, float* %2)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %3, float* %4)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float* %5, float* %6)
%23 = load float, float* %1
%24 = load float, float* %2
%25 = load i32, i32* %7
%26 = call float @integral(float (float)* @fsin, float %23, float %24, i32 %25)
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %27)
%29 = load float, float* %3
%30 = load float, float* %4
%31 = load i32, i32* %7
%32 = call float @integral(float (float)* @fcos, float %29, float %30, i32 %31)
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %33)
%35 = load float, float* %5
%36 = load float, float* %6
%37 = load i32, i32* %7
%38 = call float @integral(float (float)* @fexp, float %35, float %36, i32 %37)
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), double %39)
ret i32 0
}