#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 EXIT_FAILURE;
int EXIT_SUCCESS;
double atof(char *);
size_t atoi(char *);
double floor(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
double mySqrt(double, double, int /*<<< orphan*/, size_t);
double sqrt(double);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  double x, a;
  size_t n;
  if (argc != 3) {
    fprintf(stderr, "sqrt number precision\n");
    return EXIT_FAILURE;
  }
  x = atof(argv[1]);
  n = atoi(argv[2]);
  a = floor(x - 1);
  fprintf(stdout, "mySqrt(%f) = %f ; sqrt(%f) = %f\n", x, mySqrt(a, x, 0, n), x,
          sqrt(x));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a8 <main+0x48>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1259 <main+0xf9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x28(%rbp),%rsi
xor    %edi,%edi
call   1040 <mySqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <sqrt@plt>
mov    -0x44(%rbp),%edi
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
lea    0xdd9(%rip),%rsi
mov    $0x4,%al
call   1050 <fprintf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    11cf <main+0x6f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbx
movsd  0xe6f(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1080 <floor@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%ebp
movsd  0x8(%rsp),%xmm1
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <mySqrt@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     11ef <main+0x8f>
sqrtsd %xmm2,%xmm3
jmp    120e <main+0xae>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2deb(%rip),%rax
jmp    1229 <main+0xc9>
movapd %xmm2,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1070 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm3
lea    0xe0a(%rip),%rsi
mov    %ebp,%edi
movapd %xmm2,%xmm0
mov    $0x4,%al
call   1050 <fprintf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"sqrt number precision\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [33 x i8] c"mySqrt(%f) = %f ; sqrt(%f) = %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
store i32 %14, i32* %3
br label %38
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call double @atof(i8* %18)
store double %19, double* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i64 @atoi(i8* %22)
store i64 %23, i64* %8
%24 = load double, double* %6
%25 = fsub double %24, 1.000000e+00
%26 = call double @llvm.floor.f64(double %25)
store double %26, double* %7
%27 = load i32, i32* @stdout
%28 = load double, double* %6
%29 = load double, double* %7
%30 = load double, double* %6
%31 = load i64, i64* %8
%32 = call double @mySqrt(double %29, double %30, i32 0, i64 %31)
%33 = load double, double* %6
%34 = load double, double* %6
%35 = call double @sqrt(double %34)
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), double %28, double %32, double %33, double %35)
%37 = load i32, i32* @EXIT_SUCCESS
store i32 %37, i32* %3
br label %38
38: ; preds = %15, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"sqrt number precision\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [33 x i8] c"mySqrt(%f) = %f ; sqrt(%f) = %f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %20
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call double @atof(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i64 @atoi(i8* %12)
%14 = fadd double %10, -1.000000e+00
%15 = tail call double @llvm.floor.f64(double %14)
%16 = load i32, i32* @stdout
%17 = tail call double @mySqrt(double %15, double %10, i32 0, i64 %13)
%18 = tail call double @sqrt(double %10)
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), double %10, double %17, double %10, double %18)
br label %20
20: ; preds = %7, %4
%21 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %7 ]
%22 = load i32, i32* %21
ret i32 %22
}