#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 /*<<< orphan*/ print(float);
int sin(float);
void main() {
  float a, b, s = 0, s1 = 1, c;
  int i;
  a = 0;
  b = 3.1415926;
  c = (b - a) / 10;
  while (abs(s - s1) > 1e-6) {
    s1 = s;
    s = 0;
    for (i = 0; i * c < b - a; i++)
      s += ((sin(a + i * c) + sin(a + (i + 1) * c)) / 2) * c;
    c = c / 2;
  }
  print(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xec0(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xea7(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
movss  0xe8c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe78(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126b <main+0x13b>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm1
mulss  -0x14(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1250 <main+0x120>
movss  -0x4(%rbp),%xmm1
cvtsi2ssl -0x18(%rbp),%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sin@plt>
mov    %eax,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm1
mov    -0x18(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
movss  -0x14(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sin@plt>
mov    %eax,%ecx
mov    -0x1c(%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    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bb <main+0x8b>
movss  -0x14(%rbp),%xmm0
movss  0xdaf(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    117d <main+0x4d>
movss  -0xc(%rbp),%xmm0
call   1040 <print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movss  0xec2(%rip),%xmm0
call   1030 <abs@plt>
test   %eax,%eax
jle    1271 <main+0x141>
xorps  %xmm1,%xmm1
movss  0xeae(%rip),%xmm2
movss  0xeaa(%rip),%xmm3
xorps  %xmm4,%xmm4
jmp    11b7 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm3,0x4(%rsp)
mulss  0xe8e(%rip),%xmm2
movss  %xmm2,0x8(%rsp)
movss  0x4(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
call   1030 <abs@plt>
movss  0x4(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
movaps %xmm0,%xmm4
test   %eax,%eax
xorps  %xmm1,%xmm1
movss  0xe57(%rip),%xmm3
jle    1274 <main+0x144>
movss  %xmm4,0xc(%rsp)
movaps %xmm2,%xmm0
mulss  %xmm1,%xmm0
ucomiss %xmm0,%xmm3
xorps  %xmm3,%xmm3
xorps  %xmm1,%xmm1
jbe    1170 <main+0x40>
xorps  %xmm0,%xmm0
mov    $0x1,%ebp
xorps  %xmm3,%xmm3
movss  %xmm2,0x8(%rsp)
movss  %xmm3,0x4(%rsp)
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  %xmm0,0x10(%rsp)
mov    %eax,%ebx
mulss  0x8(%rsp),%xmm0
movss  %xmm0,0x14(%rsp)
addss  0xdfa(%rip),%xmm0
call   1050 <sin@plt>
movss  0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm2
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
xorps  %xmm3,%xmm3
cvtsi2ss %ecx,%xmm3
mulss  %xmm2,%xmm3
movss  0x4(%rsp),%xmm1
addss  %xmm3,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x4(%rsp),%xmm3
add    $0x1,%ebp
movss  0xdaa(%rip),%xmm1
ucomiss 0x14(%rsp),%xmm1
xorps  %xmm1,%xmm1
ja     11e0 <main+0xb0>
jmp    1170 <main+0x40>
xorps  %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <print@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
store float 0.000000e+00, float* %3
store float 1.000000e+00, float* %4
store float 0.000000e+00, float* %1
store float 0x400921FB40000000, float* %2
%7 = load float, float* %2
%8 = load float, float* %1
%9 = fsub float %7, %8
%10 = fdiv float %9, 1.000000e+01
store float %10, float* %5
br label %11
11: ; preds = %52, %0
%12 = load float, float* %3
%13 = load float, float* %4
%14 = fsub float %12, %13
%15 = call i32 @abs(float %14)
%16 = sitofp i32 %15 to double
%17 = fcmp ogt double %16, 0x3EB0C6F7A0B5ED8D
br i1 %17, label %18, label %55
18: ; preds = %11
%19 = load float, float* %3
store float %19, float* %4
store float 0.000000e+00, float* %3
store i32 0, i32* %6
br label %20
20: ; preds = %49, %18
%21 = load i32, i32* %6
%22 = sitofp i32 %21 to float
%23 = load float, float* %5
%24 = fmul float %22, %23
%25 = load float, float* %2
%26 = load float, float* %1
%27 = fsub float %25, %26
%28 = fcmp olt float %24, %27
br i1 %28, label %29, label %52
29: ; preds = %20
%30 = load float, float* %1
%31 = load i32, i32* %6
%32 = sitofp i32 %31 to float
%33 = load float, float* %5
%34 = call float @llvm.fmuladd.f32(float %32, float %33, float %30)
%35 = call i32 @sin(float %34)
%36 = load float, float* %1
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
%39 = sitofp i32 %38 to float
%40 = load float, float* %5
%41 = call float @llvm.fmuladd.f32(float %39, float %40, float %36)
%42 = call i32 @sin(float %41)
%43 = add nsw i32 %35, %42
%44 = sdiv i32 %43, 2
%45 = sitofp i32 %44 to float
%46 = load float, float* %5
%47 = load float, float* %3
%48 = call float @llvm.fmuladd.f32(float %45, float %46, float %47)
store float %48, float* %3
br label %49
49: ; preds = %29
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %20
52: ; preds = %20
%53 = load float, float* %5
%54 = fdiv float %53, 2.000000e+00
store float %54, float* %5
br label %11
55: ; preds = %11
%56 = load float, float* %3
%57 = call i32 @print(float %56)
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @abs(float -1.000000e+00)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %30
3: ; preds = %0, %24
%4 = phi float [ %26, %24 ], [ 0x3FD41B2F60000000, %0 ]
%5 = phi float [ %25, %24 ], [ 0.000000e+00, %0 ]
%6 = fmul float %4, 0.000000e+00
%7 = fcmp olt float %6, 0x400921FB40000000
br i1 %7, label %8, label %24
8: ; preds = %3, %8
%9 = phi float [ %15, %8 ], [ 0.000000e+00, %3 ]
%10 = phi i32 [ %14, %8 ], [ 0, %3 ]
%11 = phi float [ %21, %8 ], [ 0.000000e+00, %3 ]
%12 = tail call float @llvm.fmuladd.f32(float %9, float %4, float 0.000000e+00)
%13 = tail call i32 @sin(float %12)
%14 = add nuw nsw i32 %10, 1
%15 = sitofp i32 %14 to float
%16 = tail call float @llvm.fmuladd.f32(float %15, float %4, float 0.000000e+00)
%17 = tail call i32 @sin(float %16)
%18 = add nsw i32 %17, %13
%19 = sdiv i32 %18, 2
%20 = sitofp i32 %19 to float
%21 = tail call float @llvm.fmuladd.f32(float %20, float %4, float %11)
%22 = fmul float %4, %15
%23 = fcmp olt float %22, 0x400921FB40000000
br i1 %23, label %8, label %24
24: ; preds = %8, %3
%25 = phi float [ 0.000000e+00, %3 ], [ %21, %8 ]
%26 = fmul float %4, 5.000000e-01
%27 = fsub float %25, %5
%28 = tail call i32 @abs(float %27)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %3, label %30
30: ; preds = %24, %0
%31 = phi float [ 0.000000e+00, %0 ], [ %25, %24 ]
%32 = tail call i32 @print(float %31)
ret void
}