#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 fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, double *);
int main() {
  double a, eps, xp, xn;
  printf("a, eps = ");
  scanf("%lf%lf", &a, &eps);
  xn = 1.0;
  do {
    xp = xn;
    xn = (xp + a / xp) / 2;
  } while (fabs(xn - xp) >= eps);
  printf("Korijen iz a = %15.10lf\n", xn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movsd  0xea7(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe73(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    115e <main+0x3e>
movsd  -0x28(%rbp),%xmm0
lea    0xe79(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xef5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm1
movsd  0xeaa(%rip),%xmm0
movsd  0x8(%rsp),%xmm2
movsd  0xea4(%rip),%xmm3
movapd 0xea4(%rip),%xmm4
nopl   0x0(%rax)
movapd %xmm0,%xmm5
movapd %xmm1,%xmm0
divsd  %xmm5,%xmm0
addsd  %xmm5,%xmm0
mulsd  %xmm3,%xmm0
movapd %xmm0,%xmm6
subsd  %xmm5,%xmm6
andpd  %xmm4,%xmm6
ucomisd %xmm2,%xmm6
jae    1170 <main+0x50>
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"a, eps = \00"
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [25 x i8] c"Korijen iz a = %15.10lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
store double 1.000000e+00, double* %5
br label %8
8: ; preds = %16, %0
%9 = load double, double* %5
store double %9, double* %4
%10 = load double, double* %4
%11 = load double, double* %2
%12 = load double, double* %4
%13 = fdiv double %11, %12
%14 = fadd double %10, %13
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %5
br label %16
16: ; preds = %8
%17 = load double, double* %5
%18 = load double, double* %4
%19 = fsub double %17, %18
%20 = call double @llvm.fabs.f64(double %19)
%21 = load double, double* %3
%22 = fcmp oge double %20, %21
br i1 %22, label %8, label %23
23: ; preds = %16
%24 = load double, double* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"a, eps = \00"
@.str.1 = [7 x i8] c"%lf%lf\00"
@.str.2 = [25 x i8] c"Korijen iz a = %15.10lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%7 = load double, double* %1
%8 = load double, double* %2
br label %9
9: ; preds = %9, %0
%10 = phi double [ 1.000000e+00, %0 ], [ %13, %9 ]
%11 = fdiv double %7, %10
%12 = fadd double %10, %11
%13 = fmul double %12, 5.000000e-01
%14 = fsub double %13, %10
%15 = call double @llvm.fabs.f64(double %14)
%16 = fcmp ult double %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), double %13)
ret i32 0
}