#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*/ printf(char *, double);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int end = 1;
  double sum = 0.0;
  int sign = 1;
  scanf("%d", &end);
  for (int i = 1; i <= end; i++) {
    sum = sum + sign * 1.0 / i;
    sign = -sign;
  }
  printf("%f", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a6 <main+0x86>
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe86(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsi2sdl -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115c <main+0x3c>
movsd  -0x10(%rbp),%xmm0
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xee0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1159 <main+0x39>
cmp    $0x1,%eax
jne    115f <main+0x3f>
xorpd  %xmm0,%xmm0
movsd  0xead(%rip),%xmm1
test   $0x1,%al
jne    11bb <main+0x9b>
jmp    11cb <main+0xab>
xorpd  %xmm0,%xmm0
jmp    11cb <main+0xab>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
xorpd  %xmm0,%xmm0
mov    $0x1,%edx
movsd  0xe8b(%rip),%xmm1
movsd  0xe8b(%rip),%xmm2
nopl   (%rax)
xorps  %xmm3,%xmm3
cvtsi2sd %edx,%xmm3
movapd %xmm1,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm0,%xmm4
lea    0x1(%rdx),%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movapd %xmm2,%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
add    $0x2,%edx
cmp    %ecx,%esi
jne    1180 <main+0x60>
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
test   $0x1,%al
je     11cb <main+0xab>
movsd  0xe3d(%rip),%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 1
br i1 %5, label %21, label %6
6: ; preds = %0
%7 = and i32 %4, 1
%8 = icmp eq i32 %4, 1
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = and i32 %4, -2
br label %24
11: ; preds = %24
%12 = sitofp i32 %35 to double
br label %13
13: ; preds = %11, %6
%14 = phi double [ undef, %6 ], [ %34, %11 ]
%15 = phi double [ 1.000000e+00, %6 ], [ %12, %11 ]
%16 = phi double [ 0.000000e+00, %6 ], [ %34, %11 ]
%17 = icmp eq i32 %7, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = fdiv double 1.000000e+00, %15
%20 = fadd double %16, %19
br label %21
21: ; preds = %18, %13, %0
%22 = phi double [ 0.000000e+00, %0 ], [ %14, %13 ], [ %20, %18 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %22)
ret i32 0
24: ; preds = %24, %9
%25 = phi i32 [ 1, %9 ], [ %35, %24 ]
%26 = phi double [ 0.000000e+00, %9 ], [ %34, %24 ]
%27 = phi i32 [ 0, %9 ], [ %36, %24 ]
%28 = sitofp i32 %25 to double
%29 = fdiv double 1.000000e+00, %28
%30 = fadd double %26, %29
%31 = add nuw i32 %25, 1
%32 = sitofp i32 %31 to double
%33 = fdiv double -1.000000e+00, %32
%34 = fadd double %30, %33
%35 = add nuw i32 %25, 2
%36 = add i32 %27, 2
%37 = icmp eq i32 %36, %10
br i1 %37, label %11, label %24
}