#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 */
double power(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main(void) {
  double num, sum = 1;
  int i = 1;
  double temp;
  printf("Please input a value (Between (-1) and (+1) ): ");
  scanf("%lf", &num);
  temp = num;
  while ((num > 0.000001) || (num < -0.000001)) {
    sum = sum + num;
    i++;
    num = power(temp, i);
  }
  printf("\n The value of 1-(1/x) will be: %lf \n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x29(%rbp)
ja     11aa <main+0x7a>
movsd  0xe71(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
seta   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11ba <main+0x8a>
jmp    11e9 <main+0xb9>
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <power@plt>
movsd  %xmm0,-0x10(%rbp)
jmp    117b <main+0x4b>
movsd  -0x18(%rbp),%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefe(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm1
ucomisd 0xe9e(%rip),%xmm1
ja     117c <main+0x4c>
movsd  0xea4(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     117c <main+0x4c>
movsd  0xe8e(%rip),%xmm2
jmp    11e2 <main+0xb2>
movsd  0xe84(%rip),%xmm2
mov    $0x2,%ebx
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
movapd %xmm1,%xmm0
mov    %ebx,%edi
call   1030 <power@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebx
ucomisd 0xe2e(%rip),%xmm0
ja     11a0 <main+0x70>
movsd  0xe34(%rip),%xmm3
ucomisd %xmm0,%xmm3
ja     11a0 <main+0x70>
lea    0xe63(%rip),%rdi
movapd %xmm2,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Please input a value (Between (-1) and (+1) ): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [38 x i8] c"\0A The value of 1-(1/x) will be: %lf \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %3
store i32 1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = load double, double* %2
store double %8, double* %5
br label %9
9: ; preds = %17, %0
%10 = load double, double* %2
%11 = fcmp ogt double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %2
%14 = fcmp olt double %13, 0xBEB0C6F7A0B5ED8D
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = load double, double* %3
%19 = load double, double* %2
%20 = fadd double %18, %19
store double %20, double* %3
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
%23 = load double, double* %5
%24 = load i32, i32* %4
%25 = call double @power(double %23, i32 %24)
store double %25, double* %2
br label %9
26: ; preds = %15
%27 = load double, double* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"Please input a value (Between (-1) and (+1) ): \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [38 x i8] c"\0A The value of 1-(1/x) will be: %lf \0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fcmp ogt double %5, 0x3EB0C6F7A0B5ED8D
%7 = fcmp olt double %5, 0xBEB0C6F7A0B5ED8D
%8 = or i1 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %0, %9
%10 = phi double [ %15, %9 ], [ %5, %0 ]
%11 = phi double [ %13, %9 ], [ 1.000000e+00, %0 ]
%12 = phi i32 [ %14, %9 ], [ 1, %0 ]
%13 = fadd double %11, %10
%14 = add nuw nsw i32 %12, 1
%15 = call double @power(double %5, i32 %14)
store double %15, double* %1
%16 = fcmp ogt double %15, 0x3EB0C6F7A0B5ED8D
%17 = fcmp olt double %15, 0xBEB0C6F7A0B5ED8D
%18 = or i1 %16, %17
br i1 %18, label %9, label %19
19: ; preds = %9, %0
%20 = phi double [ 1.000000e+00, %0 ], [ %13, %9 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %20)
ret i32 0
}