// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/strtod.c
// Function: bignat_extract
static double bignat_extract(struct BigNat *mant, int32_t exponent2) {
    uint64_t top53;
    int32_t n = mant->n;
    /* Get most significant 53 bits from mant. Bit 52 (0 indexed) should
     * always be 1. This is essentially a large right shift on mant.*/
    if (n) {
        /* Two or more digits */
        uint64_t d1 = mant->digits[n - 1]; /* MSD (non-zero) */
        uint64_t d2 = (n == 1) ? mant->first_digit : mant->digits[n - 2];
        uint64_t d3 = (n > 2) ? mant->digits[n - 3] : (n == 2) ? mant->first_digit : 0;
        int lz = clz((uint32_t) d1);
        int nbits = 32 - lz;
        /* First get 54 bits */
        top53 = (d2 << (54 - BIGNAT_NBIT)) + (d3 >> (2 * BIGNAT_NBIT - 54));
        top53 >>= nbits;
        top53 |= (d1 << (54 - nbits));
        /* Rounding based on lowest bit of 54 */
        if (top53 & 1) top53++;
        top53 >>= 1;
        if (top53 > 0x1FffffFFFFffffUL) {
            top53 >>= 1;
            exponent2++;
        }
        /* Correct exponent - to correct for large right shift to mantissa. */
        exponent2 += (nbits - 53) + BIGNAT_NBIT * n;
    } else {
        /* One digit */
        top53 = mant->first_digit;
    }
    return ldexp((double)top53, exponent2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x676d7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x28(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x675bc
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
jmp 0x675d3
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, %eax
movq %rax, -0x30(%rbp)
cmpl $0x2, -0x1c(%rbp)
jle 0x675fb
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1c(%rbp), %ecx
subl $0x3, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
jmp 0x67619
cmpl $0x2, -0x1c(%rbp)
jne 0x6760c
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
jmp 0x67613
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x67613
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, %eax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
bsrl %eax, %eax
xorl $0x1f, %eax
movl %eax, -0x3c(%rbp)
movl $0x20, %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
shlq $0x17, %rax
movq -0x38(%rbp), %rcx
shrq $0x8, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl -0x40(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movl $0x36, %ecx
subl -0x40(%rbp), %ecx
movl %ecx, %ecx
shlq %cl, %rax
orq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x67694
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
shrq %rax
movq %rax, -0x18(%rbp)
movabsq $0x1fffffffffffff, %rax # imm = 0x1FFFFFFFFFFFFF
cmpq %rax, -0x18(%rbp)
jbe 0x676c3
movq -0x18(%rbp), %rax
shrq %rax
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x40(%rbp), %eax
subl $0x35, %eax
imull $0x1f, -0x1c(%rbp), %ecx
addl %ecx, %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x676e1
movq -0x8(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x18(%rbp)
movaps 0x1a198(%rip), %xmm1    # 0x81880
movq -0x18(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1a197(%rip), %xmm1    # 0x81890
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movl -0xc(%rbp), %edi
callq 0x12130
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)