#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*/ printf(char *, long double, long double, ...);
long double sqrtl(long double);
int main(void) {
  long double x = 17999999998987831969ULL;
  long double sr = sqrtl(x);
  unsigned long long z = ((unsigned long long)sr) * ((unsigned long long)sr);
  printf("sqrt(%Lf) == %Lf\n", x, sr);
  printf("%Lf * %Lf == %llu\n", sr, sr, z);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
fldt   0xecb(%rip)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <sqrtl@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
flds   0xebf(%rip)
fucomi %st(1),%st
setbe  %al
fldz
fcmovbe %st(1),%st
fstp   %st(1)
fsubrp %st,%st(1)
fnstcw -0x42(%rbp)
movzwl -0x42(%rbp),%ecx
or     $0xc00,%ecx
mov    %cx,-0x44(%rbp)
fldcw  -0x44(%rbp)
fistpll -0x40(%rbp)
fldcw  -0x42(%rbp)
movzbl %al,%eax
mov    %eax,%ecx
shl    $0x3f,%rcx
mov    -0x40(%rbp),%rax
xor    %rcx,%rax
imul   %rax,%rax
mov    %rax,-0x38(%rbp)
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
fldt   -0x30(%rbp)
fld    %st(0)
mov    -0x38(%rbp),%rsi
mov    %rsp,%rax
fxch   %st(1)
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
fldt   0xed5(%rip)
fld    %st(0)
fstpt  0x44(%rsp)
fstpt  (%rsp)
call   1040 <sqrtl@plt>
flds   0xed1(%rip)
xor    %ebx,%ebx
fxch   %st(1)
fucomi %st(1),%st
setae  %bl
fldz
fcmovnb %st(2),%st
fstp   %st(2)
fsub   %st,%st(1)
fld    %st(0)
fstpt  0x38(%rsp)
fnstcw 0x2c(%rsp)
movzwl 0x2c(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x2e(%rsp)
fldcw  0x2e(%rsp)
fxch   %st(1)
fistpll 0x30(%rsp)
fldcw  0x2c(%rsp)
shl    $0x3f,%rbx
xor    0x30(%rsp),%rbx
imul   %rbx,%rbx
fstpt  0x10(%rsp)
fldt   0x44(%rsp)
fstpt  (%rsp)
lea    0xe7e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
fldt   0x38(%rsp)
fld    %st(0)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0xe75(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"sqrt(%Lf) == %Lf\0A\00"
@.str.1 = [19 x i8] c"%Lf * %Lf == %llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca i64
store i32 0, i32* %1
store x86_fp80 0xK403EF9CCD8A188B38AA1, x86_fp80* %2
%5 = load x86_fp80, x86_fp80* %2
%6 = call x86_fp80 @sqrtl(x86_fp80 %5)
store x86_fp80 %6, x86_fp80* %3
%7 = load x86_fp80, x86_fp80* %3
%8 = fptoui x86_fp80 %7 to i64
%9 = load x86_fp80, x86_fp80* %3
%10 = fptoui x86_fp80 %9 to i64
%11 = mul i64 %8, %10
store i64 %11, i64* %4
%12 = load x86_fp80, x86_fp80* %2
%13 = load x86_fp80, x86_fp80* %3
%14 = call i32 (i8*, x86_fp80, x86_fp80, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), x86_fp80 %12, x86_fp80 %13)
%15 = load x86_fp80, x86_fp80* %3
%16 = load x86_fp80, x86_fp80* %3
%17 = load i64, i64* %4
%18 = call i32 (i8*, x86_fp80, x86_fp80, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %15, x86_fp80 %16, i64 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"sqrt(%Lf) == %Lf\0A\00"
@.str.1 = [19 x i8] c"%Lf * %Lf == %llu\0A\00"
define i32 @main() {
%1 = tail call x86_fp80 @sqrtl(x86_fp80 0xK403EF9CCD8A188B38AA1)
%2 = fptoui x86_fp80 %1 to i64
%3 = mul i64 %2, %2
%4 = tail call i32 (i8*, x86_fp80, x86_fp80, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), x86_fp80 0xK403EF9CCD8A188B38AA1, x86_fp80 %1)
%5 = tail call i32 (i8*, x86_fp80, x86_fp80, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %1, x86_fp80 %1, i64 %3)
ret i32 0
}