#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, z, r;
  printf("Wpisz liczbe rzeczywista: ");
  scanf("%lf", &x);
  z = sqrt(x);
  if (x == 0) {
    printf("Odwrotnosc z 0 nie istnieje\n");
  } else {
    r = 1 / x;
    printf("Liczba odwrotna do liczby %lf to %lf.2\n", x, r);
  }
  if (x >= 0) {
    z = sqrt(x);
    printf("Pierwiastek kwadratowy z liczby %lf to %lf\n", x, z);
  } else {
    r = 1 / x;
    printf("Pierwiastek kwadratowy z liczby ujemnej nie istnieje\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec2(%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
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1197 <main+0x67>
jp     1197 <main+0x67>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <main+0x91>
movsd  0xe61(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe8a(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ff <main+0xcf>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe79(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
jmp    121f <main+0xef>
movsd  0xdf9(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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
ja     11e5 <main+0xa5>
ucomisd %xmm1,%xmm0
jne    1183 <main+0x43>
jp     1183 <main+0x43>
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
jmp    119d <main+0x5d>
movsd  0xe75(%rip),%xmm1
divsd  %xmm0,%xmm1
lea    0xe91(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jae    11ba <main+0x7a>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
jmp    11e1 <main+0xa1>
jb     11c5 <main+0x85>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    11ce <main+0x8e>
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
lea    0xe75(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
ucomisd %xmm1,%xmm0
jae    11f4 <main+0xb4>
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  (%rsp),%xmm0
jmp    116d <main+0x2d>

LLVM IR (-O0):
@.str = [27 x i8] c"Wpisz liczbe rzeczywista: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [29 x i8] c"Odwrotnosc z 0 nie istnieje\0A\00"
@.str.3 = [40 x i8] c"Liczba odwrotna do liczby %lf to %lf.2\0A\00"
@.str.4 = [44 x i8] c"Pierwiastek kwadratowy z liczby %lf to %lf\0A\00"
@.str.5 = [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
%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 = call double @sqrt(double %7)
store double %8, double* %3
%9 = load double, double* %2
%10 = fcmp oeq double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %19
13: ; preds = %0
%14 = load double, double* %2
%15 = fdiv double 1.000000e+00, %14
store double %15, double* %4
%16 = load double, double* %2
%17 = load double, double* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), double %16, double %17)
br label %19
19: ; preds = %13, %11
%20 = load double, double* %2
%21 = fcmp oge double %20, 0.000000e+00
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load double, double* %2
%24 = call double @sqrt(double %23)
store double %24, double* %3
%25 = load double, double* %2
%26 = load double, double* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %25, double %26)
br label %32
28: ; preds = %19
%29 = load double, double* %2
%30 = fdiv double 1.000000e+00, %29
store double %30, double* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %28, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Wpisz liczbe rzeczywista: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [40 x i8] c"Liczba odwrotna do liczby %lf to %lf.2\0A\00"
@.str.4 = [44 x i8] c"Pierwiastek kwadratowy z liczby %lf to %lf\0A\00"
@str = [53 x i8] c"Pierwiastek kwadratowy z liczby ujemnej nie istnieje\00"
@str.6 = [28 x i8] c"Odwrotnosc z 0 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 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call double @sqrt(double %5)
%9 = load double, double* %1
br label %10
10: ; preds = %0, %7
%11 = phi double [ %5, %0 ], [ %9, %7 ]
%12 = fcmp oeq double %11, 0.000000e+00
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0))
br label %18
15: ; preds = %10
%16 = fdiv double 1.000000e+00, %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), double %11, double %16)
br label %18
18: ; preds = %15, %13
%19 = load double, double* %1
%20 = fcmp ult double %19, 0.000000e+00
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = call double @sqrt(double %19)
%23 = load double, double* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %23, double %22)
br label %27
25: ; preds = %18
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
ret i32 0
}