#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 pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  int i;
  double num, x, x1;
  printf("please input a number: ");
  scanf("%lf", &num);
  x = 5;
  for (i = 0; i < 100; i++) {
    x1 = ((num - 1) * pow(x, 2.0) + num) / (num * x);
    if (x - x1 < 0.001) {
      break;
    }
    x = x1;
  }
  printf("ans. => %f\n", x1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    1204 <main+0xd4>
movsd  -0x10(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe72(%rip),%xmm1
call   1050 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe2b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ec <main+0xbc>
jmp    1204 <main+0xd4>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x41>
movsd  -0x20(%rbp),%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm1
movsd  0xeb5(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0xeb1(%rip),%xmm0
mov    $0x63,%eax
movsd  0xeac(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm4
mulsd  %xmm0,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm4,%xmm5
mulsd  %xmm1,%xmm5
divsd  %xmm5,%xmm0
subsd  %xmm0,%xmm4
sub    $0x1,%eax
setb   %cl
ucomisd %xmm4,%xmm3
ja     11a0 <main+0x80>
test   %cl,%cl
je     1170 <main+0x50>
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"please input a number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"ans. => %f\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
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 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* %3)
store double 5.000000e+00, double* %4
store i32 0, i32* %2
br label %8
8: ; preds = %29, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load double, double* %3
%13 = fsub double %12, 1.000000e+00
%14 = load double, double* %4
%15 = call double @pow(double %14, double 2.000000e+00)
%16 = load double, double* %3
%17 = call double @llvm.fmuladd.f64(double %13, double %15, double %16)
%18 = load double, double* %3
%19 = load double, double* %4
%20 = fmul double %18, %19
%21 = fdiv double %17, %20
store double %21, double* %5
%22 = load double, double* %4
%23 = load double, double* %5
%24 = fsub double %22, %23
%25 = fcmp olt double %24, 1.000000e-03
br i1 %25, label %26, label %27
26: ; preds = %11
br label %32
27: ; preds = %11
%28 = load double, double* %5
store double %28, double* %4
br label %29
29: ; preds = %27
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %8
32: ; preds = %26, %8
%33 = load double, double* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"please input a number: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [12 x i8] c"ans. => %f\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 ([24 x i8], [24 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 = fadd double %5, -1.000000e+00
br label %7
7: ; preds = %7, %0
%8 = phi double [ 5.000000e+00, %0 ], [ %13, %7 ]
%9 = phi i32 [ 0, %0 ], [ %16, %7 ]
%10 = fmul double %8, %8
%11 = call double @llvm.fmuladd.f64(double %6, double %10, double %5)
%12 = fmul double %8, %5
%13 = fdiv double %11, %12
%14 = fsub double %8, %13
%15 = fcmp olt double %14, 1.000000e-03
%16 = add nuw nsw i32 %9, 1
%17 = icmp eq i32 %16, 100
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), double %13)
ret i32 0
}