#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*/ assert(int);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ puts(char *);
int scanf(char *, double *, double *);
double sqrt(double);
int main(void) {
  double x, y, z;
  puts("Entera a pair of numbers (0 0 to quit): ");
  while (scanf("%lf %lf", &x, &y) == 2 && (x != 0 || y != 0)) {
    z = x * x - y * y;
    assert(z >= 0);
    printf("Answer is %f\n", sqrt(z));
    puts("NExt pair of numbers.");
  }
  puts("Done!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <scanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x21(%rbp)
jne    11c9 <main+0x79>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x22(%rbp)
jne    11c3 <main+0x73>
jp     11c3 <main+0x73>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11d9 <main+0x89>
jmp    1251 <main+0x101>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movsd  -0x20(%rbp),%xmm0
call   1070 <sqrt@plt>
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
lea    0xdf8(%rip),%rdi
call   1030 <puts@plt>
jmp    116b <main+0x1b>
lea    0xdfd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    122f <main+0xdf>
xorpd  %xmm1,%xmm1
lea    0xe9e(%rip),%r14
lea    0xea5(%rip),%r15
lea    0xe88(%rip),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbx
jmp    11dc <main+0x8c>
nopl   (%rax)
call   1070 <sqrt@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <scanf@plt>
cmp    $0x2,%eax
xorpd  %xmm1,%xmm1
jne    122f <main+0xdf>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm1,%xmm2
movsd  0x8(%rsp),%xmm0
jne    11f8 <main+0xa8>
jp     11f8 <main+0xa8>
ucomisd %xmm1,%xmm0
jne    11f8 <main+0xa8>
jnp    122f <main+0xdf>
mulsd  %xmm0,%xmm0
mulsd  %xmm2,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
xor    %edi,%edi
ucomisd %xmm1,%xmm2
setae  %dil
call   1050 <assert@plt>
movsd  0x18(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11b0 <main+0x60>
sqrtsd %xmm0,%xmm0
jmp    11b5 <main+0x65>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Entera a pair of numbers (0 0 to quit): \00"
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [14 x i8] c"Answer is %f\0A\00"
@.str.3 = [22 x i8] c"NExt pair of numbers.\00"
@.str.4 = [7 x i8] c"Done!\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 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %19, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load double, double* %2
%11 = fcmp une double %10, 0.000000e+00
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load double, double* %3
%14 = fcmp une double %13, 0.000000e+00
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br label %17
17: ; preds = %15, %6
%18 = phi i1 [ false, %6 ], [ %16, %15 ]
br i1 %18, label %19, label %35
19: ; preds = %17
%20 = load double, double* %2
%21 = load double, double* %2
%22 = load double, double* %3
%23 = load double, double* %3
%24 = fmul double %22, %23
%25 = fneg double %24
%26 = call double @llvm.fmuladd.f64(double %20, double %21, double %25)
store double %26, double* %4
%27 = load double, double* %4
%28 = fcmp oge double %27, 0.000000e+00
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load double, double* %4
%32 = call double @sqrt(double %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %32)
%34 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %6
35: ; preds = %17
%36 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Entera a pair of numbers (0 0 to quit): \00"
@.str.1 = [8 x i8] c"%lf %lf\00"
@.str.2 = [14 x i8] c"Answer is %f\0A\00"
@.str.3 = [22 x i8] c"NExt pair of numbers.\00"
@.str.4 = [7 x i8] c"Done!\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %26
8: ; preds = %0, %14
%9 = load double, double* %1
%10 = fcmp une double %9, 0.000000e+00
%11 = load double, double* %2
%12 = fcmp une double %11, 0.000000e+00
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %26
14: ; preds = %8
%15 = fneg double %11
%16 = fmul double %11, %15
%17 = call double @llvm.fmuladd.f64(double %9, double %9, double %16)
%18 = fcmp oge double %17, 0.000000e+00
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call double @sqrt(double %17)
%22 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %21)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2)
%25 = icmp eq i32 %24, 2
br i1 %25, label %8, label %26
26: ; preds = %8, %14, %0
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}