#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 */
int /*<<< orphan*/ file_write(double, char *);
int /*<<< orphan*/ report(double);
double sqrt(double);
void test_sqrt() {
  double x, step;
  for (x = 0.0; x <= 10.0; x += 0.01) {
    report(x);
    file_write(x, "x_5");
    file_write(sqrt(x), "sqrt_x");
  }
}


x86 assembly (clang, -O0):
<test_sqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeb8(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     119b <test_sqrt+0x6b>
movsd  -0x8(%rbp),%xmm0
call   1050 <report@plt>
movsd  -0x8(%rbp),%xmm0
lea    0xea7(%rip),%rdi
call   1040 <file_write@plt>
movsd  -0x8(%rbp),%xmm0
call   1030 <sqrt@plt>
lea    0xe95(%rip),%rdi
call   1040 <file_write@plt>
movsd  0xe7c(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1140 <test_sqrt+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sqrt>:
push   %r14
push   %rbx
push   %rax
lea    0xedd(%rip),%r14
lea    0xeda(%rip),%rbx
xorpd  %xmm1,%xmm1
jmp    1178 <test_sqrt+0x48>
nopl   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
mov    %rbx,%rdi
call   1040 <file_write@plt>
movsd  (%rsp),%xmm1
addsd  0xe96(%rip),%xmm1
movsd  0xe96(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11a8 <test_sqrt+0x78>
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1050 <report@plt>
movsd  (%rsp),%xmm0
mov    %r14,%rdi
call   1040 <file_write@plt>
movsd  (%rsp),%xmm0
ucomisd 0xe70(%rip),%xmm0
jb     1150 <test_sqrt+0x20>
sqrtsd %xmm0,%xmm0
jmp    1155 <test_sqrt+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"x_5\00"
@.str.1 = [7 x i8] c"sqrt_x\00"
define void @test_sqrt() {
%1 = alloca double
%2 = alloca double
store double 0.000000e+00, double* %1
br label %3
3: ; preds = %14, %0
%4 = load double, double* %1
%5 = fcmp ole double %4, 1.000000e+01
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = load double, double* %1
%8 = call i32 @report(double %7)
%9 = load double, double* %1
%10 = call i32 @file_write(double %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = load double, double* %1
%12 = call double @sqrt(double %11)
%13 = call i32 @file_write(double %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %6
%15 = load double, double* %1
%16 = fadd double %15, 1.000000e-02
store double %16, double* %1
br label %3
17: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"x_5\00"
@.str.1 = [7 x i8] c"sqrt_x\00"
define void @test_sqrt() {
br label %1
1: ; preds = %0, %1
%2 = phi double [ 0.000000e+00, %0 ], [ %7, %1 ]
%3 = tail call i32 @report(double %2)
%4 = tail call i32 @file_write(double %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = tail call double @sqrt(double %2)
%6 = tail call i32 @file_write(double %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = fadd double %2, 1.000000e-02
%8 = fcmp ugt double %7, 1.000000e+01
br i1 %8, label %9, label %1
9: ; preds = %1
ret void
}