#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ isnan(float);
int /*<<< orphan*/ printf(char *);
float sqrt(float);
float vectorGetLength(float vx, float vy) {
  if (isnan(vx) || isnan(vy)) {
    printf("Cannot get length of vector.\n");
    exit(EXIT_FAILURE);
  }
  float res = sqrt(vx * vx + vy * vy);
  return res;
}


x86 assembly (clang, -O0):
<vectorGetLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    117a <vectorGetLength+0x3a>
movss  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1194 <vectorGetLength+0x54>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1050 <sqrt@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectorGetLength>:
push   %rax
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
jne    1190 <vectorGetLength+0x50>
movss  (%rsp),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
jne    1190 <vectorGetLength+0x50>
movss  (%rsp),%xmm1
mulss  %xmm1,%xmm1
movss  0x4(%rsp),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     118a <vectorGetLength+0x4a>
sqrtss %xmm0,%xmm0
pop    %rax
ret
pop    %rax
jmp    1050 <sqrt@plt>
lea    0xe69(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Cannot get length of vector.\0A\00"
@EXIT_FAILURE = global i32 0
define float @vectorGetLength(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
%6 = load float, float* %3
%7 = call i64 @isnan(float %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load float, float* %4
%11 = call i64 @isnan(float %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9, %2
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
%18 = load float, float* %3
%19 = load float, float* %3
%20 = load float, float* %4
%21 = load float, float* %4
%22 = fmul float %20, %21
%23 = call float @llvm.fmuladd.f32(float %18, float %19, float %22)
%24 = call float @sqrt(float %23)
store float %24, float* %5
%25 = load float, float* %5
ret float %25
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [29 x i8] c"Cannot get length of vector.\00"
define float @vectorGetLength(float %0, float %1) {
%3 = tail call i64 @isnan(float %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @isnan(float %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5, %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %5
%13 = fmul float %1, %1
%14 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %13)
%15 = tail call float @sqrt(float %14)
ret float %15
}