#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 /*<<< orphan*/ time_t;

/* Variables and functions */
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, ...);
long double sqrtl(long double);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  long long int n = 581170932765279684LL;
  long double x = sqrtl((long double)n);
  printf("Math function sqrt of %lli is %Lf \n\n", n, x);
  long long int sqrt = 0;
  time_t starttime = time(NULL);
  for (long long int i = 2; i < n / 2; i++) {
    if (i * i == n) {
      sqrt = i;
      break;
    }
  }
  time_t endtime = time(NULL);
  double runtimeinsecs = difftime(endtime, starttime);
  printf("Big sqrt mp of %lli is %lli \n", n, sqrt);
  printf("Time taken: %f \n", runtimeinsecs);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x810bbe25941c5c4,%rax
bb 10 08
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
fildll -0x60(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <sqrtl@plt>
fstpt  -0x30(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x3c(%rbp)
movq   $0x2,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
cmp    %rcx,%rax
jge    1213 <main+0xd3>
mov    -0x48(%rbp),%rax
imul   -0x48(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11fd <main+0xbd>
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1213 <main+0xd3>
jmp    1202 <main+0xc2>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11b7 <main+0x77>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xde5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
fldt   0xeb5(%rip)
fstpt  (%rsp)
call   1060 <sqrtl@plt>
fstpt  (%rsp)
lea    0xebb(%rip),%rdi
movsd  0xeab(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1040 <difftime@plt>
movsd  %xmm0,0x18(%rsp)
lea    0xeab(%rip),%rdi
mov    $0x2d7078ce,%esi
movsd  0xe71(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Math function sqrt of %lli is %Lf \0A\0A\00"
@.str.1 = [30 x i8] c"Big sqrt mp of %lli is %lli \0A\00"
@.str.2 = [17 x i8] c"Time taken: %f \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca x86_fp80
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
%11 = alloca i32
%12 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 581170932765279684, i64* %6
%13 = load i64, i64* %6
%14 = sitofp i64 %13 to x86_fp80
%15 = call x86_fp80 @sqrtl(x86_fp80 %14)
store x86_fp80 %15, x86_fp80* %7
%16 = load i64, i64* %6
%17 = sitofp i64 %16 to double
%18 = load x86_fp80, x86_fp80* %7
%19 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double %17, x86_fp80 %18)
store i64 0, i64* %8
%20 = call i32 @time(i32* null)
store i32 %20, i32* %9
store i64 2, i64* %10
br label %21
21: ; preds = %35, %2
%22 = load i64, i64* %10
%23 = load i64, i64* %6
%24 = sdiv i64 %23, 2
%25 = icmp slt i64 %22, %24
br i1 %25, label %26, label %38
26: ; preds = %21
%27 = load i64, i64* %10
%28 = load i64, i64* %10
%29 = mul nsw i64 %27, %28
%30 = load i64, i64* %6
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %26
%33 = load i64, i64* %10
store i64 %33, i64* %8
br label %38
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load i64, i64* %10
%37 = add nsw i64 %36, 1
store i64 %37, i64* %10
br label %21
38: ; preds = %32, %21
%39 = call i32 @time(i32* null)
store i32 %39, i32* %11
%40 = load i32, i32* %11
%41 = load i32, i32* %9
%42 = call double @difftime(i32 %40, i32 %41)
store double %42, double* %12
%43 = load i64, i64* %6
%44 = sitofp i64 %43 to double
%45 = load i64, i64* %8
%46 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double %44, i64 %45)
%47 = load double, double* %12
%48 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Math function sqrt of %lli is %Lf \0A\0A\00"
@.str.1 = [30 x i8] c"Big sqrt mp of %lli is %lli \0A\00"
@.str.2 = [17 x i8] c"Time taken: %f \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call x86_fp80 @sqrtl(x86_fp80 0xK403A810BBE25941C5C40)
%4 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), double 0x43A02177C4B2838C, x86_fp80 %3)
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @time(i32* null)
%7 = tail call double @difftime(i32 %6, i32 %5)
%8 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), double 0x43A02177C4B2838C, i64 762345678)
%9 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %7)
ret i32 0
}