#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 fabs(double);
int /*<<< orphan*/ printf(char *, double);
int main() {
  double x = 1;
  double num = 121;
  double y = 1.0 / 2 * (x + num / x);
  while (fabs(y - x) > 1e-5) {
    x = y;
    y = 1.0 / 2 * (x + num / x);
  }
  printf("%.3lf\n", y);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c5 <main+0xa5>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    116d <main+0x4d>
movsd  -0x20(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xed7(%rip),%xmm0
call   1040 <fabs@plt>
test   %eax,%eax
jle    1175 <main+0x55>
movsd  0xece(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movsd  0xec8(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xec0(%rip),%xmm0
movsd  %xmm0,(%rsp)
subsd  %xmm1,%xmm0
call   1040 <fabs@plt>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm1
test   %eax,%eax
jg     1140 <main+0x20>
jmp    117d <main+0x5d>
movsd  0xe8b(%rip),%xmm0
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%.3lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 1.000000e+00, double* %2
store double 1.210000e+02, double* %3
%5 = load double, double* %2
%6 = load double, double* %3
%7 = load double, double* %2
%8 = fdiv double %6, %7
%9 = fadd double %5, %8
%10 = fmul double 5.000000e-01, %9
store double %10, double* %4
br label %11
11: ; preds = %18, %0
%12 = load double, double* %4
%13 = load double, double* %2
%14 = fsub double %12, %13
%15 = call i32 @fabs(double %14)
%16 = sitofp i32 %15 to double
%17 = fcmp ogt double %16, 1.000000e-05
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = load double, double* %4
store double %19, double* %2
%20 = load double, double* %2
%21 = load double, double* %3
%22 = load double, double* %2
%23 = fdiv double %21, %22
%24 = fadd double %20, %23
%25 = fmul double 5.000000e-01, %24
store double %25, double* %4
br label %11
26: ; preds = %11
%27 = load double, double* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %27)
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.3lf\0A\00"
define i32 @main() {
%1 = tail call i32 @fabs(double 6.000000e+01)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %11
3: ; preds = %0, %3
%4 = phi double [ %7, %3 ], [ 6.100000e+01, %0 ]
%5 = fdiv double 1.210000e+02, %4
%6 = fadd double %4, %5
%7 = fmul double %6, 5.000000e-01
%8 = fsub double %7, %4
%9 = tail call i32 @fabs(double %8)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %3, %0
%12 = phi double [ 6.100000e+01, %0 ], [ %7, %3 ]
%13 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %12)
ret i32 0
}