#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);
float stub1(float);
float integral(float a, float b, float (*p)(float x)) {
  float x, result = 0;
  float dx = 0.001;
  for (x = a; x < b;) {
    result = result + (*p)(x)*dx;
    x = x + dx;
  }
  printf("%10.5f\n", result);
  return result;
}


x86 assembly (clang, -O0):
<integral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xeca(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1198 <integral+0x88>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  -0x14(%rbp),%xmm0
call   *%rax
movss  -0x20(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1145 <integral+0x35>
movss  -0x18(%rbp),%xmm0
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integral>:
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm2
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm1
jbe    1178 <integral+0x68>
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movss  %xmm1,0x8(%rsp)
nopl   0x0(%rax)
movss  %xmm2,0xc(%rsp)
movss  %xmm0,0x4(%rsp)
movaps %xmm2,%xmm0
call   *%rbx
movss  0xc(%rsp),%xmm2
movss  0xeb1(%rip),%xmm3
mulss  %xmm3,%xmm0
movss  0x4(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x8(%rsp),%xmm1
movss  0x4(%rsp),%xmm0
addss  %xmm3,%xmm2
ucomiss %xmm2,%xmm1
ja     1130 <integral+0x20>
lea    0xe85(%rip),%rdi
movss  %xmm0,0x4(%rsp)
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%10.5f\0A\00"
define float @integral(float %0, float %1, float (float)* %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float (float)*
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float %1, float* %5
store float (float)* %2, float (float)** %6
store float 0.000000e+00, float* %8
store float 0x3F50624DE0000000, float* %9
%10 = load float, float* %4
store float %10, float* %7
br label %11
11: ; preds = %15, %3
%12 = load float, float* %7
%13 = load float, float* %5
%14 = fcmp olt float %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load float, float* %8
%17 = load float (float)*, float (float)** %6
%18 = load float, float* %7
%19 = call float %17(float %18)
%20 = load float, float* %9
%21 = call float @llvm.fmuladd.f32(float %19, float %20, float %16)
store float %21, float* %8
%22 = load float, float* %7
%23 = load float, float* %9
%24 = fadd float %22, %23
store float %24, float* %7
br label %11
25: ; preds = %11
%26 = load float, float* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), float %26)
%28 = load float, float* %8
ret float %28
}

LLVM IR (-O2):
@.str = [8 x i8] c"%10.5f\0A\00"
define float @integral(float %0, float %1, float (float)* nocapture %2) {
%4 = fcmp olt float %0, %1
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi float [ %10, %5 ], [ %0, %3 ]
%7 = phi float [ %9, %5 ], [ 0.000000e+00, %3 ]
%8 = tail call float %2(float %6)
%9 = tail call float @llvm.fmuladd.f32(float %8, float 0x3F50624DE0000000, float %7)
%10 = fadd float %6, 0x3F50624DE0000000
%11 = fcmp olt float %10, %1
br i1 %11, label %5, label %12
12: ; preds = %5, %3
%13 = phi float [ 0.000000e+00, %3 ], [ %9, %5 ]
%14 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), float %13)
ret float %13
}