#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(int argc, char const *argv[]) {
  int t_ct;
  int limit;
  long double time, x;
  printf("Enter the number of terms you want: ");
  scanf("%d", &limit);
  for (time = 0, x = 1, t_ct = 1; t_ct <= limit; t_ct++, x *= 2.0) {
    time += 1.0 / x;
    printf("time = %Lf when terms = %d\n", time, t_ct);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
fldz
fstpt  -0x30(%rbp)
fld1
fstpt  -0x40(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11af <main+0x8f>
fldt   -0x40(%rbp)
fld1
fdivp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
mov    -0x14(%rbp),%esi
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
fldt   -0x40(%rbp)
fadd   %st,%st(0)
fstpt  -0x40(%rbp)
jmp    1165 <main+0x45>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
lea    0xed3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
fldz
fldz
jle    11a8 <main+0x88>
fstp   %st(1)
fstp   %st(0)
fldz
fld1
lea    0xec9(%rip),%rbx
xor    %ebp,%ebp
fld    %st(0)
fstpt  0x14(%rsp)
nopw   0x0(%rax,%rax,1)
fld    %st(0)
fstpt  0x20(%rsp)
add    $0x1,%ebp
fldt   0x14(%rsp)
fdivp  %st,%st(1)
faddp  %st,%st(1)
fld    %st(0)
fstpt  0x2c(%rsp)
fstpt  (%rsp)
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
fldt   0x20(%rsp)
fldt   0x2c(%rsp)
fxch   %st(1)
fadd   %st,%st(0)
cmp    0x10(%rsp),%ebp
jl     1170 <main+0x50>
fstp   %st(1)
fstp   %st(0)
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter the number of terms you want: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"time = %Lf when terms = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca x86_fp80
%9 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
store x86_fp80 0xK00000000000000000000, x86_fp80* %8
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %9
store i32 1, i32* %6
br label %12
12: ; preds = %24, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load x86_fp80, x86_fp80* %9
%18 = fdiv x86_fp80 0xK3FFF8000000000000000, %17
%19 = load x86_fp80, x86_fp80* %8
%20 = fadd x86_fp80 %19, %18
store x86_fp80 %20, x86_fp80* %8
%21 = load x86_fp80, x86_fp80* %8
%22 = load i32, i32* %6
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %21, i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
%27 = load x86_fp80, x86_fp80* %9
%28 = fmul x86_fp80 %27, 0xK40008000000000000000
store x86_fp80 %28, x86_fp80* %9
br label %12
29: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter the number of terms you want: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"time = %Lf when terms = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1
br i1 %8, label %20, label %9
9: ; preds = %2, %9
%10 = phi x86_fp80 [ %17, %9 ], [ 0xK3FFF8000000000000000, %2 ]
%11 = phi i32 [ %16, %9 ], [ 1, %2 ]
%12 = phi x86_fp80 [ %14, %9 ], [ 0xK00000000000000000000, %2 ]
%13 = fdiv x86_fp80 0xK3FFF8000000000000000, %10
%14 = fadd x86_fp80 %12, %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %14, i32 %11)
%16 = add nuw nsw i32 %11, 1
%17 = fmul x86_fp80 %10, 0xK40008000000000000000
%18 = load i32, i32* %3
%19 = icmp slt i32 %11, %18
br i1 %19, label %9, label %20
20: ; preds = %9, %2
ret i32 0
}