#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(double);
int main() {
  double x;
  printf("Podaj liczbe rzeczywista, dla ktorej zostanie wyliczony pierwiastek "
         "kwadratowy: ");
  scanf("%lf", &x);
  if (x < 0) {
    printf("Error: Liczba mniejsza od zera, brak pierwiastka kwadratowego\n");
  } else {
    double p = sqrt(x);
    printf("Pierwiastek z liczby %.4f to %.4f\n", x, p);
  }
}


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    0xefd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117e <main+0x4e>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a5 <main+0x75>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xef6(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    117b <main+0x3b>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
jmp    11a6 <main+0x66>
ucomisd %xmm1,%xmm0
jb     118a <main+0x4a>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    1193 <main+0x53>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
lea    0xeb6(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [81 x i8] c"Podaj liczbe rzeczywista, dla ktorej zostanie wyliczony pierwiastek kwadratowy: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [63 x i8] c"Error: Liczba mniejsza od zera, brak pierwiastka kwadratowego\0A\00"
@.str.3 = [35 x i8] c"Pierwiastek z liczby %.4f to %.4f\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 ([81 x i8], [81 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 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
br 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 ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %13, double %14)
br label %16
16: ; preds = %10, %8
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [81 x i8] c"Podaj liczbe rzeczywista, dla ktorej zostanie wyliczony pierwiastek kwadratowy: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [35 x i8] c"Pierwiastek z liczby %.4f to %.4f\0A\00"
@str = [62 x i8] c"Error: Liczba mniejsza od zera, brak pierwiastka kwadratowego\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 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 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
br label %13
9: ; preds = %0
%10 = call double @sqrt(double %5)
%11 = load double, double* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %11, double %10)
br label %13
13: ; preds = %9, %7
ret i32 0
}