#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 */
typedef int uint32_t;

/* Variables and functions */
float INFINITY;
scalar_t__ UINT32_C(int);
int float_as_uint(float);
float fmul_native(float, float);
float fsub_native(float, float);
float uint_as_float(scalar_t__);
float fsqr_soft(float a) {
  if (a == INFINITY)
    return a;
  float ahalf = 0.5f * a;
  uint32_t bin = float_as_uint(a);
  float x = uint_as_float(UINT32_C(0x5f400000) - (bin >> 1));
  x = fmul_native(x,
                  (fsub_native(1.5f, fmul_native(fmul_native(ahalf, x), x))));
  x = fmul_native(x,
                  (fsub_native(1.5f, fmul_native(fmul_native(ahalf, x), x))));
  x = fmul_native(x,
                  (fsub_native(1.5f, fmul_native(fmul_native(ahalf, x), x))));
  return fmul_native(a, x);
}


x86 assembly (clang, -O0):
<fsqr_soft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
mov    0x2e7f(%rip),%rax
ucomiss (%rax),%xmm0
jne    1187 <fsqr_soft+0x37>
jp     1187 <fsqr_soft+0x37>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12ab <fsqr_soft+0x15b>
movss  0xe75(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <float_as_uint@plt>
mov    %eax,-0x10(%rbp)
mov    $0x5f400000,%edi
call   1060 <UINT32_C@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
cltq
sub    %rax,%rdi
call   1050 <uint_as_float@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xe0a(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
call   1070 <fmul_native@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xdc5(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
call   1070 <fmul_native@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xd80(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
call   1070 <fmul_native@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1070 <fmul_native@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsqr_soft>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e8c(%rip),%rax
movss  (%rax),%xmm1
ucomiss %xmm0,%xmm1
jne    116d <fsqr_soft+0x1d>
jp     116d <fsqr_soft+0x1d>
add    $0x10,%rsp
pop    %rbx
ret
movss  0xe8b(%rip),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <float_as_uint@plt>
mov    %eax,%ebx
mov    $0x5f400000,%edi
call   1060 <UINT32_C@plt>
sar    %ebx
movslq %ebx,%rcx
sub    %rcx,%rax
mov    %rax,%rdi
call   1050 <uint_as_float@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1070 <fmul_native@plt>
movss  0x4(%rsp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xe34(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1070 <fmul_native@plt>
movss  0x4(%rsp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xdf7(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1070 <fmul_native@plt>
movss  0x4(%rsp),%xmm1
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xdba(%rip),%xmm0
call   1030 <fsub_native@plt>
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
call   1070 <fmul_native@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1070 <fmul_native@plt>

LLVM IR (-O0):
@INFINITY = global float 0.000000e+00
define float @fsqr_soft(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca float
store float %0, float* %3
%7 = load float, float* %3
%8 = load float, float* @INFINITY
%9 = fcmp oeq float %7, %8
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load float, float* %3
store float %11, float* %2
br label %50
12: ; preds = %1
%13 = load float, float* %3
%14 = fmul float 5.000000e-01, %13
store float %14, float* %4
%15 = load float, float* %3
%16 = call i32 @float_as_uint(float %15)
store i32 %16, i32* %5
%17 = call i64 @UINT32_C(i32 1598029824)
%18 = load i32, i32* %5
%19 = ashr i32 %18, 1
%20 = sext i32 %19 to i64
%21 = sub nsw i64 %17, %20
%22 = call float @uint_as_float(i64 %21)
store float %22, float* %6
%23 = load float, float* %6
%24 = load float, float* %4
%25 = load float, float* %6
%26 = call float @fmul_native(float %24, float %25)
%27 = load float, float* %6
%28 = call float @fmul_native(float %26, float %27)
%29 = call float @fsub_native(float 1.500000e+00, float %28)
%30 = call float @fmul_native(float %23, float %29)
store float %30, float* %6
%31 = load float, float* %6
%32 = load float, float* %4
%33 = load float, float* %6
%34 = call float @fmul_native(float %32, float %33)
%35 = load float, float* %6
%36 = call float @fmul_native(float %34, float %35)
%37 = call float @fsub_native(float 1.500000e+00, float %36)
%38 = call float @fmul_native(float %31, float %37)
store float %38, float* %6
%39 = load float, float* %6
%40 = load float, float* %4
%41 = load float, float* %6
%42 = call float @fmul_native(float %40, float %41)
%43 = load float, float* %6
%44 = call float @fmul_native(float %42, float %43)
%45 = call float @fsub_native(float 1.500000e+00, float %44)
%46 = call float @fmul_native(float %39, float %45)
store float %46, float* %6
%47 = load float, float* %3
%48 = load float, float* %6
%49 = call float @fmul_native(float %47, float %48)
store float %49, float* %2
br label %50
50: ; preds = %12, %10
%51 = load float, float* %2
ret float %51
}

LLVM IR (-O2):
@INFINITY = global float 0.000000e+00
define float @fsqr_soft(float %0) {
%2 = load float, float* @INFINITY
%3 = fcmp oeq float %2, %0
br i1 %3, label %25, label %4
4: ; preds = %1
%5 = fmul float %0, 5.000000e-01
%6 = tail call i32 @float_as_uint(float %0)
%7 = tail call i64 @UINT32_C(i32 1598029824)
%8 = ashr i32 %6, 1
%9 = sext i32 %8 to i64
%10 = sub nsw i64 %7, %9
%11 = tail call float @uint_as_float(i64 %10)
%12 = tail call float @fmul_native(float %5, float %11)
%13 = tail call float @fmul_native(float %12, float %11)
%14 = tail call float @fsub_native(float 1.500000e+00, float %13)
%15 = tail call float @fmul_native(float %11, float %14)
%16 = tail call float @fmul_native(float %5, float %15)
%17 = tail call float @fmul_native(float %16, float %15)
%18 = tail call float @fsub_native(float 1.500000e+00, float %17)
%19 = tail call float @fmul_native(float %15, float %18)
%20 = tail call float @fmul_native(float %5, float %19)
%21 = tail call float @fmul_native(float %20, float %19)
%22 = tail call float @fsub_native(float 1.500000e+00, float %21)
%23 = tail call float @fmul_native(float %19, float %22)
%24 = tail call float @fmul_native(float %0, float %23)
br label %25
25: ; preds = %1, %4
%26 = phi float [ %24, %4 ], [ %0, %1 ]
ret float %26
}