#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;
  printf("Wpisz liczbe rzeczywista: ");
  scanf("%lf", &x);
  printf("Wpisano liczbe rzeczywista %lf\n", x);
  while (x < 0) {
    printf("Wpisales liczbe ujemna: %lf\n", x);
    printf("Wpisz liczbe dodatnia: ");
    scanf("%lf", &x);
  }
  z = sqrt(x);
  printf("Pierwiastek Kwadratowy z %lf to %lf\n", x, z);
  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    0xec7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xeb6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b4 <main+0x84>
movsd  -0x10(%rbp),%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1170 <main+0x40>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xea0(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
lea    0xebe(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    11be <main+0x8e>
lea    0xec1(%rip),%r14
lea    0xed7(%rip),%r15
lea    0xe8f(%rip),%r12
mov    %rsp,%rbx
nop
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorpd  %xmm1,%xmm1
movsd  (%rsp),%xmm0
ucomisd %xmm0,%xmm1
ja     1190 <main+0x60>
ucomisd %xmm1,%xmm0
jb     11cd <main+0x9d>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    11d6 <main+0xa6>
call   1050 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  (%rsp),%xmm0
lea    0xe92(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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 = [29 x i8] c"Wpisales liczbe ujemna: %lf\0A\00"
@.str.4 = [24 x i8] c"Wpisz liczbe dodatnia: \00"
@.str.5 = [37 x i8] c"Pierwiastek Kwadratowy z %lf to %lf\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)
br label %8
8: ; preds = %11, %0
%9 = load double, double* %2
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load double, double* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
br label %8
16: ; preds = %8
%17 = load double, double* %2
%18 = call double @sqrt(double %17)
store double %18, double* %3
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %19, double %20)
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 = [29 x i8] c"Wpisales liczbe ujemna: %lf\0A\00"
@.str.4 = [24 x i8] c"Wpisz liczbe dodatnia: \00"
@.str.5 = [37 x i8] c"Pierwiastek Kwadratowy z %lf to %lf\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 ([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 olt double %7, 0.000000e+00
br i1 %8, label %9, label %16
9: ; preds = %0, %9
%10 = phi double [ %14, %9 ], [ %7, %0 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %10)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%14 = load double, double* %1
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %9, label %16
16: ; preds = %9, %0
%17 = phi double [ %7, %0 ], [ %14, %9 ]
%18 = call double @sqrt(double %17)
%19 = load double, double* %1
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), double %19, double %18)
ret i32 0
}