// File: /workspace/github_c_makefile_star2_O3/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 0x29ba
movq %rdi, %rbx
movaps %xmm0, 0x30(%rsp)
callq 0x24bc
movapd 0x30(%rsp), %xmm0
callq 0x1080
cmpl $0x2, %eax
je 0x29ad
cmpl $0x1, %eax
je 0x280c
testl %eax, %eax
jne 0x2817
movw $0x2, 0x2(%rbx)
jmp 0x29ad
movw $0x1, 0x2(%rbx)
jmp 0x29ad
movapd 0x87f1(%rip), %xmm0     # 0xb010
movapd 0x30(%rsp), %xmm2
andpd %xmm2, %xmm0
movlpd %xmm0, 0x28(%rsp)
fldl 0x28(%rsp)
movsd 0x15235(%rip), %xmm1    # 0x17a70
xorl %eax, %eax
movl $0x90, %edx
movl $0x8, %ecx
leaq 0x88b2(%rip), %rsi      # 0xb100
xorl %ebp, %ebp
ucomisd %xmm0, %xmm1
jbe 0x288e
fldl 0x1521c(%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 0x285e
jmp 0x28bc
fldl 0x151dc(%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 0x2898
fstp %st(0)
fstp %st(0)
fldl 0x151b2(%rip)           # 0x17a78
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x28d6
fdivs 0x151ec(%rip)           # 0x17ac0
incl %ebp
fldl 0x15194(%rip)           # 0x17a70
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jb 0x29bf
fldl 0x1518a(%rip)           # 0x17a78
fucompi %st(1), %st
jbe 0x29bf
flds 0x151c8(%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 0x15129(%rip), %rcx     # 0x17a80
fadds (%rcx,%rax,4)
fsubrp %st, %st(1)
fmuls 0x1515e(%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 0x90d6
movslq %eax, %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x2768
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