#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int y;
  double x, sum = 0, minus = 0;
  printf("Enter term:");
  scanf("%d", &y);
  while (y > 0) {
    for (x = 1.0; x <= y; x++)
      sum += (double)1.0 / x;
    printf(" %g\n", sum);
    for (x = 1.0; x <= y; x++)
      minus -= 1.0 / x;
    printf("%g\n", minus);
    printf("Enter term:");
    scanf("%d", &y);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1252 <main+0x132>
movsd  0xe91(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11b6 <main+0x96>
movsd  0xe70(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe59(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1174 <main+0x54>
movsd  -0x18(%rbp),%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xe2f(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     121c <main+0xfc>
movsd  0xe0e(%rip),%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdf3(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11d6 <main+0xb6>
movsd  -0x20(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115d <main+0x3d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    125b <main+0x13b>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe96(%rip),%xmm3
lea    0xea6(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xe89(%rip),%r12
lea    0xe8e(%rip),%r13
lea    0xc(%rsp),%rbx
xorpd  %xmm0,%xmm0
jmp    11e1 <main+0xc1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x10(%rsp),%xmm0
mov    %r15,%rdi
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0xe2d(%rip),%xmm3
mov    0xc(%rsp),%eax
test   %eax,%eax
movsd  0x18(%rsp),%xmm0
jle    125b <main+0x13b>
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
movapd %xmm3,%xmm1
nopl   0x0(%rax)
movapd %xmm3,%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
addsd  %xmm3,%xmm1
ucomisd %xmm1,%xmm4
jae    11f0 <main+0xd0>
mov    %r14,%rdi
movsd  %xmm0,0x18(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11a0 <main+0x80>
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
movsd  0xdd3(%rip),%xmm4
movapd %xmm4,%xmm1
movsd  0x10(%rsp),%xmm0
nopw   0x0(%rax,%rax,1)
movapd %xmm4,%xmm2
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
addsd  %xmm4,%xmm1
ucomisd %xmm1,%xmm3
jae    1240 <main+0x120>
jmp    11a6 <main+0x86>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Enter term:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c" %g\0A\00"
@.str.3 = [4 x i8] c"%g\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %41, %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %46
11: ; preds = %8
store double 1.000000e+00, double* %3
br label %12
12: ; preds = %22, %11
%13 = load double, double* %3
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to double
%16 = fcmp ole double %13, %15
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load double, double* %3
%19 = fdiv double 1.000000e+00, %18
%20 = load double, double* %4
%21 = fadd double %20, %19
store double %21, double* %4
br label %22
22: ; preds = %17
%23 = load double, double* %3
%24 = fadd double %23, 1.000000e+00
store double %24, double* %3
br label %12
25: ; preds = %12
%26 = load double, double* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %26)
store double 1.000000e+00, double* %3
br label %28
28: ; preds = %38, %25
%29 = load double, double* %3
%30 = load i32, i32* %2
%31 = sitofp i32 %30 to double
%32 = fcmp ole double %29, %31
br i1 %32, label %33, label %41
33: ; preds = %28
%34 = load double, double* %3
%35 = fdiv double 1.000000e+00, %34
%36 = load double, double* %5
%37 = fsub double %36, %35
store double %37, double* %5
br label %38
38: ; preds = %33
%39 = load double, double* %3
%40 = fadd double %39, 1.000000e+00
store double %40, double* %3
br label %28
41: ; preds = %28
%42 = load double, double* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
46: ; preds = %8
ret i32 0
}

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