#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 *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double sqrt(int);
int main() {
  double number;
  printf("Enter number to print sqrt of it: ");
  scanf("%lf", &number);
  printf("Square root of %lf -> %lf\n", number, sqrt(number));
  printf("Square root of 12345 -> %f\n", sqrt(12345));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
lea    0xea7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x3039,%edi
call   1050 <sqrt@plt>
lea    0xeaa(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movapd %xmm0,%xmm1
lea    0xeb4(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
mov    $0x3039,%edi
call   1050 <sqrt@plt>
lea    0xeb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter number to print sqrt of it: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"Square root of %lf -> %lf\0A\00"
@.str.3 = [28 x i8] c"Square root of 12345 -> %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%5 = load double, double* %2
%6 = load double, double* %2
%7 = fptosi double %6 to i32
%8 = call double @sqrt(i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %5, double %8)
%10 = call double @sqrt(i32 12345)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter number to print sqrt of it: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"Square root of %lf -> %lf\0A\00"
@.str.3 = [28 x i8] c"Square root of 12345 -> %f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fptosi double %5 to i32
%7 = call double @sqrt(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %5, double %7)
%9 = call double @sqrt(i32 12345)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), double %9)
ret i32 0
}