// File: /workspace/github_c_makefile_star2_O1/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 0x2a42
movq %rdi, %rbx
movaps %xmm0, 0x30(%rsp)
callq 0x2540
movapd 0x30(%rsp), %xmm0
callq 0x1080
cmpl $0x2, %eax
je 0x2a35
cmpl $0x1, %eax
je 0x2894
testl %eax, %eax
jne 0x289f
movw $0x2, 0x2(%rbx)
jmp 0x2a35
movw $0x1, 0x2(%rbx)
jmp 0x2a35
movapd 0x8769(%rip), %xmm0     # 0xb010
movapd 0x30(%rsp), %xmm2
andpd %xmm2, %xmm0
movlpd %xmm0, 0x28(%rsp)
fldl 0x28(%rsp)
movsd 0x151ad(%rip), %xmm1    # 0x17a70
xorl %eax, %eax
movl $0x90, %edx
movl $0x8, %ecx
leaq 0x882a(%rip), %rsi      # 0xb100
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
jbe 0x2916
fldl 0x15194(%rip)           # 0x17a78
fldz
fstp %st(0)
fldt -0x10(%rdx,%rsi)
fmul %st(2), %st
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
fxch %st(1)
fucomi %st(1), %st
fxch %st(2)
fcmovnbe %st(1), %st
fstp %st(1)
cmovbel %eax, %edi
addl %edi, %ebp
decl %ecx
addq $-0x10, %rdx
fldz
fxch %st(1)
fxch %st(2)
fxch %st(1)
jne 0x28e6
jmp 0x2944
fldl 0x15154(%rip)           # 0x17a70
fldz
fxch %st(2)
fstp %st(2)
fldt -0x10(%rdx,%rsi)
fdivr %st(2), %st
movl $0x1, %edi
shll %cl, %edi
fucomi %st(1), %st
fcmovb %st(2), %st
fstp %st(2)
cmovbl %eax, %edi
addl %edi, %ebp
decl %ecx
fld %st(1)
addq $-0x10, %rdx
jne 0x2920
fstp %st(0)
fstp %st(0)
fldl 0x1512a(%rip)           # 0x17a78
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x295e
fdivs 0x15164(%rip)           # 0x17ac0
incl %ebp
fldl 0x1510c(%rip)           # 0x17a70
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x2a47
fldl 0x15102(%rip)           # 0x17a78
fucompi %st(1), %st
jbe 0x2a47
flds 0x15140(%rip)           # 0x17ac4
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 0x150a1(%rip), %rcx     # 0x17a80
fadds (%rcx,%rax,4)
fsubrp %st, %st(1)
fmuls 0x150d6(%rip)           # 0x17ac0
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
movl $0x2, %edx
callq 0x9052
movslq %eax, %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x27f0
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
callq 0x124a
fstp %st(0)
callq 0x1222