// File: /workspace/github_c_makefile_star2_O2/cyb70289[P]tt/src/apn/decimal/mach.c
// Function: tt_dec_from_float
int tt_dec_from_float(struct tt_dec *dec, double num)
{
	tt_assert(dec->_prec >= 20);

	_tt_dec_zero(dec);

	int sign = !!signbit(num);
	switch (fpclassify(num)) {
	case FP_NAN:
		dec->_inf_nan = TT_DEC_NAN;
		return 0;
	case FP_INFINITE:
		dec->_inf_nan = TT_DEC_INF;
		return 0;
	case FP_ZERO:
		return 0;
	default:
		break;
	}

	if (sign)
		num = -num;

	/* Convert to [10^18, 10^19). 19 significands is enough to keep
	 * precision of a double float number.
	 */
	uint64_t ui64;
	int adjexp = norm_fp_to_i64(num, &ui64);
	tt_dec_from_uint(dec, ui64);
	dec->_exp = adjexp;
	dec->_sign = sign;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
cmpl $0x13, 0x8(%rdi)
jle 0x1f7e
movq %rdi, %rbx
movaps %xmm0, 0x30(%rsp)
callq 0x1b01
movapd 0x30(%rsp), %xmm0
callq 0x1080
cmpl $0x2, %eax
je 0x1f71
cmpl $0x1, %eax
je 0x1dd6
testl %eax, %eax
jne 0x1de1
movw $0x2, 0x2(%rbx)
jmp 0x1f71
movw $0x1, 0x2(%rbx)
jmp 0x1f71
movapd 0x14c47(%rip), %xmm0    # 0x16a30
movapd 0x30(%rsp), %xmm2
andpd %xmm2, %xmm0
movlpd %xmm0, 0x28(%rsp)
fldl 0x28(%rsp)
movsd 0x14c5b(%rip), %xmm1    # 0x16a60
xorl %eax, %eax
pushq $0x8
popq %rcx
movl $0x90, %edx
leaq 0x82ca(%rip), %rsi      # 0xa0e0
ucomisd %xmm0, %xmm1
jbe 0x1e53
pushq $-0x1
popq %rdi
xorl %ebp, %ebp
fldl 0x14c41(%rip)           # 0x16a68
testq %rdx, %rdx
je 0x1e84
fldt -0x10(%rdx,%rsi)
fmul %st(2), %st
movl %edi, %r8d
shll %cl, %r8d
fxch %st(1)
fucomi %st(1), %st
fxch %st(2)
fcmovnbe %st(1), %st
fstp %st(1)
cmovbel %eax, %r8d
addl %r8d, %ebp
decl %ecx
addq $-0x10, %rdx
fxch %st(1)
jmp 0x1e27
pushq $0x1
popq %rdi
xorl %ebp, %ebp
fldl 0x14c02(%rip)           # 0x16a60
testq %rdx, %rdx
je 0x1e84
fldt -0x10(%rdx,%rsi)
fdivr %st(2), %st
movl %edi, %r8d
shll %cl, %r8d
fucomi %st(1), %st
fcmovb %st(2), %st
fstp %st(2)
cmovbl %eax, %r8d
addl %r8d, %ebp
decl %ecx
addq $-0x10, %rdx
jmp 0x1e5e
fstp %st(0)
fldl 0x14bdc(%rip)           # 0x16a68
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x1e9c
fdivs 0x14c16(%rip)           # 0x16ab0
incl %ebp
fldl 0x14bbe(%rip)           # 0x16a60
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x1fa5
fldl 0x14bb4(%rip)           # 0x16a68
fucompi %st(1), %st
jbe 0x1fa5
flds 0x14bf2(%rip)           # 0x16ab4
xorl %r14d, %r14d
fxch %st(1)
fucomi %st(1), %st
setae %r14b
fldz
fcmovnb %st(2), %st
fstp %st(2)
fsub %st, %st(1)
fnstcw 0xa(%rsp)
movzwl 0xa(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0xe(%rsp)
fldcw 0xe(%rsp)
fxch %st(1)
fistpll 0x10(%rsp)
fldcw 0xa(%rsp)
shlq $0x3f, %r14
movq 0x10(%rsp), %rdi
xorq %rdi, %r14
andl $0x1, %edi
movq %r14, 0x18(%rsp)
xorl %eax, %eax
testq %r14, %r14
sets %al
fildll 0x18(%rsp)
leaq 0x14b53(%rip), %rcx     # 0x16a70
fadds (%rcx,%rax,4)
fsubrp %st, %st(1)
fmuls 0x14b88(%rip)           # 0x16ab0
fnstcw 0x8(%rsp)
movzwl 0x8(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0xc(%rsp)
fldcw 0xc(%rsp)
fistpll 0x20(%rsp)
fldcw 0x8(%rsp)
movq %xmm2, %r15
movl 0x20(%rsp), %esi
pushq $0x2
popq %rdx
callq 0x829c
movslq %eax, %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x1d10
movl %ebp, 0x4(%rbx)
shrq $0x3f, %r15
movw %r15w, (%rbx)
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1480f(%rip), %rsi     # 0x16794
leaq 0x80f6(%rip), %rdx      # 0xa082
leaq 0x147ea(%rip), %rcx     # 0x1677d
pushq $0x58
popq %r8
xorl %edi, %edi
xorl %eax, %eax
callq 0x7de8
callq 0x1050
fstp %st(0)
leaq 0x14827(%rip), %rsi     # 0x167d5
leaq 0x80cd(%rip), %rdx      # 0xa082
leaq 0x147c1(%rip), %rcx     # 0x1677d
pushq $0x30
jmp 0x1f95