#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 */
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
double sqrt(double);
int main() {
  double x;
  printf("Podaj liczbe rzeczywista: ");
  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);
  }
  if (x == 0) {
    printf("Error: LIczba równa 0, brak liczby odwrotnej\n");
  } else {
    double odw = pow(x, -1.00);
    printf("Odwrotnosc liczby %.4f to %.4f \n", x, odw);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    118e <main+0x4e>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <main+0x75>
movsd  -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xeb8(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e0 <main+0xa0>
jp     11e0 <main+0xa0>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120f <main+0xcf>
movsd  -0x10(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xeb0(%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    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    117b <main+0x3b>
lea    0xf25(%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    0xe88(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11c5 <main+0x85>
jp     11c5 <main+0x85>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
jmp    11df <main+0x9f>
movsd  0xe33(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    0xe72(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Podaj liczbe rzeczywista: \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"
@.str.4 = [47 x i8] c"Error: LIczba r\C3\B3wna 0, brak liczby odwrotnej\0A\00"
@.str.5 = [33 x i8] c"Odwrotnosc liczby %.4f to %.4f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = load double, double* %2
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
br label %17
11: ; preds = %0
%12 = load double, double* %2
%13 = call double @sqrt(double %12)
store double %13, double* %3
%14 = load double, double* %2
%15 = load double, double* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %14, double %15)
br label %17
17: ; preds = %11, %9
%18 = load double, double* %2
%19 = fcmp oeq double %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %28
22: ; preds = %17
%23 = load double, double* %2
%24 = call double @pow(double %23, double -1.000000e+00)
store double %24, double* %4
%25 = load double, double* %2
%26 = load double, double* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %25, double %26)
br label %28
28: ; preds = %22, %20
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [27 x i8] c"Podaj liczbe rzeczywista: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [35 x i8] c"Pierwiastek z liczby %.4f to %.4f\0A\00"
@.str.5 = [33 x i8] c"Odwrotnosc liczby %.4f to %.4f \0A\00"
@str = [46 x i8] c"Error: LIczba r\C3\B3wna 0, brak liczby odwrotnej\00"
@str.6 = [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 ([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 = 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.6, 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
%14 = load double, double* %1
%15 = fcmp oeq double %14, 0.000000e+00
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %21
18: ; preds = %13
%19 = fdiv double 1.000000e+00, %14
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), double %14, double %19)
br label %21
21: ; preds = %18, %16
ret i32 0
}