#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 *, double *);
int main(void) {
  double start = 1.0;
  double lower, upper;
  double s1 = 0, s2 = 0;
  double sign = -1.0;
  scanf("%lf", &upper);
  for (lower = start; lower <= upper; lower++) {
    s1 += start / lower;
    if (sign == -1)
      sign = 1;
    else
      sign = -1;
    s2 += (start / lower) * sign;
  }
  printf("s1 = %lf\n", s1);
  printf("s2 = %lf\n", s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeac(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     120f <main+0xef>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11ca <main+0xaa>
jp     11ca <main+0xaa>
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11d7 <main+0xb7>
movsd  0xe2e(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe08(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1173 <main+0x53>
movsd  -0x28(%rbp),%xmm0
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xee5(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm8
xorpd  %xmm0,%xmm0
ucomisd 0xeb7(%rip),%xmm8
xorpd  %xmm1,%xmm1
jb     11a8 <main+0x88>
movsd  0xea9(%rip),%xmm2
xorpd  %xmm1,%xmm1
movsd  0xea5(%rip),%xmm3
movapd %xmm3,%xmm4
xorpd  %xmm0,%xmm0
movapd %xmm2,%xmm5
nop
movapd %xmm2,%xmm6
divsd  %xmm5,%xmm6
addsd  %xmm6,%xmm0
cmpeqsd %xmm3,%xmm4
movapd %xmm4,%xmm7
andpd  %xmm2,%xmm7
andnpd %xmm3,%xmm4
orpd   %xmm7,%xmm4
movapd %xmm4,%xmm7
mulsd  %xmm6,%xmm7
addsd  %xmm7,%xmm1
addsd  %xmm2,%xmm5
ucomisd %xmm5,%xmm8
jae    1170 <main+0x50>
movsd  %xmm1,0x8(%rsp)
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [10 x i8] c"s1 = %lf\0A\00"
@.str.2 = [10 x i8] c"s2 = %lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double -1.000000e+00, double* %7
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %4)
%9 = load double, double* %2
store double %9, double* %3
br label %10
10: ; preds = %31, %0
%11 = load double, double* %3
%12 = load double, double* %4
%13 = fcmp ole double %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = load double, double* %2
%16 = load double, double* %3
%17 = fdiv double %15, %16
%18 = load double, double* %5
%19 = fadd double %18, %17
store double %19, double* %5
%20 = load double, double* %7
%21 = fcmp oeq double %20, -1.000000e+00
br i1 %21, label %22, label %23
22: ; preds = %14
store double 1.000000e+00, double* %7
br label %24
23: ; preds = %14
store double -1.000000e+00, double* %7
br label %24
24: ; preds = %23, %22
%25 = load double, double* %2
%26 = load double, double* %3
%27 = fdiv double %25, %26
%28 = load double, double* %7
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double %27, double %28, double %29)
store double %30, double* %6
br label %31
31: ; preds = %24
%32 = load double, double* %3
%33 = fadd double %32, 1.000000e+00
store double %33, double* %3
br label %10
34: ; preds = %10
%35 = load double, double* %5
%36 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = load double, double* %6
%38 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [10 x i8] c"s1 = %lf\0A\00"
@.str.2 = [10 x i8] c"s2 = %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = load double, double* %1
%5 = fcmp ult double %4, 1.000000e+00
br i1 %5, label %18, label %6
6: ; preds = %0, %6
%7 = phi double [ %14, %6 ], [ -1.000000e+00, %0 ]
%8 = phi double [ %15, %6 ], [ 0.000000e+00, %0 ]
%9 = phi double [ %12, %6 ], [ 0.000000e+00, %0 ]
%10 = phi double [ %16, %6 ], [ 1.000000e+00, %0 ]
%11 = fdiv double 1.000000e+00, %10
%12 = fadd double %9, %11
%13 = fcmp oeq double %7, -1.000000e+00
%14 = select i1 %13, double 1.000000e+00, double -1.000000e+00
%15 = call double @llvm.fmuladd.f64(double %11, double %14, double %8)
%16 = fadd double %10, 1.000000e+00
%17 = fcmp ugt double %16, %4
br i1 %17, label %18, label %6
18: ; preds = %6, %0
%19 = phi double [ 0.000000e+00, %0 ], [ %12, %6 ]
%20 = phi double [ 0.000000e+00, %0 ], [ %15, %6 ]
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %19)
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}