#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 */
float fabs(float);
float sqrtf(float);
float hypot_s(float a, float b) {
  float r;
  if (fabs(a) > fabs(b)) {
    r = b / a;
    r = fabs(a) * sqrtf(1.0f + r * r);
  } else if (b != 0.0f) {
    r = a / b;
    r = fabs(b) * sqrtf(1.0f + r * r);
  } else {
    r = 0.0f;
  }
  return r;
}


x86 assembly (clang, -O0):
<hypot_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    11af <hypot_s+0x8f>
movss  -0x8(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe70(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    122b <hypot_s+0x10b>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11cb <hypot_s+0xab>
jp     11cb <hypot_s+0xab>
jmp    121e <hypot_s+0xfe>
movss  -0x4(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  0xe01(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <sqrtf@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1226 <hypot_s+0x106>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    122b <hypot_s+0x10b>
movss  -0xc(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypot_s>:
sub    $0x18,%rsp
movaps 0xee5(%rip),%xmm2
movaps %xmm0,%xmm3
andps  %xmm2,%xmm3
andps  %xmm1,%xmm2
ucomiss %xmm2,%xmm3
jbe    113b <hypot_s+0x2b>
divss  %xmm0,%xmm1
mulss  %xmm1,%xmm1
addss  0xed7(%rip),%xmm1
jmp    115b <hypot_s+0x4b>
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm1
jne    1145 <hypot_s+0x35>
jnp    1180 <hypot_s+0x70>
divss  %xmm1,%xmm0
mulss  %xmm0,%xmm0
addss  0xebb(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm2,%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jb     116c <hypot_s+0x5c>
xorps  %xmm0,%xmm0
sqrtss %xmm1,%xmm0
jmp    117c <hypot_s+0x6c>
movaps %xmm1,%xmm0
movaps %xmm3,(%rsp)
call   1030 <sqrtf@plt>
movaps (%rsp),%xmm3
mulss  %xmm0,%xmm3
movaps %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @hypot_s(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 float @fabs(float %6)
%8 = load float, float* %4
%9 = call float @fabs(float %8)
%10 = fcmp ogt float %7, %9
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load float, float* %4
%13 = load float, float* %3
%14 = fdiv float %12, %13
store float %14, float* %5
%15 = load float, float* %3
%16 = call float @fabs(float %15)
%17 = load float, float* %5
%18 = load float, float* %5
%19 = call float @llvm.fmuladd.f32(float %17, float %18, float 1.000000e+00)
%20 = call float @sqrtf(float %19)
%21 = fmul float %16, %20
store float %21, float* %5
br label %38
22: ; preds = %2
%23 = load float, float* %4
%24 = fcmp une float %23, 0.000000e+00
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load float, float* %3
%27 = load float, float* %4
%28 = fdiv float %26, %27
store float %28, float* %5
%29 = load float, float* %4
%30 = call float @fabs(float %29)
%31 = load float, float* %5
%32 = load float, float* %5
%33 = call float @llvm.fmuladd.f32(float %31, float %32, float 1.000000e+00)
%34 = call float @sqrtf(float %33)
%35 = fmul float %30, %34
store float %35, float* %5
br label %37
36: ; preds = %22
store float 0.000000e+00, float* %5
br label %37
37: ; preds = %36, %25
br label %38
38: ; preds = %37, %11
%39 = load float, float* %5
ret float %39
}

LLVM IR (-O2):
define float @hypot_s(float %0, float %1) {
%3 = tail call float @llvm.fabs.f32(float %0)
%4 = tail call float @llvm.fabs.f32(float %1)
%5 = fcmp ogt float %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = fdiv float %1, %0
%8 = tail call float @llvm.fmuladd.f32(float %7, float %7, float 1.000000e+00)
br label %14
9: ; preds = %2
%10 = fcmp une float %1, 0.000000e+00
br i1 %10, label %11, label %19
11: ; preds = %9
%12 = fdiv float %0, %1
%13 = tail call float @llvm.fmuladd.f32(float %12, float %12, float 1.000000e+00)
br label %14
14: ; preds = %6, %11
%15 = phi float [ %13, %11 ], [ %8, %6 ]
%16 = phi float [ %4, %11 ], [ %3, %6 ]
%17 = tail call float @sqrtf(float %15)
%18 = fmul float %16, %17
br label %19
19: ; preds = %14, %9
%20 = phi float [ 0.000000e+00, %9 ], [ %18, %14 ]
ret float %20
}