#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 *, float);
void main() {
  float dispatch(float (*)(float), float, float, int);
  float fsin(float);
  float fcos(float);
  float fexp(float);
  float result;
  int n = 1000;
  result = (4 * dispatch(fsin, 0, 1, 2 * n) - dispatch(fsin, 0, 1, n)) / 3;
  printf("sinx dx = %f\n", result);
  result = (4 * dispatch(fcos, -1, 1, 2 * n) - dispatch(fcos, -1, 1, n)) / 3;
  printf("cosx dx = %f\n", result);
  result = (4 * dispatch(fexp, 0, 2, 2 * n) - dispatch(fexp, 0, 2, n)) / 3;
  printf("ex dx = %f\n", result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3e8,-0x8(%rbp)
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
mov    0x2eb4(%rip),%rdi
xorps  %xmm0,%xmm0
movss  0xec9(%rip),%xmm1
call   1040 <dispatch@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e95(%rip),%rdi
xorps  %xmm0,%xmm0
movss  0xeaa(%rip),%xmm1
call   1040 <dispatch@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xe7c(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xe68(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
mov    0x2e09(%rip),%rdi
movss  0xe45(%rip),%xmm0
movss  0xe41(%rip),%xmm1
call   1040 <dispatch@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2de5(%rip),%rdi
movss  0xe21(%rip),%xmm0
movss  0xe1d(%rip),%xmm1
call   1040 <dispatch@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xdef(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xddb(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
mov    0x2d94(%rip),%rdi
xorps  %xmm0,%xmm0
movss  0xdb1(%rip),%xmm1
call   1040 <dispatch@plt>
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2d75(%rip),%rdi
xorps  %xmm0,%xmm0
movss  0xd92(%rip),%xmm1
call   1040 <dispatch@plt>
movaps %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  0xd6c(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  0xd58(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
lea    0xd73(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ec4(%rip),%rbx
movss  0xecc(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x7d0,%esi
call   1040 <dispatch@plt>
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movss  0xea8(%rip),%xmm1
mov    $0x3e8,%esi
call   1040 <dispatch@plt>
movss  0xc(%rsp),%xmm1
mulss  0xe94(%rip),%xmm1
subss  %xmm0,%xmm1
divss  0xe8c(%rip),%xmm1
movaps %xmm1,%xmm0
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e36(%rip),%rbx
movss  0xe72(%rip),%xmm0
mov    %rbx,%rdi
movss  0xe5b(%rip),%xmm1
mov    $0x7d0,%esi
call   1040 <dispatch@plt>
movss  %xmm0,0xc(%rsp)
mov    %rbx,%rdi
movss  0xe4c(%rip),%xmm0
movss  0xe38(%rip),%xmm1
mov    $0x3e8,%esi
call   1040 <dispatch@plt>
movss  0xc(%rsp),%xmm1
mulss  0xe24(%rip),%xmm1
subss  %xmm0,%xmm1
divss  0xe1c(%rip),%xmm1
movaps %xmm1,%xmm0
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dde(%rip),%rbx
movss  0xe06(%rip),%xmm1
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x7d0,%esi
call   1040 <dispatch@plt>
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
movss  0xde2(%rip),%xmm1
mov    $0x3e8,%esi
call   1040 <dispatch@plt>
movss  0xc(%rsp),%xmm1
mulss  0xdbe(%rip),%xmm1
subss  %xmm0,%xmm1
divss  0xdb6(%rip),%xmm1
movaps %xmm1,%xmm0
lea    0xdd4(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"sinx dx = %f\0A\00"
@.str.1 = [14 x i8] c"cosx dx = %f\0A\00"
@.str.2 = [12 x i8] c"ex dx = %f\0A\00"
define void @main() {
%1 = alloca float
%2 = alloca i32
store i32 1000, i32* %2
%3 = load i32, i32* %2
%4 = mul nsw i32 2, %3
%5 = call float @dispatch(float (float)* @fsin, float 0.000000e+00, float 1.000000e+00, i32 %4)
%6 = load i32, i32* %2
%7 = call float @dispatch(float (float)* @fsin, float 0.000000e+00, float 1.000000e+00, i32 %6)
%8 = fneg float %7
%9 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %5, float %8)
%10 = fdiv float %9, 3.000000e+00
store float %10, float* %1
%11 = load float, float* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %11)
%13 = load i32, i32* %2
%14 = mul nsw i32 2, %13
%15 = call float @dispatch(float (float)* @fcos, float -1.000000e+00, float 1.000000e+00, i32 %14)
%16 = load i32, i32* %2
%17 = call float @dispatch(float (float)* @fcos, float -1.000000e+00, float 1.000000e+00, i32 %16)
%18 = fneg float %17
%19 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %15, float %18)
%20 = fdiv float %19, 3.000000e+00
store float %20, float* %1
%21 = load float, float* %1
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), float %21)
%23 = load i32, i32* %2
%24 = mul nsw i32 2, %23
%25 = call float @dispatch(float (float)* @fexp, float 0.000000e+00, float 2.000000e+00, i32 %24)
%26 = load i32, i32* %2
%27 = call float @dispatch(float (float)* @fexp, float 0.000000e+00, float 2.000000e+00, i32 %26)
%28 = fneg float %27
%29 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %25, float %28)
%30 = fdiv float %29, 3.000000e+00
store float %30, float* %1
%31 = load float, float* %1
%32 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), float %31)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"sinx dx = %f\0A\00"
@.str.1 = [14 x i8] c"cosx dx = %f\0A\00"
@.str.2 = [12 x i8] c"ex dx = %f\0A\00"
define void @main() {
%1 = tail call float @dispatch(float (float)* @fsin, float 0.000000e+00, float 1.000000e+00, i32 2000)
%2 = tail call float @dispatch(float (float)* @fsin, float 0.000000e+00, float 1.000000e+00, i32 1000)
%3 = fneg float %2
%4 = tail call float @llvm.fmuladd.f32(float %1, float 4.000000e+00, float %3)
%5 = fdiv float %4, 3.000000e+00
%6 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %5)
%7 = tail call float @dispatch(float (float)* @fcos, float -1.000000e+00, float 1.000000e+00, i32 2000)
%8 = tail call float @dispatch(float (float)* @fcos, float -1.000000e+00, float 1.000000e+00, i32 1000)
%9 = fneg float %8
%10 = tail call float @llvm.fmuladd.f32(float %7, float 4.000000e+00, float %9)
%11 = fdiv float %10, 3.000000e+00
%12 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), float %11)
%13 = tail call float @dispatch(float (float)* @fexp, float 0.000000e+00, float 2.000000e+00, i32 2000)
%14 = tail call float @dispatch(float (float)* @fexp, float 0.000000e+00, float 2.000000e+00, i32 1000)
%15 = fneg float %14
%16 = tail call float @llvm.fmuladd.f32(float %13, float 4.000000e+00, float %15)
%17 = fdiv float %16, 3.000000e+00
%18 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), float %17)
ret void
}