#include "../../cmd/ld/textflag.h"
#define PosInf 0x7FF0000000000000
#define NaN 0x7FF8000000000001
TEXT ·Hypot(SB),NOSPLIT,$0
MOVQ p+0(FP), BX
MOVQ $~(1<<63), AX
ANDQ AX, BX
MOVQ q+8(FP), CX
ANDQ AX, CX
MOVQ $PosInf, AX
CMPQ AX, BX
JLE isInfOrNaN
CMPQ AX, CX
JLE isInfOrNaN
MOVQ BX, X0
MOVQ CX, X1
ORQ CX, BX
JEQ isZero
MOVAPD X0, X2
MAXSD X1, X0
MINSD X2, X1
DIVSD X0, X1
MULSD X1, X1
ADDSD $1.0, X1
SQRTSD X1, X1
MULSD X1, X0
MOVSD X0, ret+16(FP)
RET
isInfOrNaN:
CMPQ AX, BX
JEQ isInf
CMPQ AX, CX
JEQ isInf
MOVQ $NaN, AX
MOVQ AX, ret+16(FP)
RET
isInf:
MOVQ AX, ret+16(FP)
RET
isZero:
MOVQ $0, AX
MOVQ AX, ret+16(FP)
RET