// File: /workspace/github_c_makefile_star2_O0/cyb70289[P]tt/src/apn/decimal/mach.c
// Function: norm_fp_to_i64
static int norm_fp_to_i64(double num, uint64_t *ui64)
{
	static const long double _lower = 1E18L, _upper = 1E19L;

	long double lnum = num;
	int adjexp = 0, i = ARRAY_SIZE(_exp10);
	if (lnum < _lower) {
		/* Scale up */
		while (i--) {
			if (lnum * _exp10[i] < _upper) {
				lnum *= _exp10[i];
				adjexp -= (1U << i);
			}
		}
	} else {
		/* Scale down */
		while (i--) {
			if (lnum / _exp10[i] >= _lower) {
				lnum /= _exp10[i];
				adjexp += (1U << i);
			}
		}
	}
	if (lnum >= _upper) {
		lnum /= _exp10[0];
		adjexp++;
	}
	tt_assert(lnum >= _lower && lnum < _upper);

	*ui64 = (uint64_t)lnum;
	*ui64 += _tt_round((*ui64) & 1, (uint)((lnum - *ui64) * 10),
			TT_ROUND_HALF_AWAY0);

	return adjexp;
}

// Assembly:
subq $0x58, %rsp
movsd %xmm0, 0x50(%rsp)
movq %rdi, 0x48(%rsp)
fldl 0x50(%rsp)
fstpt 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl $0x9, 0x28(%rsp)
fldt 0x30(%rsp)
fldl 0x1c087(%rip)           # 0x1e968
fucompi %st(1), %st
fstp %st(0)
jbe 0x295c
jmp 0x28e9
jmp 0x28eb
movl 0x28(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rsp)
cmpl $0x0, %eax
je 0x295a
fldt 0x30(%rsp)
movslq 0x28(%rsp), %rax
shlq $0x4, %rax
leaq 0xf7ff(%rip), %rcx      # 0x12110
fldt (%rax,%rcx)
fmulp %st, %st(1)
fldl 0x1c054(%rip)           # 0x1e970
fucompi %st(1), %st
fstp %st(0)
jbe 0x2958
jmp 0x2924
movslq 0x28(%rsp), %rax
shlq $0x4, %rax
leaq 0xf7dc(%rip), %rcx      # 0x12110
fldt (%rax,%rcx)
fldt 0x30(%rsp)
fmulp %st, %st(1)
fstpt 0x30(%rsp)
movl 0x28(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movl 0x2c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x2c(%rsp)
jmp 0x28eb
jmp 0x29cd
jmp 0x295e
movl 0x28(%rsp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rsp)
cmpl $0x0, %eax
je 0x29cb
fldt 0x30(%rsp)
movslq 0x28(%rsp), %rax
shlq $0x4, %rax
leaq 0xf78c(%rip), %rcx      # 0x12110
fldt (%rax,%rcx)
fdivrp %st, %st(1)
fldl 0x1bfd9(%rip)           # 0x1e968
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jb 0x29c9
jmp 0x2999
movslq 0x28(%rsp), %rax
shlq $0x4, %rax
leaq 0xf767(%rip), %rcx      # 0x12110
fldt (%rax,%rcx)
fldt 0x30(%rsp)
fdivp %st, %st(1)
fstpt 0x30(%rsp)
movl 0x28(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl 0x2c(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x295e
jmp 0x29cd
fldt 0x30(%rsp)
fldl 0x1bf99(%rip)           # 0x1e970
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jb 0x29fc
jmp 0x29e1
fldt 0xf729(%rip)            # 0x12110
fldt 0x30(%rsp)
fdivp %st, %st(1)
fstpt 0x30(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x29fe
fldt 0x30(%rsp)
xorl %eax, %eax
fldl 0x1bf5e(%rip)           # 0x1e968
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
movb %al, 0x7(%rsp)
jb 0x2a2d
jmp 0x2a18
fldt 0x30(%rsp)
fldl 0x1bf4e(%rip)           # 0x1e970
fucompi %st(1), %st
fstp %st(0)
seta %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
xorb $-0x1, %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x2a6d
xorl %edi, %edi
leaq 0x1bca8(%rip), %rsi     # 0x1e6f5
leaq 0xf68a(%rip), %rdx      # 0x120de
leaq 0x1bc42(%rip), %rcx     # 0x1e69d
movl $0x30, %r8d
movb $0x0, %al
callq 0xe010
callq 0x1060
jmp 0x2a6f
fldt 0x30(%rsp)
flds 0x1bf37(%rip)           # 0x1e9b0
fucomi %st(1), %st
setbe %al
fldz
fcmovbe %st(1), %st
fstp %st(1)
fsubrp %st, %st(1)
fnstcw 0xe(%rsp)
movzwl 0xe(%rsp), %ecx
orl $0xc00, %ecx            # imm = 0xC00
movw %cx, 0xc(%rsp)
fldcw 0xc(%rsp)
fistpll 0x10(%rsp)
fldcw 0xe(%rsp)
movzbl %al, %eax
shlq $0x3f, %rax
movq 0x10(%rsp), %rcx
xorq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, (%rax)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movl %eax, %edi
andl $0x1, %edi
fldt 0x30(%rsp)
movq %rax, 0x18(%rsp)
testq %rax, %rax
sets %al
movzbl %al, %eax
movl %eax, %ecx
fildll 0x18(%rsp)
leaq 0x1be8f(%rip), %rax     # 0x1e978
flds (%rax,%rcx,4)
faddp %st, %st(1)
fsubrp %st, %st(1)
flds 0x1bebe(%rip)           # 0x1e9b4
fmulp %st, %st(1)
fnstcw 0xa(%rsp)
movzwl 0xa(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0x8(%rsp)
fldcw 0x8(%rsp)
fistpll 0x20(%rsp)
fldcw 0xa(%rsp)
movl 0x20(%rsp), %esi
movl $0x2, %edx
callq 0xe9f0
movslq %eax, %rcx
movq 0x48(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl 0x2c(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)