#include "../../cmd/ld/textflag.h"
#define LN2 0.6931471805599453094172321214581766
#define LOG2E 1.4426950408889634073599246810018920
#define LN2U 0.69314718055966295651160180568695068359375
#define LN2L 0.28235290563031577122588448175013436025525412068e-12
#define T0 1.0
#define T1 0.5
#define T2 1.6666666666666666667e-1
#define T3 4.1666666666666666667e-2
#define T4 8.3333333333333333333e-3
#define T5 1.3888888888888888889e-3
#define T6 1.9841269841269841270e-4
#define T7 2.4801587301587301587e-5
#define PosInf 0x7FF0000000000000
#define NegInf 0xFFF0000000000000
TEXT ·Exp(SB),NOSPLIT,$0
MOVQ x+0(FP), BX
MOVQ $~(1<<63), AX
MOVQ BX, DX
ANDQ AX, DX
MOVQ $PosInf, AX
CMPQ AX, DX
JLE notFinite
MOVQ BX, X0
MOVSD $LOG2E, X1
MULSD X0, X1
CVTSD2SL X1, BX
CVTSL2SD BX, X1
MOVSD $LN2U, X2
MULSD X1, X2
SUBSD X2, X0
MOVSD $LN2L, X2
MULSD X1, X2
SUBSD X2, X0
MULSD $0.0625, X0
MOVSD $T7, X1
MULSD X0, X1
ADDSD $T6, X1
MULSD X0, X1
ADDSD $T5, X1
MULSD X0, X1
ADDSD $T4, X1
MULSD X0, X1
ADDSD $T3, X1
MULSD X0, X1
ADDSD $T2, X1
MULSD X0, X1
ADDSD $T1, X1
MULSD X0, X1
ADDSD $T0, X1
MULSD X1, X0
MOVSD $2.0, X1
ADDSD X0, X1
MULSD X1, X0
MOVSD $2.0, X1
ADDSD X0, X1
MULSD X1, X0
MOVSD $2.0, X1
ADDSD X0, X1
MULSD X1, X0
MOVSD $2.0, X1
ADDSD X0, X1
MULSD X1, X0
ADDSD $1.0, X0
MOVL $0x3FF, AX
ADDL AX, BX
JLE underflow
CMPL BX, $0x7FF
JGE overflow
MOVL $52, CX
SHLQ CX, BX
MOVQ BX, X1
MULSD X1, X0
MOVSD X0, ret+8(FP)
RET
notFinite:
MOVQ $NegInf, AX
CMPQ AX, BX
JNE notNegInf
underflow:
MOVQ $0, AX
MOVQ AX, ret+8(FP)
RET
overflow:
MOVQ $PosInf, BX
notNegInf:
MOVQ BX, ret+8(FP)
RET