#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 */
float abs(float);
int f(float);
int /*<<< orphan*/ getid(float);
int /*<<< orphan*/ printid(float);
void main() {
  float a, b, s, s1, l, e = 1e-6;
  int i, n;
  getid(a);
  getid(b);
  n = 10;
  s = 0;
  s1 = 0;
  printid(a);
  printid(b);
  do {
    l = (b - a) / n;
    for (i = 0; i < n; i++) {
      s += ((f(a + i * l) + f(a + (i + 1) * l)) / 2) * l;
    }
    if (abs(s - s1) > l) {
      s1 = s;
      s = 0;
      n = n * 2;
    }
  } while (abs(s - s1) > l);
  printid(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  0xeb0(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
call   1050 <getid@plt>
movss  -0x8(%rbp),%xmm0
call   1050 <getid@plt>
movl   $0xa,-0x20(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
call   1060 <printid@plt>
movss  -0x8(%rbp),%xmm0
call   1060 <printid@plt>
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1237 <main+0xf7>
movss  -0x4(%rbp),%xmm1
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <f@plt>
mov    %eax,-0x24(%rbp)
movss  -0x4(%rbp),%xmm1
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <f@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  -0x14(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b3 <main+0x73>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
ucomiss -0x14(%rbp),%xmm0
jbe    126b <main+0x12b>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1270 <main+0x130>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
ucomiss -0x14(%rbp),%xmm0
ja     1194 <main+0x54>
movss  -0xc(%rbp),%xmm0
call   1060 <printid@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1050 <getid@plt>
call   1050 <getid@plt>
call   1060 <printid@plt>
call   1060 <printid@plt>
movss  0xea3(%rip),%xmm0
call   1040 <f@plt>
movss  0xe96(%rip),%xmm0
call   1040 <f@plt>
movss  0xe89(%rip),%xmm0
call   1040 <f@plt>
movss  0xe7c(%rip),%xmm0
call   1040 <f@plt>
movss  0xe6f(%rip),%xmm0
call   1040 <f@plt>
movss  0xe62(%rip),%xmm0
call   1040 <f@plt>
movss  0xe55(%rip),%xmm0
call   1040 <f@plt>
movss  0xe48(%rip),%xmm0
call   1040 <f@plt>
movss  0xe3b(%rip),%xmm0
call   1040 <f@plt>
movss  0xe2e(%rip),%xmm0
call   1040 <f@plt>
movss  0xe21(%rip),%xmm0
call   1040 <f@plt>
movss  0xe14(%rip),%xmm0
call   1040 <f@plt>
movss  0xe07(%rip),%xmm0
call   1040 <f@plt>
movss  0xdfa(%rip),%xmm0
call   1040 <f@plt>
movss  0xded(%rip),%xmm0
call   1040 <f@plt>
movss  0xde0(%rip),%xmm0
call   1040 <f@plt>
movss  0xdd3(%rip),%xmm0
call   1040 <f@plt>
movss  0xdc6(%rip),%xmm0
call   1040 <f@plt>
movss  0xdb9(%rip),%xmm0
call   1040 <f@plt>
movss  0xdac(%rip),%xmm0
call   1040 <f@plt>
movss  0xd9f(%rip),%xmm0
call   1030 <abs@plt>
movss  0xd92(%rip),%xmm0
call   1030 <abs@plt>
movss  0xd85(%rip),%xmm0
pop    %rax
jmp    1060 <printid@plt>

LLVM IR (-O0):
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
store float 0x3EB0C6F7A0000000, float* %6
%9 = load float, float* %1
%10 = call i32 @getid(float %9)
%11 = load float, float* %2
%12 = call i32 @getid(float %11)
store i32 10, i32* %8
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%13 = load float, float* %1
%14 = call i32 @printid(float %13)
%15 = load float, float* %2
%16 = call i32 @printid(float %15)
br label %17
17: ; preds = %63, %0
%18 = load float, float* %2
%19 = load float, float* %1
%20 = fsub float %18, %19
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
store float %23, float* %5
store i32 0, i32* %7
br label %24
24: ; preds = %48, %17
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %51
28: ; preds = %24
%29 = load float, float* %1
%30 = load i32, i32* %7
%31 = sitofp i32 %30 to float
%32 = load float, float* %5
%33 = call float @llvm.fmuladd.f32(float %31, float %32, float %29)
%34 = call i32 @f(float %33)
%35 = load float, float* %1
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
%38 = sitofp i32 %37 to float
%39 = load float, float* %5
%40 = call float @llvm.fmuladd.f32(float %38, float %39, float %35)
%41 = call i32 @f(float %40)
%42 = add nsw i32 %34, %41
%43 = sdiv i32 %42, 2
%44 = sitofp i32 %43 to float
%45 = load float, float* %5
%46 = load float, float* %3
%47 = call float @llvm.fmuladd.f32(float %44, float %45, float %46)
store float %47, float* %3
br label %48
48: ; preds = %28
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %24
51: ; preds = %24
%52 = load float, float* %3
%53 = load float, float* %4
%54 = fsub float %52, %53
%55 = call float @abs(float %54)
%56 = load float, float* %5
%57 = fcmp ogt float %55, %56
br i1 %57, label %58, label %62
58: ; preds = %51
%59 = load float, float* %3
store float %59, float* %4
store float 0.000000e+00, float* %3
%60 = load i32, i32* %8
%61 = mul nsw i32 %60, 2
store i32 %61, i32* %8
br label %62
62: ; preds = %58, %51
br label %63
63: ; preds = %62
%64 = load float, float* %3
%65 = load float, float* %4
%66 = fsub float %64, %65
%67 = call float @abs(float %66)
%68 = load float, float* %5
%69 = fcmp ogt float %67, %68
br i1 %69, label %17, label %70
70: ; preds = %63
%71 = load float, float* %3
%72 = call i32 @printid(float %71)
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @getid(float undef)
%2 = tail call i32 @getid(float undef)
%3 = tail call i32 @printid(float undef)
%4 = tail call i32 @printid(float undef)
%5 = tail call i32 @f(float 0x7FF8000000000000)
%6 = tail call i32 @f(float 0x7FF8000000000000)
%7 = tail call i32 @f(float 0x7FF8000000000000)
%8 = tail call i32 @f(float 0x7FF8000000000000)
%9 = tail call i32 @f(float 0x7FF8000000000000)
%10 = tail call i32 @f(float 0x7FF8000000000000)
%11 = tail call i32 @f(float 0x7FF8000000000000)
%12 = tail call i32 @f(float 0x7FF8000000000000)
%13 = tail call i32 @f(float 0x7FF8000000000000)
%14 = tail call i32 @f(float 0x7FF8000000000000)
%15 = tail call i32 @f(float 0x7FF8000000000000)
%16 = tail call i32 @f(float 0x7FF8000000000000)
%17 = tail call i32 @f(float 0x7FF8000000000000)
%18 = tail call i32 @f(float 0x7FF8000000000000)
%19 = tail call i32 @f(float 0x7FF8000000000000)
%20 = tail call i32 @f(float 0x7FF8000000000000)
%21 = tail call i32 @f(float 0x7FF8000000000000)
%22 = tail call i32 @f(float 0x7FF8000000000000)
%23 = tail call i32 @f(float 0x7FF8000000000000)
%24 = tail call i32 @f(float 0x7FF8000000000000)
%25 = tail call float @abs(float 0x7FF8000000000000)
%26 = tail call float @abs(float 0x7FF8000000000000)
%27 = tail call i32 @printid(float 0x7FF8000000000000)
ret void
}