#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*/ ERANGE;
int /*<<< orphan*/ errno;
scalar_t__ pow(double, int);
double sqrt(scalar_t__);
double pythagorean_theorem(double a, double b) {
  if (a <= 0 || b <= 0) {
    errno = ERANGE;
    return (-1.0);
  }
  return (sqrt(pow(a, 2) + pow(b, 2)));
}


x86 assembly (clang, -O0):
<pythagorean_theorem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jae    114e <pythagorean_theorem+0x2e>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1172 <pythagorean_theorem+0x52>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
mov    0x2e7a(%rip),%rax
mov    %ecx,(%rax)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a5 <pythagorean_theorem+0x85>
movsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %rax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pythagorean_theorem>:
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1168 <pythagorean_theorem+0x48>
ucomisd %xmm1,%xmm2
jae    1168 <pythagorean_theorem+0x48>
mov    $0x2,%edi
movsd  %xmm1,0x8(%rsp)
call   1030 <pow@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <sqrt@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    0x2e60(%rip),%rcx
mov    %eax,(%rcx)
movsd  0xe7e(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
define double @pythagorean_theorem(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = fcmp ole double %6, 0.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp ole double %9, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %8, %2
%12 = load i32, i32* @ERANGE
store i32 %12, i32* @errno
store double -1.000000e+00, double* %3
br label %20
13: ; preds = %8
%14 = load double, double* %4
%15 = call i64 @pow(double %14, i32 2)
%16 = load double, double* %5
%17 = call i64 @pow(double %16, i32 2)
%18 = add nsw i64 %15, %17
%19 = call double @sqrt(i64 %18)
store double %19, double* %3
br label %20
20: ; preds = %13, %11
%21 = load double, double* %3
ret double %21
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
define double @pythagorean_theorem(double %0, double %1) {
%3 = fcmp ole double %0, 0.000000e+00
%4 = fcmp ole double %1, 0.000000e+00
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = load i32, i32* @ERANGE
store i32 %7, i32* @errno
br label %13
8: ; preds = %2
%9 = tail call i64 @pow(double %0, i32 2)
%10 = tail call i64 @pow(double %1, i32 2)
%11 = add nsw i64 %10, %9
%12 = tail call double @sqrt(i64 %11)
br label %13
13: ; preds = %8, %6
%14 = phi double [ -1.000000e+00, %6 ], [ %12, %8 ]
ret double %14
}