// File: /workspace/github_c_makefile_star2_O3/hfiguiere[P]exifprobe/misc.c
// Function: scan_summary
int
scan_summary(struct image_summary *summary_entry)
{
    struct image_summary *next_entry = NULL;
    struct image_summary *prev_entry = NULL;
    unsigned long long image_size = 0ULL;
    unsigned long long max_image_size = 0ULL;
    unsigned long marked_primary_image_length = 0ULL;
    unsigned long long marked_primary_image_size = 0ULL;
    unsigned long long primary_image_size = 0ULL;
    unsigned long long next_primary_size = 0ULL;
    unsigned long max_image_width = 0UL;
    unsigned long max_image_height = 0UL;
    unsigned long max_image_length = 0UL;
    unsigned long image_length = 0UL;
    int primary_found = 0;
    int number_of_images = 0;

    if(Debug & 0x4)
        (void)newline(1);

    /* The passed entry should be the head; scan forward merging data */
    while(summary_entry/*  && next_entry */)
    {
        if(summary_entry->entry_lock <= 0)
        {
            summary_entry = summary_entry->next_entry;
            continue;
        }
        if(summary_entry)
            next_entry = summary_entry->next_entry;
        if(Debug & 0x4)
        {
            printred("DEBUG:");
            printf(" %d: ffm=%#x, fsf=%#x",summary_entry->entry_lock,
                    summary_entry->fileformat,summary_entry->filesubformat);
            printf(", spp=%d, bps[0]=%d",summary_entry->spp,summary_entry->bps[0]);
        }

        /* 'image_size' in pixels                                     */
        image_size = summary_entry->pixel_width * summary_entry->pixel_height;

        /* image_length vs summary length: compressed? how much?      */
        /* ###%%% this is "experimental" and shows up only in Debug   */
        if(summary_entry->bps[0] && summary_entry->spp)
        {
            int i;
            int spp = summary_entry->spp;
            float total_bits,bytes_per_pixel;

            total_bits = 0;
            if (spp > MAXSAMPLE)
            {
                spp = MAXSAMPLE;
                if(Debug & 0x4)
                {
                    printf("CLAMPING spp\n");
                }
            }
            for(i = 0; i < spp; ++i)
                total_bits += summary_entry->bps[i];
            bytes_per_pixel = total_bits / 8.0;
            if(Debug & 0x4)
                printf(", bytesperpixel=%.1f",bytes_per_pixel);
            image_length = image_size * bytes_per_pixel;
            summary_entry->compress_percent = (float)summary_entry->length / (float)image_length;
            summary_entry->compress_percent *= 100.0;
        }
        if(Debug & 0x4)
            printf(" c=%lu/%lu=%.0f%%\n",summary_entry->length,image_length,
                                            summary_entry->compress_percent);

        if(summary_entry->subfiletype == PRIMARY_TYPE)
        {
            ++primary_found;    /* marked in a TIFF/EP IFD            */
            marked_primary_image_size = image_size;
            marked_primary_image_length = summary_entry->length;
            if(summary_entry->primary_height == 0UL)
                summary_entry->primary_height = summary_entry->pixel_height;
            if(summary_entry->primary_width == 0UL)
                summary_entry->primary_width = summary_entry->pixel_width;
            
        }
        /* maintain max values independently of primary               */
        if(image_size > max_image_size)
        {
            max_image_height = summary_entry->pixel_height;
            max_image_width = summary_entry->pixel_width;
            max_image_size = image_size;
        }

        /* The largest chunk of image data; could be very important   */
        if(summary_entry->length > max_image_length)
            max_image_length = summary_entry->length;

        /* If a primary size was found, e.g. in an exif ifd, carry    */
        /* it forward. If more than one was found, keep the largest.  */
        /* Then carry it back down to the head in the backward loop.  */
        /* Should wind up with all entries the same (and possibly     */
        /* zero).                                                     */
        if(summary_entry->primary_height || summary_entry->primary_width)
        {
            primary_image_size = summary_entry->primary_width * summary_entry->primary_height;
            if(next_entry && (next_entry->primary_height || next_entry->primary_width))
            {
                next_primary_size = next_entry->primary_width * next_entry->primary_height;
                if(next_primary_size > primary_image_size)
                {
                    summary_entry->primary_width = next_entry->primary_width;
                    summary_entry->primary_height = next_entry->primary_height;
                    primary_image_size = next_primary_size;
                }
                else
                {
                    next_entry->primary_width = summary_entry->primary_width;
                    next_entry->primary_height = summary_entry->primary_height;
                }
            }
            else if(next_entry)
            {
                next_entry->primary_width = summary_entry->primary_width;
                next_entry->primary_height = summary_entry->primary_height;
            }
        }
        /* In JPEG format files, it's almost certain that the primary */
        /* begins at the beginning of the file; "almost" only because */
        /* I've seen some strange things...                           */
        if((summary_entry->fileformat == FILEFMT_JPEG) &&
                            (summary_entry->subfiletype == UNKNOWN_TYPE))
        {
            if(summary_entry->offset == 0)
                summary_entry->subfiletype = POSSIBLE_PRIMARY_TYPE;
        }
        
        prev_entry = summary_entry;
        summary_entry = next_entry;
    }
    summary_entry = prev_entry;
    if((Debug & 0x4) && summary_entry)
    {
        printred("DEBUG:");
        printf(" Exif   Primary=%lux%lu = %llu\n",summary_entry->primary_width,summary_entry->primary_height,primary_image_size);
        printred("DEBUG:");
        printf("        Maxsize=%lux%lu = %llu\n",max_image_width,max_image_height,max_image_size);
        printred("DEBUG:");
        printf(" Marked Primary size = %llu",marked_primary_image_size);
        printf(" Marked Primary length=%lu, max length = %lu\n",marked_primary_image_length,max_image_length);
    }

    /* now walk back to the head                                      */
    /* If a marked primary has been found, the primary job is to mark */
    /* reduced resolution images which haven't been defined as        */
    /* thumbnails in the main code. If no marked primary, it is also  */
    /* necessary to deduce the identity of the primary image, using   */
    /* size, length and/or image and compression type.                */

    /* ###%%% at this point, after all the futzing around with        */
    /* primary_width, etc., it never gets used. max_* are used        */
    /* (and primary_image_size may not have been set if the last      */
    /* entry contained the values)                                    */

    if(summary_entry)
        prev_entry = summary_entry->prev_entry;
    while(summary_entry)
    {
        if(Debug & 0x4)
        {
            printred("DEBUG:");
            printf(" #%d se=%#-9x, pe=%#-9x",summary_entry->entry_lock,
                    (unsigned int)summary_entry,(unsigned int)prev_entry);
        }
        image_size = summary_entry->pixel_width * summary_entry->pixel_height;
        image_length = summary_entry->length;
        if(summary_entry->entry_lock <= 0)
        {
            summary_entry = prev_entry;
            if(summary_entry)
                prev_entry = summary_entry->prev_entry;
            continue;
        }
        if(Debug & 0x4)
        {
            printf(" ffm=%#x, fsf=%#-3x",summary_entry->fileformat,summary_entry->filesubformat);
            printf(", ifm=%#lx, isf=%#lx",summary_entry->imageformat,summary_entry->imagesubformat);
            printf(", offs=%lu, len=%lu",summary_entry->offset,summary_entry->length);
            printf(", pw=%lu, ph=%lu",summary_entry->pixel_width,summary_entry->pixel_height);
        }
        if(prev_entry && (prev_entry->subfiletype != PRIMARY_TYPE))
        {
            /* The primary size was carried up to the last entry in   */
            /* the forward scan; now copy it back down.               */
            /* ###%%% is this used?   ...no, never                    */
            prev_entry->primary_width = summary_entry->primary_width;
            prev_entry->primary_height = summary_entry->primary_height;
        }
        if(Debug & 0x4)
            printf(" sft=%d\n",summary_entry->subfiletype);
        if(primary_found >= 1)  /* should never be greater than 1     */
        {
            if(summary_entry->subfiletype == POSSIBLE_PRIMARY_TYPE)
                summary_entry->subfiletype = REDUCED_RES_TYPE;
        }
        else if(primary_found == 0)
        {
            if(summary_entry->subfiletype == POSSIBLE_PRIMARY_TYPE)
            {
                if((summary_entry->fileformat == FILEFMT_TIFF) ||
                    (summary_entry->fileformat == FILEFMT_ORF1) ||
                        (summary_entry->fileformat == FILEFMT_ORF2))
                {
                    switch(summary_entry->compression)
                    {
                        case 1:
                        case 34712:     /* JPEG 2000 */
                        case 34713:     /* NEF compressed */
                        case JPEG_SOF_3:
                        case JPEG_SOF_7:
                        case JPEG_SOF_11:
                        case JPEG_SOF_15:
                            if(image_size >= max_image_size)
                            {
                                summary_entry->subfiletype = PRIMARY_TYPE;
                                ++primary_found;
                            }
                            break;
                        default:
                            if((image_size < max_image_size) || (image_length < max_image_length))
                                summary_entry->subfiletype = REDUCED_RES_TYPE;
                            break;
                    }
                }
                else if(summary_entry->fileformat == FILEFMT_JP2)
                {
                        summary_entry->subfiletype = PRIMARY_TYPE;
                        ++primary_found;
                }
                else if(summary_entry->fileformat == FILEFMT_JPEG)
                {
                    if(summary_entry->offset == 0)
                    {
                        summary_entry->subfiletype = PRIMARY_TYPE;
                        ++primary_found;
                    }
                    else if(summary_entry->filesubformat & (FILESUBFMT_TIFF|FILESUBFMT_TIFFEP))
                    {
                        switch(summary_entry->compression)
                        {
                            case JPEG_SOF_3:
                            case JPEG_SOF_7:
                            case JPEG_SOF_11:
                            case JPEG_SOF_15:
                                /* lossless compression               */
                                if(image_size >= max_image_size)
                                {
                                    summary_entry->subfiletype = PRIMARY_TYPE;
                                    ++primary_found;
                                }
                                break;
                            default:
                                if((image_size < max_image_size) ||
                                                            (image_length < max_image_length))
                                    summary_entry->subfiletype = REDUCED_RES_TYPE;
                                break;
                        }
                    }
                }
                else if(summary_entry->imagesubformat == IMGSUBFMT_CFA)
                {
                    /* fileformat may be MRW; other fileformats?      */
                    if(image_size >= max_image_size)
                    {
                        summary_entry->subfiletype = PRIMARY_TYPE;
                        ++primary_found;
                    }
                    else
                        summary_entry->subfiletype = REDUCED_RES_TYPE;
                }
                else
                    summary_entry->subfiletype = REDUCED_RES_TYPE;
            }
        }

        if(primary_found)
        {
            if(summary_entry->subfiletype <= POSSIBLE_PRIMARY_TYPE)
                summary_entry->subfiletype = REDUCED_RES_TYPE;
        }
        else if(image_size >= max_image_size)
        {
            if(summary_entry->subfiletype == POSSIBLE_PRIMARY_TYPE)
            {
                summary_entry->subfiletype = PRIMARY_TYPE;
                ++primary_found;
            }
        }
        else if(summary_entry->subfiletype <= POSSIBLE_PRIMARY_TYPE)
            summary_entry->subfiletype = REDUCED_RES_TYPE;

        if(((summary_entry->imageformat) != IMGFMT_NOIMAGE) &&
                ((summary_entry->imagesubformat & ~IMGSUBFMT_ERRORMASK) != IMGSUBFMT_JPEGTABLES))
            ++number_of_images;
        if(Debug & 0x4)
        {
            printred("DEBUG:");
            printf(" #%d se=%#-9x, pe=%#-9x",summary_entry->entry_lock,
                    (unsigned int)summary_entry,(unsigned int)prev_entry);
            printf(" ffm=%#x, fsf=%#-3x",summary_entry->fileformat,summary_entry->filesubformat);
            printf(", ifm=%#lx, isf=%#lx",summary_entry->imageformat,summary_entry->imagesubformat);
            printf(", offs=%lu, len=%lu",summary_entry->offset,summary_entry->length);
            printf(", pw=%lu, ph=%lu",summary_entry->pixel_width,summary_entry->pixel_height);
            printf(" sft=%d\n",summary_entry->subfiletype);
        }
        summary_entry = prev_entry;
        if(summary_entry)
            prev_entry = summary_entry->prev_entry;
        else
            prev_entry = NULL;
    }
    if(Debug & 0x4)
        (void)newline(1);
    return(number_of_images);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r15
leaq 0x47050(%rip), %rbp     # 0x5d670
testb $0x4, (%rbp)
je 0x1663a
movl $0xa, %edi
callq 0x3060
movl $0x0, 0x46f0e(%rip)     # 0x5d548
testq %r15, %r15
je 0x16a08
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
xorl %r12d, %r12d
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %rbx, %rax
movq %r15, %rbx
cmpl $0x0, 0x10(%rbx)
movq 0x8(%rbx), %r15
jg 0x166a0
movq %r15, %rbx
testq %r15, %r15
jne 0x16689
jmp 0x16964
movq %r12, 0x20(%rsp)
testb $0x4, (%rbp)
je 0x166e8
leaq 0x2e197(%rip), %rdi     # 0x44849
callq 0x5c26
movl 0x10(%rbx), %esi
movl 0x14(%rbx), %edx
movl 0x18(%rbx), %ecx
leaq 0x2f0b0(%rip), %rdi     # 0x45777
xorl %eax, %eax
callq 0x3120
movl 0xcc(%rbx), %esi
movl 0xd0(%rbx), %edx
leaq 0x2f0ac(%rip), %rdi     # 0x4578d
xorl %eax, %eax
callq 0x3120
movq %r13, 0x10(%rsp)
movq 0x78(%rbx), %r12
imulq 0x70(%rbx), %r12
cmpl $0x0, 0xd0(%rbx)
je 0x16842
movl 0xcc(%rbx), %r13d
testl %r13d, %r13d
je 0x16842
cmpl $0x11, %r13d
jl 0x16733
movl $0x10, %r13d
testb $0x4, (%rbp)
je 0x1673c
leaq 0x2f824(%rip), %rdi     # 0x45f50
callq 0x30a0
jmp 0x1673c
testl %r13d, %r13d
jle 0x1695c
movl %r13d, %eax
xorps %xmm2, %xmm2
xorl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2ssl 0xd0(%rbx,%rcx,4), %xmm0
addss %xmm0, %xmm2
incq %rcx
cmpq %rcx, %rax
jne 0x16744
mulss 0x2edd0(%rip), %xmm2    # 0x45534
testb $0x4, (%rbp)
je 0x16789
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
leaq 0x2f029(%rip), %rdi     # 0x457a1
movb $0x1, %al
movaps %xmm2, 0x40(%rsp)
callq 0x3120
movaps 0x40(%rsp), %xmm2
testq %r12, %r12
js 0x16798
xorps %xmm0, %xmm0
cvtsi2ss %r12, %xmm0
jmp 0x167b3
movq %r12, %rax
shrq %rax
movl %r12d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
mulss %xmm0, %xmm2
movaps %xmm2, %xmm1
subss 0x2ed76(%rip), %xmm1    # 0x45538
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x167d8
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
jmp 0x167f0
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
cvttss2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
cvttss2si %xmm1, %r14
andq %rcx, %r14
orq %rax, %r14
js 0x16813
xorps %xmm1, %xmm1
cvtsi2ss %r14, %xmm1
jmp 0x1682e
movq %r14, %rax
shrq %rax
movl %r14d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
xorps %xmm1, %xmm1
cvtsi2ss %rcx, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
mulss 0x2ed02(%rip), %xmm0    # 0x4553c
movss %xmm0, 0x114(%rbx)
testb $0x4, (%rbp)
je 0x1686b
movq 0x98(%rbx), %rsi
xorps %xmm0, %xmm0
cvtss2sd 0x114(%rbx), %xmm0
leaq 0x2ef55(%rip), %rdi     # 0x457b6
movq %r14, %rdx
movb $0x1, %al
callq 0x3120
movl 0xc4(%rbx), %eax
cmpl $0x1, %eax
movq 0x10(%rsp), %r13
jne 0x168ae
cmpq $0x0, 0x68(%rbx)
jne 0x1688a
movq 0x78(%rbx), %rcx
movq %rcx, 0x68(%rbx)
incl 0x4(%rsp)
movq 0x98(%rbx), %rcx
movq %rcx, 0x18(%rsp)
cmpq $0x0, 0x60(%rbx)
jne 0x168a9
movq 0x70(%rbx), %rcx
movq %rcx, 0x60(%rbx)
movq %r12, 0x28(%rsp)
cmpq %r13, %r12
jbe 0x168c8
movq 0x70(%rbx), %rcx
movq %rcx, 0x30(%rsp)
movq 0x78(%rbx), %rcx
movq %rcx, 0x38(%rsp)
movq %r12, %r13
movq 0x98(%rbx), %rcx
movq 0x20(%rsp), %r12
cmpq %r12, %rcx
cmovaq %rcx, %r12
movq 0x60(%rbx), %rdx
movq 0x68(%rbx), %rcx
movq %rcx, %rsi
orq %rdx, %rsi
je 0x1692f
movq %rdx, %rsi
imulq %rcx, %rsi
testq %r15, %r15
je 0x1692a
movq 0x60(%r15), %r8
movq 0x68(%r15), %rdi
movq %rdi, %r9
orq %r8, %r9
je 0x16922
movq %r8, %r9
imulq %rdi, %r9
movq %r9, 0x8(%rsp)
cmpq %rsi, %r9
jbe 0x16922
movq %r8, 0x60(%rbx)
movq %rdi, 0x68(%rbx)
jmp 0x1692f
movq %rdx, 0x60(%r15)
movq %rcx, 0x68(%r15)
movq %rsi, 0x8(%rsp)
cmpl $-0x1, %eax
jne 0x16951
cmpl $0xffd8, 0x14(%rbx)     # imm = 0xFFD8
jne 0x16951
cmpq $0x0, 0x90(%rbx)
jne 0x16951
movl $0x0, 0xc4(%rbx)
testq %r15, %r15
jne 0x16683
jmp 0x16967
xorps %xmm2, %xmm2
jmp 0x16764
movq %rax, %rbx
movl (%rbp), %eax
testb $0x4, %al
je 0x16a10
testq %rbx, %rbx
je 0x16a10
leaq 0x2dec7(%rip), %r14     # 0x44849
movq %r14, %rdi
callq 0x5c26
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
leaq 0x2ee30(%rip), %rdi     # 0x457c9
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x3120
movq %r14, %rdi
callq 0x5c26
leaq 0x2ee35(%rip), %rdi     # 0x457e9
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, 0x10(%rsp)
movq %r13, %rcx
xorl %eax, %eax
callq 0x3120
movq %r14, %rdi
callq 0x5c26
leaq 0x2ee2d(%rip), %rdi     # 0x45809
movq 0x28(%rsp), %rsi
xorl %eax, %eax
callq 0x3120
leaq 0x2ee36(%rip), %rdi     # 0x45825
movq 0x18(%rsp), %rsi
movq %r12, 0x20(%rsp)
movq %r12, %rdx
xorl %eax, %eax
callq 0x3120
movl (%rbp), %eax
jmp 0x16a23
movl (%rbp), %eax
jmp 0x16d99
testq %rbx, %rbx
je 0x16d99
movq %r13, 0x10(%rsp)
movq %r12, 0x20(%rsp)
leaq 0x2de1f(%rip), %r12     # 0x44849
leaq 0x2ee22(%rip), %r13     # 0x45853
xorl %r15d, %r15d
movq %rbx, %r14
movq (%r14), %rbx
testb $0x4, %al
je 0x16a5c
movq %r12, %rdi
callq 0x5c26
movl 0x10(%r14), %esi
movq %r13, %rdi
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x3120
movl (%rbp), %eax
cmpl $0x0, 0x10(%r14)
jg 0x16a70
movq %rbx, %r14
testq %rbx, %rbx
jne 0x16a37
jmp 0x16d9c
movl %r15d, 0x8(%rsp)
movq 0x98(%r14), %rcx
movq %rcx, 0x18(%rsp)
movq 0x78(%r14), %r15
imulq 0x70(%r14), %r15
testb $0x4, %al
je 0x16af2
movl 0x14(%r14), %esi
movl 0x18(%r14), %edx
leaq 0x2edce(%rip), %rdi     # 0x4586b
xorl %eax, %eax
callq 0x3120
movq 0x80(%r14), %rsi
movq 0x88(%r14), %rdx
leaq 0x2edc6(%rip), %rdi     # 0x4587f
xorl %eax, %eax
callq 0x3120
movq 0x90(%r14), %rsi
movq 0x98(%r14), %rdx
leaq 0x2edbf(%rip), %rdi     # 0x45894
xorl %eax, %eax
callq 0x3120
movq 0x70(%r14), %rsi
movq 0x78(%r14), %rdx
leaq 0x2edbd(%rip), %rdi     # 0x458a8
xorl %eax, %eax
callq 0x3120
testq %rbx, %rbx
je 0x16b09
cmpl $0x1, 0xc4(%rbx)
je 0x16b09
movups 0x60(%r14), %xmm0
movups %xmm0, 0x60(%rbx)
testb $0x4, (%rbp)
je 0x16b24
movl 0xc4(%r14), %esi
leaq 0x2ed9c(%rip), %rdi     # 0x458b9
xorl %eax, %eax
callq 0x3120
cmpl $0x0, 0x4(%rsp)
jle 0x16b48
movl 0xc4(%r14), %eax
testl %eax, %eax
jne 0x16b55
movl $0x5, 0xc4(%r14)
movl 0x8(%rsp), %r15d
jmp 0x16b69
movl 0xc4(%r14), %eax
je 0x16c3e
testl %eax, %eax
movl 0x8(%rsp), %r15d
jg 0x16b69
movl $0x5, 0xc4(%r14)
cmpq $0x0, 0x80(%r14)
je 0x16b8e
movl 0x88(%r14), %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
andl %ecx, %eax
xorl %ecx, %ecx
cmpl $0x15b, %eax            # imm = 0x15B
setne %cl
addl %ecx, %r15d
movl (%rbp), %eax
testb $0x4, %al
je 0x16c30
movq %r12, %rdi
callq 0x5c26
movl 0x10(%r14), %esi
movq %r13, %rdi
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x3120
movl 0x14(%r14), %esi
movl 0x18(%r14), %edx
leaq 0x2eca8(%rip), %rdi     # 0x4586b
xorl %eax, %eax
callq 0x3120
movq 0x80(%r14), %rsi
movq 0x88(%r14), %rdx
leaq 0x2eca0(%rip), %rdi     # 0x4587f
xorl %eax, %eax
callq 0x3120
movq 0x90(%r14), %rsi
movq 0x98(%r14), %rdx
leaq 0x2ec99(%rip), %rdi     # 0x45894
xorl %eax, %eax
callq 0x3120
movq 0x70(%r14), %rsi
movq 0x78(%r14), %rdx
leaq 0x2ec97(%rip), %rdi     # 0x458a8
xorl %eax, %eax
callq 0x3120
movl 0xc4(%r14), %esi
leaq 0x2ec93(%rip), %rdi     # 0x458b9
xorl %eax, %eax
callq 0x3120
movl (%rbp), %eax
testq %rbx, %rbx
jne 0x16a34
jmp 0x16d9c
testl %eax, %eax
je 0x16c83
cmpq 0x10(%rsp), %r15
jae 0x16c56
movl $0x0, 0x4(%rsp)
jmp 0x16b55
movl $0x0, 0x4(%rsp)
testl %eax, %eax
movl 0x8(%rsp), %r15d
jne 0x16b69
movl $0x1, 0xc4(%r14)
movl $0x1, 0x4(%rsp)
jmp 0x16b69
movl 0x14(%r14), %eax
cmpl $0x5351, %eax           # imm = 0x5351
jle 0x16cac
cmpl $0xd0a870a, %eax        # imm = 0xD0A870A
je 0x16d40
cmpl $0xffd8, %eax           # imm = 0xFFD8
je 0x16cf2
cmpl $0x5352, %eax           # imm = 0x5352
je 0x16cb8
jmp 0x16d2c
cmpl $0x2a, %eax
je 0x16cb8
cmpl $0x4f52, %eax           # imm = 0x4F52
jne 0x16d2c
movl 0xc8(%r14), %eax
leal -0xffc3(%rax), %ecx
cmpl $0xc, %ecx
ja 0x16cd4
movl $0x1111, %edx           # imm = 0x1111
btl %ecx, %edx
jb 0x16ce4
leal -0x8798(%rax), %ecx
cmpl $0x2, %ecx
jb 0x16ce4
cmpl $0x1, %eax
jne 0x16d58
cmpq 0x10(%rsp), %r15
jae 0x16d40
xorl %eax, %eax
jmp 0x16c42
cmpq $0x0, 0x90(%r14)
je 0x16d40
xorl %eax, %eax
testb $0x5, 0x18(%r14)
je 0x16c42
movl 0xc8(%r14), %ecx
movl $0xffff003d, %edx       # imm = 0xFFFF003D
addl %edx, %ecx
roll $0x1e, %ecx
cmpl $0x3, %ecx
ja 0x16d6d
cmpq 0x10(%rsp), %r15
jb 0x16c42
jmp 0x16d40
cmpq $0x18023, 0x88(%r14) # imm = 0x18023
jne 0x16d84
cmpq 0x10(%rsp), %r15
jb 0x16d84
movl $0x1, 0xc4(%r14)
movl $0x1, 0x4(%rsp)
jmp 0x16b41
cmpq 0x10(%rsp), %r15
jb 0x16d84
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0x16ceb
jmp 0x16d84
cmpq 0x10(%rsp), %r15
jb 0x16d84
movq 0x18(%rsp), %rcx
cmpq 0x20(%rsp), %rcx
jae 0x16c42
movl $0x5, 0xc4(%r14)
movl $0x5, %eax
jmp 0x16c42
xorl %r15d, %r15d
testb $0x4, %al
je 0x16db4
movl $0xa, %edi
callq 0x3060
movl $0x0, 0x46794(%rip)     # 0x5d548
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq