#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 fabs(float);
int /*<<< orphan*/ printf(char *, float, float, float);
float rsqrt(unsigned int);
int sqrt(unsigned int);
int main(void) {
  unsigned i;
  float x, y, z;
  for (i = 0; i <= 10000; i++) {
    x = 1 / sqrt(i);
    y = rsqrt(i);
    z = fabs(x - y);
    printf("%.6f %.6f %.6f\n", x, y, z);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
ja     11c8 <main+0x88>
mov    -0x8(%rbp),%edi
call   1060 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <rsqrt@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
lea    0xece(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1050 <sqrt@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %ebp,%edi
call   1030 <rsqrt@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
andps  0xe74(%rip),%xmm2
mov    %rbx,%rdi
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    $0x2711,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"%.6f %.6f %.6f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %2
%8 = icmp ule i32 %7, 10000
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %2
%11 = call i32 @sqrt(i32 %10)
%12 = sdiv i32 1, %11
%13 = sitofp i32 %12 to float
store float %13, float* %3
%14 = load i32, i32* %2
%15 = call float @rsqrt(i32 %14)
store float %15, float* %4
%16 = load float, float* %3
%17 = load float, float* %4
%18 = fsub float %16, %17
%19 = call float @fabs(float %18)
store float %19, float* %5
%20 = load float, float* %3
%21 = load float, float* %4
%22 = load float, float* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %20, float %21, float %22)
br label %24
24: ; preds = %9
%25 = load i32, i32* %2
%26 = add i32 %25, 1
store i32 %26, i32* %2
br label %6
27: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"%.6f %.6f %.6f\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %12, %1 ]
%3 = tail call i32 @sqrt(i32 %2)
%4 = add i32 %3, 1
%5 = icmp ult i32 %4, 3
%6 = select i1 %5, i32 %3, i32 0
%7 = sitofp i32 %6 to float
%8 = tail call float @rsqrt(i32 %2)
%9 = fsub float %7, %8
%10 = tail call float @llvm.fabs.f32(float %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), float %7, float %8, float %10)
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 10001
br i1 %13, label %14, label %1
14: ; preds = %1
ret i32 0
}