#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 abs(float);
int f(float);
int /*<<< orphan*/ getid(float);
int /*<<< orphan*/ printid(int);
void main() {
  float a, b, d, S, S_1;
  int i, k = 0;
  S = 1;
  S_1 = 0;
  getid(d);
  getid(a);
  getid(b);
  while (abs(S - S_1) > 1e-6) {
    S_1 = S;
    S = 0;
    for (i = 0; i * d < b - a; i++)
      S += ((f(a + i * d) + f(a + (i + 1) * d)) / 2) * d;
    d = d / 2;
    printid(S_1);
    k++;
  }
  printid(S);
  printid(d);
  printid(k);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x1c(%rbp)
movss  0xea9(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1050 <getid@plt>
movss  -0x4(%rbp),%xmm0
call   1050 <getid@plt>
movss  -0x8(%rbp),%xmm0
call   1050 <getid@plt>
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
call   1030 <abs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe6b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1283 <main+0x143>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1255 <main+0x115>
movss  -0x4(%rbp),%xmm1
cvtsi2ssl -0x18(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <f@plt>
mov    %eax,-0x20(%rbp)
movss  -0x4(%rbp),%xmm1
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <f@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c0 <main+0x80>
movss  -0xc(%rbp),%xmm0
movss  0xda2(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
cvttss2si -0x14(%rbp),%edi
call   1060 <printid@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1182 <main+0x42>
cvttss2si -0x10(%rbp),%edi
call   1060 <printid@plt>
cvttss2si -0xc(%rbp),%edi
call   1060 <printid@plt>
mov    -0x1c(%rbp),%edi
call   1060 <printid@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
call   1040 <getid@plt>
call   1040 <getid@plt>
call   1040 <getid@plt>
movss  0xeb6(%rip),%xmm0
call   1030 <abs@plt>
test   %eax,%eax
jle    1198 <main+0x68>
mov    $0x1,%ebx
mov    $0x1,%edi
call   1050 <printid@plt>
movss  0xe9a(%rip),%xmm0
call   1030 <abs@plt>
test   %eax,%eax
jle    11a1 <main+0x71>
mov    $0x1,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1050 <printid@plt>
add    $0x1,%ebx
xorps  %xmm0,%xmm0
call   1030 <abs@plt>
test   %eax,%eax
jg     1180 <main+0x50>
jmp    11a3 <main+0x73>
xor    %ebx,%ebx
mov    $0x1,%ebp
jmp    11a3 <main+0x73>
xor    %ebp,%ebp
mov    %ebp,%edi
call   1050 <printid@plt>
call   1050 <printid@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <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 i32
%7 = alloca i32
store i32 0, i32* %7
store float 1.000000e+00, float* %4
store float 0.000000e+00, float* %5
%8 = load float, float* %3
%9 = call i32 @getid(float %8)
%10 = load float, float* %1
%11 = call i32 @getid(float %10)
%12 = load float, float* %2
%13 = call i32 @getid(float %12)
br label %14
14: ; preds = %55, %0
%15 = load float, float* %4
%16 = load float, float* %5
%17 = fsub float %15, %16
%18 = call i32 @abs(float %17)
%19 = sitofp i32 %18 to double
%20 = fcmp ogt double %19, 0x3EB0C6F7A0B5ED8D
br i1 %20, label %21, label %63
21: ; preds = %14
%22 = load float, float* %4
store float %22, float* %5
store float 0.000000e+00, float* %4
store i32 0, i32* %6
br label %23
23: ; preds = %52, %21
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to float
%26 = load float, float* %3
%27 = fmul float %25, %26
%28 = load float, float* %2
%29 = load float, float* %1
%30 = fsub float %28, %29
%31 = fcmp olt float %27, %30
br i1 %31, label %32, label %55
32: ; preds = %23
%33 = load float, float* %1
%34 = load i32, i32* %6
%35 = sitofp i32 %34 to float
%36 = load float, float* %3
%37 = call float @llvm.fmuladd.f32(float %35, float %36, float %33)
%38 = call i32 @f(float %37)
%39 = load float, float* %1
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
%42 = sitofp i32 %41 to float
%43 = load float, float* %3
%44 = call float @llvm.fmuladd.f32(float %42, float %43, float %39)
%45 = call i32 @f(float %44)
%46 = add nsw i32 %38, %45
%47 = sdiv i32 %46, 2
%48 = sitofp i32 %47 to float
%49 = load float, float* %3
%50 = load float, float* %4
%51 = call float @llvm.fmuladd.f32(float %48, float %49, float %50)
store float %51, float* %4
br label %52
52: ; preds = %32
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %23
55: ; preds = %23
%56 = load float, float* %3
%57 = fdiv float %56, 2.000000e+00
store float %57, float* %3
%58 = load float, float* %5
%59 = fptosi float %58 to i32
%60 = call i32 @printid(i32 %59)
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %14
63: ; preds = %14
%64 = load float, float* %4
%65 = fptosi float %64 to i32
%66 = call i32 @printid(i32 %65)
%67 = load float, float* %3
%68 = fptosi float %67 to i32
%69 = call i32 @printid(i32 %68)
%70 = load i32, i32* %7
%71 = call i32 @printid(i32 %70)
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 @getid(float undef)
%4 = tail call i32 @abs(float 1.000000e+00)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = tail call i32 @printid(i32 1)
%8 = tail call i32 @abs(float -1.000000e+00)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %6, %10
%11 = phi i32 [ %13, %10 ], [ 1, %6 ]
%12 = tail call i32 @printid(i32 0)
%13 = add nuw nsw i32 %11, 1
%14 = tail call i32 @abs(float 0.000000e+00)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %10, %6, %0
%17 = phi i32 [ 1, %0 ], [ 0, %6 ], [ 0, %10 ]
%18 = phi i32 [ 0, %0 ], [ 1, %6 ], [ %13, %10 ]
%19 = tail call i32 @printid(i32 %17)
%20 = tail call i32 @printid(i32 poison)
%21 = tail call i32 @printid(i32 %18)
ret void
}