int main() {
  double x, y, r;
  printf("Zadej souradnice X a Y v [] oddelene carkami: ");
  if (scanf("[%lf,%lf]", &x, &y) != 2) {
    printf("Spatne zadani\n\a");
    return 1;
  }
  r = (sqrt((x) * (x) + (y) * (y)));
  printf("Vzdalenost bodu o souradnicich x=%lf a y=%lf od pocatku je %lf\n", x,
         y, r);
  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    0xedb(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x2,%eax
je     1186 <main+0x56>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d0 <main+0xa0>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xe87(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0x2,%eax
jne    1187 <main+0x57>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119f <main+0x6f>
sqrtsd %xmm0,%xmm2
jmp    11a8 <main+0x78>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret
call   1050 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe8e(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Zadej souradnice X a Y v [] oddelene carkami: \00"
@.str.1 = [10 x i8] c"[%lf,%lf]\00"
@.str.2 = [16 x i8] c"Spatne zadani\0A\07\00"
@.str.3 = [64 x i8] c"Vzdalenost bodu o souradnicich x=%lf a y=%lf od pocatku je %lf\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 ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %22
10: ; preds = %0
%11 = load double, double* %2
%12 = load double, double* %2
%13 = load double, double* %3
%14 = load double, double* %3
%15 = fmul double %13, %14
%16 = call double @llvm.fmuladd.f64(double %11, double %12, double %15)
%17 = call double @sqrt(double %16)
store double %17, double* %4
%18 = load double, double* %2
%19 = load double, double* %3
%20 = load double, double* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), double %18, double %19, double %20)
store i32 0, i32* %1
br label %22
22: ; preds = %10, %8
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [47 x i8] c"Zadej souradnice X a Y v [] oddelene carkami: \00"
@.str.1 = [10 x i8] c"[%lf,%lf]\00"
@.str.2 = [16 x i8] c"Spatne zadani\0A\07\00"
@.str.3 = [64 x i8] c"Vzdalenost bodu o souradnicich x=%lf a y=%lf od pocatku je %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %19
10: ; preds = %0
%11 = load double, double* %1
%12 = load double, double* %2
%13 = fmul double %12, %12
%14 = call double @llvm.fmuladd.f64(double %11, double %11, double %13)
%15 = call double @sqrt(double %14)
%16 = load double, double* %1
%17 = load double, double* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), double %16, double %17, double %15)
br label %19
19: ; preds = %10, %8
%20 = phi i32 [ 1, %8 ], [ 0, %10 ]
ret i32 %20
}