#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 f(float, float);
float fi(float);
int /*<<< orphan*/ printf(char *, float, float);
int /*<<< orphan*/ scanf(char *, float *);
int main() {
  const int N = 5;
  float a = 9;
  float x = a;
  scanf("%f", &a);
  for (int i = 0; i < N; i++) {
    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)
movl   $0x5,-0x8(%rbp)
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11de <main+0x9e>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <f@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x10(%rbp),%xmm0
call   1050 <fi@plt>
movss  -0x1c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x18(%rbp),%xmm0
divss  %xmm2,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <main+0x44>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
lea    0xe18(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x41100000,0x14(%rsp)
41
lea    0xeb1(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1060 <scanf@plt>
movss  0x14(%rsp),%xmm1
movss  0xe95(%rip),%xmm0
call   1030 <f@plt>
movss  %xmm0,0xc(%rsp)
movss  0xe82(%rip),%xmm0
call   1050 <fi@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xe6b(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm1
call   1030 <f@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <fi@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm1
call   1030 <f@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <fi@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm1
call   1030 <f@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <fi@plt>
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x14(%rsp),%xmm1
call   1030 <f@plt>
movss  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1050 <fi@plt>
movss  0x10(%rsp),%xmm2
divss  %xmm0,%xmm2
movss  0xc(%rsp),%xmm1
subss  %xmm2,%xmm1
movss  0x14(%rsp),%xmm0
lea    0xd89(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
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 i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %2
store float 9.000000e+00, float* %3
%6 = load float, float* %3
store float %6, float* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %3)
store i32 0, i32* %5
br label %8
8: ; preds = %20, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load float, float* %4
%13 = load float, float* %4
%14 = load float, float* %3
%15 = call float @f(float %13, float %14)
%16 = load float, float* %4
%17 = call float @fi(float %16)
%18 = fdiv float %15, %17
%19 = fsub float %12, %18
store float %19, float* %4
br label %20
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
%24 = load float, float* %3
%25 = load float, float* %4
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %24, float %25)
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 = bitcast float* %1 to i8*
store float 9.000000e+00, float* %1
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %1)
%4 = load float, float* %1
%5 = call float @f(float 9.000000e+00, float %4)
%6 = call float @fi(float 9.000000e+00)
%7 = fdiv float %5, %6
%8 = fsub float 9.000000e+00, %7
%9 = load float, float* %1
%10 = call float @f(float %8, float %9)
%11 = call float @fi(float %8)
%12 = fdiv float %10, %11
%13 = fsub float %8, %12
%14 = load float, float* %1
%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* %1
%20 = call float @f(float %18, float %19)
%21 = call float @fi(float %18)
%22 = fdiv float %20, %21
%23 = fsub float %18, %22
%24 = load float, float* %1
%25 = call float @f(float %23, float %24)
%26 = call float @fi(float %23)
%27 = fdiv float %25, %26
%28 = fsub float %23, %27
%29 = load float, float* %1
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %29, float %28)
ret i32 0
}