#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 fabs(double);
int /*<<< orphan*/ printf(char *, float);
int main(void) {
  float sum = 0, p = 1, sign = 1;
  while (fabs(1.0 / p) > 1e-4) {
    sum += 1.0 / p * sign;
    p++;
    sign *= -1;
  }
  printf("%f", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xec1(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeb4(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xeae(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe91(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e2 <main+0xc2>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe7e(%rip),%xmm0
divsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe3f(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe31(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1151 <main+0x31>
movss  -0x8(%rbp),%xmm0
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movsd  0xed4(%rip),%xmm0
call   1040 <fabs@plt>
xorps  %xmm1,%xmm1
test   %eax,%eax
jle    11c5 <main+0xa5>
movss  0xec4(%rip),%xmm2
movsd  0xeb4(%rip),%xmm4
movaps %xmm2,%xmm3
nop
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulsd  %xmm4,%xmm0
cvtss2sd %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%rsp)
addss  0xe91(%rip),%xmm2
movss  %xmm2,0x4(%rsp)
xorps  0xe8c(%rip),%xmm3
movaps %xmm3,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movsd  0xe68(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1040 <fabs@plt>
movsd  0x8(%rsp),%xmm4
movss  0x4(%rsp),%xmm2
movaps 0x10(%rsp),%xmm3
movss  (%rsp),%xmm1
test   %eax,%eax
jg     1150 <main+0x30>
lea    0xe54(%rip),%rdi
movaps %xmm1,%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define i32 @main() {
%1 = tail call i32 @fabs(double 1.000000e+00)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %18
3: ; preds = %0, %3
%4 = phi double [ %15, %3 ], [ 1.000000e+00, %0 ]
%5 = phi float [ %13, %3 ], [ 1.000000e+00, %0 ]
%6 = phi float [ %12, %3 ], [ 1.000000e+00, %0 ]
%7 = phi float [ %11, %3 ], [ 0.000000e+00, %0 ]
%8 = fpext float %5 to double
%9 = fpext float %7 to double
%10 = tail call double @llvm.fmuladd.f64(double %4, double %8, double %9)
%11 = fptrunc double %10 to float
%12 = fadd float %6, 1.000000e+00
%13 = fneg float %5
%14 = fpext float %12 to double
%15 = fdiv double 1.000000e+00, %14
%16 = tail call i32 @fabs(double %15)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %3, label %18
18: ; preds = %3, %0
%19 = phi float [ 0.000000e+00, %0 ], [ %11, %3 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float %19)
ret i32 0
}