#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 __divsf3(float, float);
float __floatsisf(int);
float __mulsf3(float, float);
float __subsf3(float, float);
float FP_Sqrt(float a) {
  float x1, y1, x2, y2, x3;
  long i;
  x1 = __floatsisf(1);
  y1 = __subsf3(__mulsf3(x1, x1), a);
  x2 = __floatsisf(100);
  y2 = __subsf3(__mulsf3(x2, x2), a);
  for (i = 0; i < 10; ++i) {
    if ((*(unsigned long *)&(y1)) == (*(unsigned long *)&(y2)))
      return x2;
    x3 = __subsf3(x2,
                  __divsf3(__mulsf3(__subsf3(x1, x2), y2), __subsf3(y1, y2)));
    x1 = x2;
    y1 = y2;
    x2 = x3;
    y2 = __subsf3(__mulsf3(x2, x2), a);
  }
  return x2;
}


x86 assembly (clang, -O0):
<FP_Sqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
mov    $0x1,%edi
call   1040 <__floatsisf@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1060 <__mulsf3@plt>
movss  -0x8(%rbp),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,-0x10(%rbp)
mov    $0x64,%edi
call   1040 <__floatsisf@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1060 <__mulsf3@plt>
movss  -0x8(%rbp),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0xa,-0x28(%rbp)
jge    127a <FP_Sqrt+0x13a>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11d7 <FP_Sqrt+0x97>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1284 <FP_Sqrt+0x144>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1050 <__subsf3@plt>
movss  -0x18(%rbp),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
call   1050 <__subsf3@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
call   1030 <__divsf3@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
call   1050 <__subsf3@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1060 <__mulsf3@plt>
movss  -0x8(%rbp),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11af <FP_Sqrt+0x6f>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FP_Sqrt>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movss  %xmm0,0xc(%rsp)
mov    $0x1,%edi
call   1040 <__floatsisf@plt>
movss  %xmm0,0x8(%rsp)
movaps %xmm0,%xmm1
call   1060 <__mulsf3@plt>
movss  0xc(%rsp),%xmm1
call   1050 <__subsf3@plt>
movss  %xmm0,0x18(%rsp)
mov    $0x64,%edi
call   1040 <__floatsisf@plt>
movss  %xmm0,0x4(%rsp)
movaps %xmm0,%xmm1
call   1060 <__mulsf3@plt>
movss  0xc(%rsp),%xmm1
call   1050 <__subsf3@plt>
movss  0x4(%rsp),%xmm1
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
mov    $0xa,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rbx
cmp    %rbx,%rax
je     125d <FP_Sqrt+0x11d>
mov    %ebx,0x4(%rsp)
mov    %eax,0x24(%rsp)
movss  %xmm1,0x8(%rsp)
call   1050 <__subsf3@plt>
movss  0x4(%rsp),%xmm1
call   1060 <__mulsf3@plt>
movss  %xmm0,0x20(%rsp)
movss  0x24(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
call   1050 <__subsf3@plt>
movaps %xmm0,%xmm1
movss  0x20(%rsp),%xmm0
call   1030 <__divsf3@plt>
movaps %xmm0,%xmm1
movss  0x8(%rsp),%xmm0
call   1050 <__subsf3@plt>
movss  %xmm0,0x4(%rsp)
mov    %ebx,0x18(%rsp)
movaps %xmm0,%xmm1
call   1060 <__mulsf3@plt>
movss  0xc(%rsp),%xmm1
call   1050 <__subsf3@plt>
movss  0x4(%rsp),%xmm1
movss  %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
add    $0xffffffffffffffff,%r14
jne    11c0 <FP_Sqrt+0x80>
movaps %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float @FP_Sqrt(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i64
store float %0, float* %3
%10 = call float @__floatsisf(i32 1)
store float %10, float* %4
%11 = load float, float* %4
%12 = load float, float* %4
%13 = call float @__mulsf3(float %11, float %12)
%14 = load float, float* %3
%15 = call float @__subsf3(float %13, float %14)
store float %15, float* %5
%16 = call float @__floatsisf(i32 100)
store float %16, float* %6
%17 = load float, float* %6
%18 = load float, float* %6
%19 = call float @__mulsf3(float %17, float %18)
%20 = load float, float* %3
%21 = call float @__subsf3(float %19, float %20)
store float %21, float* %7
store i64 0, i64* %9
br label %22
22: ; preds = %53, %1
%23 = load i64, i64* %9
%24 = icmp slt i64 %23, 10
br i1 %24, label %25, label %56
25: ; preds = %22
%26 = bitcast float* %5 to i64*
%27 = load i64, i64* %26
%28 = bitcast float* %7 to i64*
%29 = load i64, i64* %28
%30 = icmp eq i64 %27, %29
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load float, float* %6
store float %32, float* %2
br label %58
33: ; preds = %25
%34 = load float, float* %6
%35 = load float, float* %4
%36 = load float, float* %6
%37 = call float @__subsf3(float %35, float %36)
%38 = load float, float* %7
%39 = call float @__mulsf3(float %37, float %38)
%40 = load float, float* %5
%41 = load float, float* %7
%42 = call float @__subsf3(float %40, float %41)
%43 = call float @__divsf3(float %39, float %42)
%44 = call float @__subsf3(float %34, float %43)
store float %44, float* %8
%45 = load float, float* %6
store float %45, float* %4
%46 = load float, float* %7
store float %46, float* %5
%47 = load float, float* %8
store float %47, float* %6
%48 = load float, float* %6
%49 = load float, float* %6
%50 = call float @__mulsf3(float %48, float %49)
%51 = load float, float* %3
%52 = call float @__subsf3(float %50, float %51)
store float %52, float* %7
br label %53
53: ; preds = %33
%54 = load i64, i64* %9
%55 = add nsw i64 %54, 1
store i64 %55, i64* %9
br label %22
56: ; preds = %22
%57 = load float, float* %6
store float %57, float* %2
br label %58
58: ; preds = %56, %31
%59 = load float, float* %2
ret float %59
}

LLVM IR (-O2):
define float @FP_Sqrt(float %0) {
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %2 to i8*
%5 = bitcast float* %3 to i8*
%6 = tail call float @__floatsisf(i32 1)
%7 = tail call float @__mulsf3(float %6, float %6)
%8 = tail call float @__subsf3(float %7, float %0)
store float %8, float* %2
%9 = tail call float @__floatsisf(i32 100)
%10 = tail call float @__mulsf3(float %9, float %9)
%11 = tail call float @__subsf3(float %10, float %0)
store float %11, float* %3
%12 = bitcast float* %2 to i64*
%13 = bitcast float* %3 to i64*
%14 = bitcast float* %2 to i32*
br label %15
15: ; preds = %1, %24
%16 = phi i64 [ 0, %1 ], [ %34, %24 ]
%17 = phi float [ %9, %1 ], [ %31, %24 ]
%18 = phi float [ %6, %1 ], [ %17, %24 ]
%19 = load i64, i64* %12
%20 = load i64, i64* %13
%21 = icmp eq i64 %19, %20
%22 = trunc i64 %20 to i32
%23 = bitcast i32 %22 to float
br i1 %21, label %36, label %24
24: ; preds = %15
%25 = trunc i64 %19 to i32
%26 = bitcast i32 %25 to float
%27 = tail call float @__subsf3(float %18, float %17)
%28 = tail call float @__mulsf3(float %27, float %23)
%29 = tail call float @__subsf3(float %26, float %23)
%30 = tail call float @__divsf3(float %28, float %29)
%31 = tail call float @__subsf3(float %17, float %30)
store i32 %22, i32* %14
%32 = tail call float @__mulsf3(float %31, float %31)
%33 = tail call float @__subsf3(float %32, float %0)
store float %33, float* %3
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, 10
br i1 %35, label %36, label %15
36: ; preds = %24, %15
%37 = phi float [ %31, %24 ], [ %17, %15 ]
ret float %37
}