#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 */
float absf(float);
float f(float, float);
float fi(float);
int /*<<< orphan*/ printf(char *, float, float);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  float N = 0.01f;
  float a = 9;
  float x = a;
  scanf("%f", &a);
  scanf("%f", &N);
  while (absf(f(x, a)) > N) {
    x = x - f(x, a) / fi(x);
  }
  printf("sqrt(%f)=%f\n", a, x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xe9d(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe8c(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe7e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe6e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <f@plt>
call   1050 <absf@plt>
ucomiss -0x8(%rbp),%xmm0
jbe    1208 <main+0xb8>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <f@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
call   1060 <fi@plt>
movss  -0x18(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x14(%rbp),%xmm0
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11a3 <main+0x53>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x3c23d70a,0x8(%rsp)
3c
movl   $0x41100000,0x4(%rsp)
41
lea    0xe98(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
movss  0x4(%rsp),%xmm1
movss  0xe6c(%rip),%xmm0
movss  %xmm0,(%rsp)
call   1030 <f@plt>
call   1050 <absf@plt>
ucomiss 0x8(%rsp),%xmm0
jbe    120f <main+0xbf>
movss  0xe4e(%rip),%xmm0
movss  %xmm0,(%rsp)
nopw   0x0(%rax,%rax,1)
movss  0x4(%rsp),%xmm1
movss  (%rsp),%xmm0
call   1030 <f@plt>
movss  %xmm0,0xc(%rsp)
movss  (%rsp),%xmm0
call   1060 <fi@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  (%rsp),%xmm0
subss  %xmm1,%xmm0
movss  0x4(%rsp),%xmm1
movss  %xmm0,(%rsp)
call   1030 <f@plt>
call   1050 <absf@plt>
ucomiss 0x8(%rsp),%xmm0
ja     11c0 <main+0x70>
movss  0x4(%rsp),%xmm0
lea    0xdeb(%rip),%rdi
movss  (%rsp),%xmm1
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [13 x i8] c"sqrt(%f)=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store float 0x3F847AE140000000, float* %2
store float 9.000000e+00, float* %3
%5 = load float, float* %3
store float %5, float* %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %2)
br label %8
8: ; preds = %15, %0
%9 = load float, float* %4
%10 = load float, float* %3
%11 = call float @f(float %9, float %10)
%12 = call float @absf(float %11)
%13 = load float, float* %2
%14 = fcmp ogt float %12, %13
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = load float, float* %4
%17 = load float, float* %4
%18 = load float, float* %3
%19 = call float @f(float %17, float %18)
%20 = load float, float* %4
%21 = call float @fi(float %20)
%22 = fdiv float %19, %21
%23 = fsub float %16, %22
store float %23, float* %4
br label %8
24: ; preds = %8
%25 = load float, float* %3
%26 = load float, float* %4
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %25, float %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [13 x i8] c"sqrt(%f)=%f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
store float 0x3F847AE140000000, float* %1
%4 = bitcast float* %2 to i8*
store float 9.000000e+00, float* %2
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %2)
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%7 = load float, float* %2
%8 = call float @f(float 9.000000e+00, float %7)
%9 = call float @absf(float %8)
%10 = load float, float* %1
%11 = fcmp ogt float %9, %10
br i1 %11, label %12, label %24
12: ; preds = %0, %12
%13 = phi float [ %18, %12 ], [ 9.000000e+00, %0 ]
%14 = load float, float* %2
%15 = call float @f(float %13, float %14)
%16 = call float @fi(float %13)
%17 = fdiv float %15, %16
%18 = fsub float %13, %17
%19 = load float, float* %2
%20 = call float @f(float %18, float %19)
%21 = call float @absf(float %20)
%22 = load float, float* %1
%23 = fcmp ogt float %21, %22
br i1 %23, label %12, label %24
24: ; preds = %12, %0
%25 = phi float [ 9.000000e+00, %0 ], [ %18, %12 ]
%26 = load float, float* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %26, float %25)
ret i32 0
}