#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double sqrt(double);
int main() {
  double x, z;
  printf("Wpisz liczbe rzeczywista: ");
  scanf("%lf", &x);
  printf("Wpisano liczbe rzeczywista %lf\n", x);
  if (x >= 0) {
    z = sqrt(x);
    printf("Pierwiastek Kwadratowy z %lf to %lf\n", x, z);
  } else {
    printf("Pierwiastek kwadratowy z liczby ujemnej nie istnieje\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xea6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11be <main+0x7e>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe8d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    11d6 <main+0x96>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11bb <main+0x6b>
jb     119b <main+0x4b>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    11a4 <main+0x54>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
lea    0xe8f(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Wpisz liczbe rzeczywista: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [32 x i8] c"Wpisano liczbe rzeczywista %lf\0A\00"
@.str.3 = [37 x i8] c"Pierwiastek Kwadratowy z %lf to %lf\0A\00"
@.str.4 = [54 x i8] c"Pierwiastek kwadratowy z liczby ujemnej nie istnieje\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%6 = load double, double* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %6)
%8 = load double, double* %2
%9 = fcmp oge double %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %0
%11 = load double, double* %2
%12 = call double @sqrt(double %11)
store double %12, double* %3
%13 = load double, double* %2
%14 = load double, double* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %13, double %14)
br label %19
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Wpisz liczbe rzeczywista: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [32 x i8] c"Wpisano liczbe rzeczywista %lf\0A\00"
@.str.3 = [37 x i8] c"Pierwiastek Kwadratowy z %lf to %lf\0A\00"
@str = [53 x i8] c"Pierwiastek kwadratowy z liczby ujemnej nie istnieje\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %5)
%7 = load double, double* %1
%8 = fcmp ult double %7, 0.000000e+00
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = call double @sqrt(double %7)
%11 = load double, double* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), double %11, double %10)
ret i32 0
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
}