// File: /workspace/github_c_makefile_star2_O3/Matthias-Wandel[P]imgcomp/src/exif.c
// Function: ProcessExifDir
static void ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, 
        unsigned ExifLength, int NestingLevel)
{
    int de;
    int a;
    int NumDirEntries;
    char IndentString[25];

    if (NestingLevel > 4){
        ErrNonfatal("Maximum Exif directory nesting exceeded (corrupt Exif header)", 0,0);
        return;
    }

    memset(IndentString, ' ', 25);
    IndentString[NestingLevel * 4] = '\0';


    NumDirEntries = Get16u(DirStart);
    #define DIR_ENTRY_ADDR(Start, Entry) (Start+2+12*(Entry))

    {
        unsigned char * DirEnd;
        DirEnd = DIR_ENTRY_ADDR(DirStart, NumDirEntries);
        if (DirEnd+4 > (OffsetBase+ExifLength)){
            if (DirEnd+2 == OffsetBase+ExifLength || DirEnd == OffsetBase+ExifLength){
                // Version 1.3 of jhead would truncate a bit too much.
                // This also caught later on as well.
            }else{
                ErrNonfatal("Illegally sized Exif subdirectory (%d entries)",NumDirEntries,0);
                return;
            }
        }
    }

    if (ShowTags){
        printf("(dir has %d entries)\n",NumDirEntries);
    }

    for (de=0;de<NumDirEntries;de++){
        int Tag, Format, Components;
        unsigned char * ValuePtr;
        int ByteCount;
        unsigned char * DirEntry;
        DirEntry = DIR_ENTRY_ADDR(DirStart, de);

        Tag = Get16u(DirEntry);
        Format = Get16u(DirEntry+2);
        Components = Get32u(DirEntry+4);

        if ((Format-1) >= NUM_FORMATS) {
            // (-1) catches illegal zero case as unsigned underflows to positive large.
            ErrNonfatal("Illegal number format %d for tag %04x in Exif", Format, Tag);
            continue;
        }

        if ((unsigned)Components > 0x10000){
            ErrNonfatal("Too many components %d for tag %04x in Exif", Components, Tag);
            continue;
        }

        ByteCount = Components * BytesPerFormat[Format];

        if (ByteCount > 4){
            unsigned OffsetVal;
            OffsetVal = Get32u(DirEntry+8);
            // If its bigger than 4 bytes, the dir entry contains an offset.
            if (OffsetVal+ByteCount > ExifLength){
                // Bogus pointer offset and / or bytecount value
                ErrNonfatal("Illegal value pointer for tag %04x in Exif", Tag,0);
                continue;
            }
            ValuePtr = OffsetBase+OffsetVal;
        }else{
            // 4 bytes or less and value is in the dir entry itself
            ValuePtr = DirEntry+8;
        }

        if (ShowTags){
            // Show tag name
            for (a=0;;a++){
                if (a >= TAG_TABLE_SIZE){
                    printf("%s    Unknown Tag %04x Value = ", IndentString, Tag);
                    break;
                }
                if (TagTable[a].Tag == Tag){
                    printf("%s    %s = ",IndentString, TagTable[a].Desc);
                    break;
                }
            }

            // Show tag value.
            switch(Format){
                case FMT_BYTE:
                    if(ByteCount>1){
                        printf("%.*ls\n", ByteCount/2, (wchar_t *)ValuePtr);
                    }else{
                        PrintFormatNumber(ValuePtr, Format, ByteCount);
                        printf("\n");
                    }
                    break;

                case FMT_UNDEFINED:
                    // Undefined is typically an ascii string.

                case FMT_STRING:
                    // String arrays printed without function call (different from int arrays)
                    {
                        int NoPrint = 0;
                        printf("\"");
                        for (a=0;a<ByteCount;a++){
                            if (ValuePtr[a] >= 32){
                                putchar(ValuePtr[a]);
                                NoPrint = 0;
                            }else{
                                // Avoiding indicating too many unprintable characters of proprietary
                                // bits of binary information this program may not know how to parse.
                                if (!NoPrint && a != ByteCount-1){
                                    putchar('?');
                                    NoPrint = 1;
                                }
                            }
                        }
                        printf("\"\n");
                    }
                    break;

                default:
                    // Handle arrays of numbers later (will there ever be?)
                    PrintFormatNumber(ValuePtr, Format, ByteCount);
                    printf("\n");
            }
        }

        // Extract useful components of tag
        switch(Tag){

            case TAG_MAKE:
                strncpy(ImageInfo.CameraMake, (char *)ValuePtr, ByteCount < 31 ? ByteCount : 31);
                break;

            case TAG_MODEL:
                strncpy(ImageInfo.CameraModel, (char *)ValuePtr, ByteCount < 39 ? ByteCount : 39);
                break;

            case TAG_DATETIME_ORIGINAL:
                // If we get a DATETIME_ORIGINAL, we use that one.
                strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19);
                // Fallthru...

            case TAG_DATETIME_DIGITIZED:
            case TAG_DATETIME:
                if (!isdigit(ImageInfo.DateTime[0])){
                    // If we don't already have a DATETIME_ORIGINAL, use whatever
                    // time fields we may have.
                    strncpy(ImageInfo.DateTime, (char *)ValuePtr, 19);
                }
                break;

            case TAG_FNUMBER:
                // Simplest way of expressing aperture, so I trust it the most.
                // (overwrite previously computd value if there is one)
                ImageInfo.ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format);
                break;

#if 0 // don't pull in extra math stuff.
            case TAG_APERTURE:
            case TAG_MAXAPERTURE:
                // More relevant info always comes earlier, so only use this field if we don't 
                // have appropriate aperture information yet.
                if (ImageInfo.ApertureFNumber == 0){
                    ImageInfo.ApertureFNumber 
                        = (float)exp(ConvertAnyFormat(ValuePtr, Format)*log(2)*0.5);
                }
                break;

            case TAG_SHUTTERSPEED:
                // More complicated way of expressing exposure time, so only use
                // this value if we don't already have it from somewhere else.
                if (ImageInfo.ExposureTime == 0){
                    ImageInfo.ExposureTime 
                        = (float)(1/exp(ConvertAnyFormat(ValuePtr, Format)*log(2)));
                }
                break;
#endif
            case TAG_FOCALLENGTH:
                // Nice digital cameras actually save the focal length as a function
                // of how farthey are zoomed in.
                ImageInfo.FocalLength = (float)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_SUBJECT_DISTANCE:
                // Inidcates the distacne the autofocus camera is focused to.
                // Tends to be less accurate as distance increases.
                ImageInfo.Distance = (float)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_EXPOSURETIME:
                // Simplest way of expressing exposure time, so I trust it most.
                // (overwrite previously computd value if there is one)
                ImageInfo.ExposureTime = (float)ConvertAnyFormat(ValuePtr, Format);
                break;



            case TAG_FLASH:
                ImageInfo.FlashUsed=(int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_ORIENTATION:
                ImageInfo.Orientation = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_PIXEL_Y_DIMENSION:
            case TAG_PIXEL_X_DIMENSION:
                // Use largest of height and width to deal with images that have been
                // rotated to portrait format.
                a = (int)ConvertAnyFormat(ValuePtr, Format);
                if (ExifImageWidth < a) ExifImageWidth = a;
                break;

            case TAG_FOCAL_PLANE_XRES:
                FocalplaneXRes = ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_FOCAL_PLANE_UNITS:
                switch((int)ConvertAnyFormat(ValuePtr, Format)){
                    case 1: FocalplaneUnits = 25.4; break; // inch
                    case 2: 
                        // According to the information I was using, 2 means meters.
                        // But looking at the Cannon powershot's files, inches is the only
                        // sensible value.
                        FocalplaneUnits = 25.4;
                        break;

                    case 3: FocalplaneUnits = 10;   break;  // centimeter
                    case 4: FocalplaneUnits = 1;    break;  // millimeter
                    case 5: FocalplaneUnits = .001; break;  // micrometer
                }
                break;

            case TAG_EXPOSURE_BIAS:
                ImageInfo.ExposureBias = (float)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_WHITEBALANCE:
                ImageInfo.Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_LIGHT_SOURCE:
                ImageInfo.LightSource = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_METERING_MODE:
                ImageInfo.MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_EXPOSURE_PROGRAM:
                ImageInfo.ExposureProgram = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_EXPOSURE_INDEX:
                if (ImageInfo.ISOequivalent == 0){
                    // Exposure index and ISO equivalent are often used interchangeably,
                    // so we will do the same in jhead.
                    // http://photography.about.com/library/glossary/bldef_ei.htm
                    ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format);
                }
                break;

            case TAG_EXPOSURE_MODE:
                ImageInfo.ExposureMode = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_ISO_EQUIVALENT:
                ImageInfo.ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_DIGITALZOOMRATIO:
                ImageInfo.DigitalZoomRatio = (float)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_EXIF_OFFSET:
                if (ShowTags) printf("%s    Exif Dir:",IndentString);

            case TAG_INTEROP_OFFSET:
                if (Tag == TAG_INTEROP_OFFSET && ShowTags) printf("%s    Interop Dir:",IndentString);
                {
                    unsigned char * SubdirStart;
                    SubdirStart = OffsetBase + Get32u(ValuePtr);
                    if (SubdirStart < OffsetBase || SubdirStart > OffsetBase+ExifLength){
                        ErrNonfatal("Illegal Exif or interop ofset directory link",0,0);
                    }else{
                        ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1);
                    }
                    continue;
                }
                break;

            case TAG_FOCALLENGTH_35MM:
                // The focal length equivalent 35 mm is a 2.2 tag (defined as of April 2002)
                // if its present, use it to compute equivalent focal length instead of 
                // computing it from sensor geometry and actual focal length.
                ImageInfo.FocalLength35mmEquiv = (unsigned)ConvertAnyFormat(ValuePtr, Format);
                break;

            case TAG_DISTANCE_RANGE:
                // Three possible standard values:
                //   1 = macro, 2 = close, 3 = distant
                ImageInfo.DistanceRange = (int)ConvertAnyFormat(ValuePtr, Format);
                break;



            case TAG_X_RESOLUTION:
                if (NestingLevel==0) {// Only use the values from the top level directory
                    ImageInfo.xResolution = (float)ConvertAnyFormat(ValuePtr,Format);
                    // if yResolution has not been set, use the value of xResolution
                    if (ImageInfo.yResolution == 0.0) ImageInfo.yResolution = ImageInfo.xResolution;
                }
                break;

            case TAG_Y_RESOLUTION:
                if (NestingLevel==0) {// Only use the values from the top level directory
                    ImageInfo.yResolution = (float)ConvertAnyFormat(ValuePtr,Format);
                    // if xResolution has not been set, use the value of yResolution
                    if (ImageInfo.xResolution == 0.0) ImageInfo.xResolution = ImageInfo.yResolution;
                }
                break;

            case TAG_RESOLUTION_UNIT:
                if (NestingLevel==0) {// Only use the values from the top level directory
                    ImageInfo.ResolutionUnit = (int) ConvertAnyFormat(ValuePtr,Format);
                }
                break;

        }
    }


    {
        // In addition to linking to subdirectories via exif tags, 
        // there's also a potential link to another directory at the end of each
        // directory.  this has got to be the result of a committee!
        unsigned char * SubdirStart;
        unsigned Offset;

        if (DIR_ENTRY_ADDR(DirStart, NumDirEntries) + 4 <= OffsetBase+ExifLength){
            Offset = Get32u(DirStart+2+12*NumDirEntries);
            if (Offset){
                SubdirStart = OffsetBase + Offset;
                if (SubdirStart > OffsetBase+ExifLength || SubdirStart < OffsetBase){
                    if (SubdirStart > OffsetBase && SubdirStart < OffsetBase+ExifLength+20){
                        // Jhead 1.3 or earlier would crop the whole directory!
                        // As Jhead produces this form of format incorrectness, 
                        // I'll just let it pass silently
                        if (ShowTags) printf("Thumbnail removed with Jhead 1.3 or earlier\n");
                    }else{
                        ErrNonfatal("Illegal subdirectory link in Exif header",0,0);
                    }
                }else{
                    if (SubdirStart <= OffsetBase+ExifLength){
                        if (ShowTags) printf("%s    Continued directory ",IndentString);
                        ProcessExifDir(SubdirStart, OffsetBase, ExifLength, NestingLevel+1);
                    }
                }
            }
        }else{
            // The exif header ends before the last next directory pointer.
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, 0x10(%rsp)
cmpl $0x5, %ecx
jl 0x8020
leaq 0x53e4(%rip), %rdi      # 0xd3fd
xorl %esi, %esi
jmp 0x80a2
movl %ecx, %r15d
movl %edx, %ebp
movq %rdi, %r12
movapd 0x4e10(%rip), %xmm0     # 0xce40
movupd %xmm0, 0x39(%rsp)
movapd %xmm0, 0x30(%rsp)
movl %ecx, %eax
movb $0x0, 0x30(%rsp,%rax,4)
cmpl $0x0, 0xc4d2(%rip)      # 0x1451c
je 0x805b
movzwl (%r12), %eax
rolw $0x8, %ax
movzwl %ax, %r14d
jmp 0x8060
movzwl (%r12), %r14d
leal (,%r14,4), %eax
leal (%rax,%rax,2), %eax
leaq (%r12,%rax), %rdx
addq $0x2, %rdx
leaq (%r12,%rax), %rbx
addq $0x6, %rbx
movl %ebp, %ecx
addq 0x10(%rsp), %rcx
cmpq %rcx, %rdx
je 0x80ba
cmpq %rcx, %rbx
jbe 0x80ba
addq %r12, %rax
addq $0x4, %rax
cmpq %rcx, %rax
je 0x80ba
leaq 0x539c(%rip), %rdi      # 0xd43b
movl %r14d, %esi
xorl %edx, %edx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x781c
movq %rdx, 0x60(%rsp)
movq %rcx, 0x78(%rsp)
leaq 0xb385(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x80e1
leaq 0x5393(%rip), %rdi      # 0xd46a
movl %r14d, %esi
xorl %eax, %eax
callq 0x3170
movq %rbx, 0x70(%rsp)
testl %r14d, %r14d
je 0x891a
addq $0x2, %r12
leal 0x1(%r15), %eax
movl %eax, 0x18(%rsp)
movl %r14d, %eax
movq %rax, 0x88(%rsp)
movl $0x1008, %eax           # imm = 0x1008
addq 0x9ec6(%rip), %rax      # 0x11fd8
movq %rax, 0x58(%rsp)
movl $0x1028, %eax           # imm = 0x1028
addq 0x9eb5(%rip), %rax      # 0x11fd8
movq %rax, 0x50(%rsp)
movl $0x1050, %eax           # imm = 0x1050
addq 0x9ea4(%rip), %rax      # 0x11fd8
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
movq %r15, 0x68(%rsp)
movl %ebp, 0x1c(%rsp)
movq %r12, 0x90(%rsp)
leaq (%rbx,%rbx,2), %rax
leaq (%r12,%rax,4), %r12
cmpl $0x0, 0xc3c1(%rip)      # 0x1451c
je 0x817a
movzwl (%r12), %eax
movzwl 0x2(%r12), %ecx
rolw $0x8, %ax
movzwl %ax, %r14d
rolw $0x8, %cx
movzwl %cx, %r13d
jmp 0x8185
movzwl (%r12), %r14d
movzwl 0x2(%r12), %r13d
leaq 0x4(%r12), %rdi
callq 0x7b8c
cmpl $0xd, %r13d
movl %r13d, %esi
jb 0x81a1
leaq 0x52e1(%rip), %rdi      # 0xd480
jmp 0x81b1
cmpl $0x10001, %eax          # imm = 0x10001
jb 0x81d7
leaq 0x52ff(%rip), %rdi      # 0xd4ae
movl %eax, %esi
movl %r14d, %edx
callq 0x781c
incq %rbx
cmpq 0x88(%rsp), %rbx
movq 0x90(%rsp), %r12
jne 0x814c
jmp 0x891a
movl %esi, %ecx
leaq 0x4bb0(%rip), %rdx      # 0xcd90
movl (%rdx,%rcx,4), %r13d
imull %eax, %r13d
addq $0x8, %r12
cmpl $0x5, %r13d
movl %esi, 0xc(%rsp)
jl 0x8220
movq %r12, %rdi
callq 0x7b8c
leal (%rax,%r13), %ecx
cmpl %ebp, %ecx
jbe 0x8214
leaq 0x52cd(%rip), %rdi      # 0xd4da
movl %r14d, %esi
xorl %edx, %edx
jmp 0x81b4
movl %eax, %r12d
addq 0x10(%rsp), %r12
movl 0xc(%rsp), %esi
leaq 0xb229(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x837a
movl $0x8, %eax
leaq 0x94e4(%rip), %rcx      # 0x11720
movzwl -0x8(%rax,%rcx), %ecx
cmpl %ecx, %r14d
je 0x826a
addq $0x10, %rax
cmpq $0x6a8, %rax            # imm = 0x6A8
jne 0x8235
leaq 0x52ac(%rip), %rdi      # 0xd505
leaq 0x30(%rsp), %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x3170
jmp 0x8288
leaq 0x94af(%rip), %rcx      # 0x11720
movq (%rax,%rcx), %rdx
leaq 0x52a9(%rip), %rdi      # 0xd525
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
movl 0xc(%rsp), %eax
cmpl $0x7, %eax
je 0x82c4
cmpl $0x2, %eax
je 0x82c4
cmpl $0x1, %eax
jne 0x8353
cmpl $0x2, %r13d
jl 0x835c
movl %r13d, %esi
shrl %esi
leaq 0x527c(%rip), %rdi      # 0xd531
movq %r12, %rdx
xorl %eax, %eax
callq 0x3170
jmp 0x8376
movl $0x22, %edi
callq 0x3050
movq %r13, 0x28(%rsp)
testl %r13d, %r13d
jle 0x8333
movq 0x28(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0x80(%rsp)
movl %eax, %r15d
xorl %ebp, %ebp
xorl %r13d, %r13d
movzbl (%r12,%rbp), %edi
cmpl $0x20, %edi
jb 0x8304
xorl %r13d, %r13d
callq 0x3050
jmp 0x830f
testl %r13d, %r13d
movl $0x1, %r13d
je 0x8319
incq %rbp
cmpq %rbp, %r15
jne 0x82f0
jmp 0x8333
xorl %r13d, %r13d
cmpq %rbp, 0x80(%rsp)
je 0x830f
movl $0x1, %r13d
movl $0x3f, %edi
jmp 0x82fd
leaq 0x2e74(%rip), %rdi      # 0xb1ae
callq 0x30c0
movq 0x68(%rsp), %r15
movl 0x1c(%rsp), %ebp
movl 0xc(%rsp), %esi
movq 0x28(%rsp), %r13
jmp 0x837a
movq %r12, %rdi
movl 0xc(%rsp), %esi
jmp 0x8364
movq %r12, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x7c0a
movl $0xa, %edi
callq 0x3050
movl 0xc(%rsp), %esi
cmpl $0x9203, %r14d          # imm = 0x9203
jle 0x83db
cmpl $0xa004, %r14d          # imm = 0xA004
jle 0x846f
cmpl $0xa214, %r14d          # imm = 0xA214
jle 0x84e8
leal -0xa402(%r14), %eax
cmpl $0xa, %eax
ja 0x8860
leaq 0x4924(%rip), %rcx      # 0xccd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xb088(%rip), %rcx      # 0x13458
movl %eax, 0x10a4(%rcx)
jmp 0x81b9
cmpl $0x8299, %r14d          # imm = 0x8299
jg 0x84af
cmpl $0x119, %r14d           # imm = 0x119
jle 0x8518
cmpl $0x127, %r14d           # imm = 0x127
jg 0x861d
cmpl $0x11a, %r14d           # imm = 0x11A
je 0x870f
cmpl $0x11b, %r14d           # imm = 0x11B
jne 0x81b9
testl %r15d, %r15d
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xb020(%rip), %rax      # 0x13458
movss %xmm0, 0x10b8(%rax)
movss 0x10b4(%rax), %xmm1
ucomiss 0x4a01(%rip), %xmm1     # 0xce50
jne 0x81b9
jp 0x81b9
leaq 0xaff6(%rip), %rax      # 0x13458
movss %xmm0, 0x10b4(%rax)
jmp 0x81b9
leal -0x9204(%r14), %eax
cmpl $0x6, %eax
ja 0x85e9
leaq 0x4836(%rip), %rcx      # 0xccbc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xafb6(%rip), %rax      # 0x13458
movss %xmm0, 0x108c(%rax)
jmp 0x81b9
cmpl $0x8821, %r14d          # imm = 0x8821
jle 0x855d
cmpl $0x9002, %r14d          # imm = 0x9002
jg 0x863c
cmpl $0x8822, %r14d          # imm = 0x8822
je 0x8762
cmpl $0x8827, %r14d          # imm = 0x8827
je 0x8881
jmp 0x81b9
cmpl $0xa005, %r14d          # imm = 0xA005
je 0x85a3
cmpl $0xa20e, %r14d          # imm = 0xA20E
je 0x850b
cmpl $0xa210, %r14d          # imm = 0xA210
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
jmp 0x81b9
cmpl $0x10f, %r14d           # imm = 0x10F
je 0x881e
cmpl $0x110, %r14d           # imm = 0x110
je 0x87e7
cmpl $0x112, %r14d           # imm = 0x112
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xaf06(%rip), %rcx      # 0x13458
movl %eax, 0x106c(%rcx)
jmp 0x81b9
cmpl $0x829a, %r14d          # imm = 0x829A
je 0x8840
cmpl $0x829d, %r14d          # imm = 0x829D
je 0x87fe
cmpl $0x8769, %r14d          # imm = 0x8769
jne 0x81b9
leaq 0xaec5(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x85a3
leaq 0x4fa1(%rip), %rdi      # 0xd538
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
cmpl $0xa005, %r14d          # imm = 0xA005
jne 0x85cb
leaq 0xae9d(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x85cb
leaq 0x4f89(%rip), %rdi      # 0xd548
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
movq %r12, %rdi
callq 0x7b8c
cmpl %ebp, %eax
jbe 0x865b
leaq 0x4f79(%rip), %rdi      # 0xd55b
xorl %esi, %esi
jmp 0x8210
addl $0xffff5ffe, %r14d      # imm = 0xFFFF5FFE
cmpl $0x2, %r14d
jae 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
cmpl %eax, 0xbf14(%rip)      # 0x14520
jge 0x81b9
movl %eax, 0xbf08(%rip)      # 0x14520
jmp 0x81b9
cmpl $0x128, %r14d           # imm = 0x128
je 0x8780
cmpl $0x132, %r14d           # imm = 0x132
je 0x87b9
jmp 0x81b9
cmpl $0x9003, %r14d          # imm = 0x9003
je 0x87a7
cmpl $0x9004, %r14d          # imm = 0x9004
je 0x87b9
jmp 0x81b9
movl %eax, %edi
movq 0x10(%rsp), %rsi
addq %rsi, %rdi
movl %ebp, %edx
movl 0x18(%rsp), %ecx
callq 0x7ff7
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xadd0(%rip), %rcx      # 0x13458
movl %eax, 0x1078(%rcx)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xadb2(%rip), %rax      # 0x13458
movss %xmm0, 0x107c(%rax)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xad92(%rip), %rcx      # 0x13458
movl %eax, 0x10ac(%rcx)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xad74(%rip), %rax      # 0x13458
movss %xmm0, 0x1088(%rax)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xad54(%rip), %rcx      # 0x13458
movl %eax, 0x109c(%rcx)
jmp 0x81b9
testl %r15d, %r15d
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xad2d(%rip), %rax      # 0x13458
movss %xmm0, 0x10b4(%rax)
movss 0x10b8(%rax), %xmm1
ucomiss 0x470e(%rip), %xmm1     # 0xce50
jne 0x81b9
jp 0x81b9
leaq 0xad03(%rip), %rax      # 0x13458
movss %xmm0, 0x10b8(%rax)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xace3(%rip), %rcx      # 0x13458
movl %eax, 0x10a0(%rcx)
jmp 0x81b9
testl %r15d, %r15d
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xacbc(%rip), %rcx      # 0x13458
movl %eax, 0x10bc(%rcx)
jmp 0x81b9
movl $0x13, %edx
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x3090
callq 0x3510
movq (%rax), %rax
leaq 0xac90(%rip), %rcx      # 0x13458
movsbq 0x1050(%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x81b9
movl $0x13, %edx
movq 0x20(%rsp), %rdi
jmp 0x8833
cmpl $0x27, %r13d
movl $0x27, %eax
cmovgel %eax, %r13d
movslq %r13d, %rdx
movq 0x50(%rsp), %rdi
jmp 0x8833
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xac47(%rip), %rax      # 0x13458
movss %xmm0, 0x1084(%rax)
jmp 0x81b9
cmpl $0x1f, %r13d
movl $0x1f, %eax
cmovgel %eax, %r13d
movslq %r13d, %rdx
movq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x3090
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xac05(%rip), %rax      # 0x13458
movss %xmm0, 0x1080(%rax)
jmp 0x81b9
cmpl $0xa215, %r14d          # imm = 0xA215
jne 0x81b9
leaq 0xabe4(%rip), %rax      # 0x13458
cmpl $0x0, 0x10a8(%rax)
jne 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xabc4(%rip), %rcx      # 0x13458
movl %eax, 0x10a8(%rcx)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %rax
leaq 0xaba5(%rip), %rcx      # 0x13458
movl %eax, 0x1094(%rcx)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xab87(%rip), %rcx      # 0x13458
movl %eax, 0x1098(%rcx)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvtsd2ss %xmm0, %xmm0
leaq 0xab69(%rip), %rax      # 0x13458
movss %xmm0, 0x1090(%rax)
jmp 0x81b9
movq %r12, %rdi
callq 0x7dc5
cvttsd2si %xmm0, %eax
leaq 0xab49(%rip), %rcx      # 0x13458
movl %eax, 0x10b0(%rcx)
jmp 0x81b9
movq 0x78(%rsp), %rbx
cmpq %rbx, 0x70(%rsp)
ja 0x89ad
movq 0x60(%rsp), %rdi
callq 0x7b8c
testl %eax, %eax
je 0x89ad
movl %eax, %r14d
addq 0x10(%rsp), %r14
cmpl %ebp, %eax
jbe 0x8967
addq $0x14, %rbx
cmpq %rbx, %r14
jae 0x899d
leaq 0xaafc(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x89ad
leaq 0x52e0(%rip), %rdi      # 0xdc40
callq 0x30c0
jmp 0x89ad
leaq 0xaae2(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x8986
leaq 0x4c37(%rip), %rdi      # 0xd5b1
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
incl %r15d
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x7ff7
jmp 0x89ad
leaq 0x4be4(%rip), %rdi      # 0xd588
xorl %esi, %esi
xorl %edx, %edx
callq 0x781c
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq