#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*/ getchar();
int /*<<< orphan*/ printf(char *, float);
int main() {
  int tmp = 1;
  float sum = 0, n;
  for (n = 1; 1 / n >= 1e-4; n += 2, tmp = -tmp)
    sum = sum + tmp * 1.0 / n;
  printf("%f", sum * 4);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeba(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xead(%rip),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeac(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c1 <main+0xa1>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe94(%rip),%xmm2
mulsd  %xmm2,%xmm1
movss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xe5e(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    114b <main+0x2b>
movss  0xe3b(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%eax
xorps  %xmm0,%xmm0
movss  0xecf(%rip),%xmm1
movss  0xecb(%rip),%xmm2
movsd  0xecf(%rip),%xmm3
movaps %xmm1,%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorps  %xmm5,%xmm5
cvtsi2sd %eax,%xmm5
cvtss2sd %xmm0,%xmm0
xorps  %xmm6,%xmm6
cvtss2sd %xmm4,%xmm6
divsd  %xmm6,%xmm5
addsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtsd2ss %xmm5,%xmm0
addss  %xmm2,%xmm4
neg    %eax
movaps %xmm1,%xmm5
divss  %xmm4,%xmm5
cvtss2sd %xmm5,%xmm5
ucomisd %xmm3,%xmm5
jae    1150 <main+0x30>
mulss  0xe78(%rip),%xmm0
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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