// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
cmpl $0x5, %ecx
jl 0x7f6a
leaq 0x5427(%rip), %rdi      # 0xd38d
xorl %esi, %esi
jmp 0x7fe5
movapd 0x4e5e(%rip), %xmm0     # 0xcdd0
movupd %xmm0, 0x59(%rsp)
movapd %xmm0, 0x50(%rsp)
movl %ecx, %eax
movb $0x0, 0x50(%rsp,%rax,4)
xorl %eax, %eax
xorl %r8d, %r8d
cmpl $0x0, 0xc58b(%rip)      # 0x1451c
sete %al
setne %r8b
movzbl (%rdi,%rax), %eax
shll $0x8, %eax
movzbl (%rdi,%r8), %ebx
orl %eax, %ebx
leal (,%rbx,4), %eax
leal (%rax,%rax,2), %eax
leaq (%rdi,%rax), %r8
addq $0x2, %r8
leaq (%rdi,%rax), %r9
addq $0x6, %r9
movl %edx, %r10d
addq %rsi, %r10
cmpq %r10, %r8
je 0x7ffd
cmpq %r10, %r9
jbe 0x7ffd
addq %rdi, %rax
addq $0x4, %rax
cmpq %r10, %rax
je 0x7ffd
leaq 0x53e8(%rip), %rdi      # 0xd3cb
movl %ebx, %esi
xorl %edx, %edx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x76e0
movq %rcx, 0x18(%rsp)
movq %r9, 0x90(%rsp)
movq %r8, 0x88(%rsp)
movq %r10, 0x98(%rsp)
movq %rdi, 0x48(%rsp)
movq %rsi, 0x20(%rsp)
movl %edx, 0x14(%rsp)
leaq 0xb421(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x8044
leaq 0x53bf(%rip), %rdi      # 0xd3fa
movl %ebx, %esi
xorl %eax, %eax
callq 0x3170
testl %ebx, %ebx
je 0x891b
addq $0x2, 0x48(%rsp)
movq 0x18(%rsp), %rax
incl %eax
movl %eax, 0x2c(%rsp)
movl %ebx, %ebx
movl $0x1008, %eax           # imm = 0x1008
addq 0x9f6d(%rip), %rax      # 0x11fd8
movq %rax, 0x80(%rsp)
movl $0x1028, %eax           # imm = 0x1028
addq 0x9f59(%rip), %rax      # 0x11fd8
movq %rax, 0x78(%rsp)
movl $0x1050, %eax           # imm = 0x1050
addq 0x9f48(%rip), %rax      # 0x11fd8
movq %rax, 0x30(%rsp)
xorl %ebp, %ebp
movq %rbx, 0x40(%rsp)
leaq (,%rbp,2), %rax
addq %rbp, %rax
movq 0x48(%rsp), %r8
leaq (%r8,%rax,4), %r12
cmpl $0x0, 0xc465(%rip)      # 0x1451c
leaq 0x1(%r8,%rax,4), %rcx
movq %r12, %rdx
cmoveq %rcx, %rdx
cmoveq %r12, %rcx
movzbl (%rdx), %r14d
leaq 0x2(%r8,%rax,4), %rdx
leaq 0x3(%r8,%rax,4), %rsi
movq %rsi, %rdi
cmoveq %rdx, %rdi
cmoveq %rsi, %rdx
movzbl (%rcx), %ecx
shll $0x8, %r14d
orl %ecx, %r14d
movzbl (%rdx), %ecx
shll $0x8, %ecx
movzbl (%rdi), %r13d
orl %ecx, %r13d
leaq (%r8,%rax,4), %rdi
addq $0x4, %rdi
callq 0x7a83
cmpl $0xd, %r13d
jb 0x8116
leaq 0x52ff(%rip), %rdi      # 0xd410
movl %r13d, %esi
jmp 0x8126
cmpl $0x10001, %eax          # imm = 0x10001
jb 0x813f
leaq 0x531a(%rip), %rdi      # 0xd43e
movl %eax, %esi
movl %r14d, %edx
callq 0x76e0
incq %rbp
cmpq %rbx, %rbp
jne 0x809c
jmp 0x891b
movl %r13d, %ecx
leaq 0x4bd7(%rip), %rdx      # 0xcd20
movl (%rdx,%rcx,4), %r15d
imull %eax, %r15d
addq $0x8, %r12
cmpl $0x5, %r15d
jl 0x8180
movq %r12, %rdi
callq 0x7a83
leal (%rax,%r15), %ebx
cmpl 0x14(%rsp), %ebx
jbe 0x8187
leaq 0x52f6(%rip), %rdi      # 0xd46a
movl %r14d, %esi
xorl %edx, %edx
callq 0x76e0
jmp 0x8193
movq %r12, 0x8(%rsp)
jmp 0x819e
movl %eax, %eax
addq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpl 0x14(%rsp), %ebx
movq 0x40(%rsp), %rbx
ja 0x812e
leaq 0xb2ab(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x82f4
movl $0x8, %eax
leaq 0x9566(%rip), %rcx      # 0x11720
movzwl -0x8(%rax,%rcx), %ecx
cmpl %ecx, %r14d
je 0x81e8
addq $0x10, %rax
cmpq $0x6a8, %rax            # imm = 0x6A8
jne 0x81b3
leaq 0x52be(%rip), %rdi      # 0xd495
leaq 0x50(%rsp), %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x3170
jmp 0x8206
leaq 0x9531(%rip), %rcx      # 0x11720
movq (%rax,%rcx), %rdx
leaq 0x52bb(%rip), %rdi      # 0xd4b5
leaq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
cmpl $0x7, %r13d
je 0x8243
cmpl $0x2, %r13d
je 0x8243
cmpl $0x1, %r13d
jne 0x82ce
cmpl $0x2, %r15d
jl 0x82d8
movl %r15d, %esi
shrl %esi
leaq 0x528f(%rip), %rdi      # 0xd4c1
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x3170
jmp 0x82f4
movl $0x22, %edi
callq 0x3050
movq %r15, 0x38(%rsp)
testl %r15d, %r15d
jle 0x82b6
movq 0x38(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0xa0(%rsp)
movl %eax, %r12d
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
movzbl (%rax,%rbx), %edi
cmpl $0x20, %edi
jb 0x8287
xorl %r15d, %r15d
callq 0x3050
jmp 0x8292
testl %r15d, %r15d
movl $0x1, %r15d
je 0x829c
incq %rbx
cmpq %rbx, %r12
jne 0x826f
jmp 0x82b6
xorl %r15d, %r15d
cmpq %rbx, 0xa0(%rsp)
je 0x8292
movl $0x1, %r15d
movl $0x3f, %edi
jmp 0x8280
leaq 0x2ee1(%rip), %rdi      # 0xb19e
callq 0x30c0
movq 0x40(%rsp), %rbx
movq 0x38(%rsp), %r15
jmp 0x82f4
movq 0x8(%rsp), %rdi
movl %r13d, %esi
jmp 0x82e2
movq 0x8(%rsp), %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x7b01
movl $0xa, %edi
callq 0x3050
cmpl $0x9203, %r14d          # imm = 0x9203
jle 0x835a
cmpl $0xa004, %r14d          # imm = 0xA004
jle 0x83ee
cmpl $0xa214, %r14d          # imm = 0xA214
jle 0x848a
leal -0xa402(%r14), %eax
cmpl $0xa, %eax
ja 0x884d
leaq 0x493a(%rip), %rcx      # 0xcc68
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xb109(%rip), %rcx      # 0x13458
movl %eax, 0x10a4(%rcx)
jmp 0x812e
cmpl $0x8299, %r14d          # imm = 0x8299
jg 0x8433
cmpl $0x119, %r14d           # imm = 0x119
jle 0x84bf
cmpl $0x127, %r14d           # imm = 0x127
jg 0x85d6
cmpl $0x11a, %r14d           # imm = 0x11A
je 0x86df
cmpl $0x11b, %r14d           # imm = 0x11B
jne 0x812e
cmpl $0x0, 0x18(%rsp)
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xb09a(%rip), %rax      # 0x13458
movss %xmm0, 0x10b8(%rax)
movss 0x10b4(%rax), %xmm1
ucomiss 0x4a0b(%rip), %xmm1     # 0xcde0
jne 0x812e
jp 0x812e
movss %xmm0, 0x10b4(%rax)
jmp 0x812e
leal -0x9204(%r14), %eax
cmpl $0x6, %eax
ja 0x859d
leaq 0x4847(%rip), %rcx      # 0xcc4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xb032(%rip), %rax      # 0x13458
movss %xmm0, 0x108c(%rax)
jmp 0x812e
cmpl $0x8821, %r14d          # imm = 0x8821
jle 0x8509
cmpl $0x9002, %r14d          # imm = 0x9002
jg 0x85f5
cmpl $0x8822, %r14d          # imm = 0x8822
je 0x8732
cmpl $0x8827, %r14d          # imm = 0x8827
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xafd9(%rip), %rcx      # 0x13458
movl %eax, 0x10a8(%rcx)
jmp 0x812e
cmpl $0xa005, %r14d          # imm = 0xA005
je 0x854f
cmpl $0xa20e, %r14d          # imm = 0xA20E
je 0x84ad
cmpl $0xa210, %r14d          # imm = 0xA210
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
jmp 0x812e
cmpl $0x10f, %r14d           # imm = 0x10F
je 0x8801
cmpl $0x110, %r14d           # imm = 0x110
je 0x87c5
cmpl $0x112, %r14d           # imm = 0x112
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xaf5a(%rip), %rcx      # 0x13458
movl %eax, 0x106c(%rcx)
jmp 0x812e
cmpl $0x829a, %r14d          # imm = 0x829A
je 0x8828
cmpl $0x829d, %r14d          # imm = 0x829D
je 0x87dc
cmpl $0x8769, %r14d          # imm = 0x8769
jne 0x812e
leaq 0xaf19(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x854f
leaq 0x4f85(%rip), %rdi      # 0xd4c8
leaq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
cmpl $0xa005, %r14d          # imm = 0xA005
jne 0x8577
leaq 0xaef1(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x8577
leaq 0x4f6d(%rip), %rdi      # 0xd4d8
leaq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
movq 0x8(%rsp), %rdi
callq 0x7a83
movl 0x14(%rsp), %edx
cmpl %edx, %eax
jbe 0x8614
leaq 0x4f57(%rip), %rdi      # 0xd4eb
xorl %esi, %esi
xorl %edx, %edx
jmp 0x8129
addl $0xffff5ffe, %r14d      # imm = 0xFFFF5FFE
cmpl $0x2, %r14d
jae 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
cmpl %eax, 0xbf5b(%rip)      # 0x14520
jge 0x812e
movl %eax, 0xbf4f(%rip)      # 0x14520
jmp 0x812e
cmpl $0x128, %r14d           # imm = 0x128
je 0x8755
cmpl $0x132, %r14d           # imm = 0x132
je 0x8797
jmp 0x812e
cmpl $0x9003, %r14d          # imm = 0x9003
je 0x8783
cmpl $0x9004, %r14d          # imm = 0x9004
je 0x8797
jmp 0x812e
movl %eax, %edi
movq 0x20(%rsp), %rsi
addq %rsi, %rdi
movl 0x2c(%rsp), %ecx
callq 0x7f49
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xae14(%rip), %rcx      # 0x13458
movl %eax, 0x1078(%rcx)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xadf1(%rip), %rax      # 0x13458
movss %xmm0, 0x107c(%rax)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xadcc(%rip), %rcx      # 0x13458
movl %eax, 0x10ac(%rcx)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xada9(%rip), %rax      # 0x13458
movss %xmm0, 0x1088(%rax)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xad84(%rip), %rcx      # 0x13458
movl %eax, 0x109c(%rcx)
jmp 0x812e
cmpl $0x0, 0x18(%rsp)
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xad56(%rip), %rax      # 0x13458
movss %xmm0, 0x10b4(%rax)
movss 0x10b8(%rax), %xmm1
ucomiss 0x46c7(%rip), %xmm1     # 0xcde0
jne 0x812e
jp 0x812e
movss %xmm0, 0x10b8(%rax)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xad0e(%rip), %rcx      # 0x13458
movl %eax, 0x10a0(%rcx)
jmp 0x812e
cmpl $0x0, 0x18(%rsp)
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xace0(%rip), %rcx      # 0x13458
movl %eax, 0x10bc(%rcx)
jmp 0x812e
movl $0x13, %edx
movq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x3090
callq 0x3500
movq (%rax), %rax
leaq 0xacb2(%rip), %rcx      # 0x13458
movsbq 0x1050(%rcx), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x812e
movl $0x13, %edx
movq 0x30(%rsp), %rdi
jmp 0x8819
cmpl $0x27, %r15d
movl $0x27, %eax
cmovgel %eax, %r15d
movslq %r15d, %rdx
movq 0x78(%rsp), %rdi
jmp 0x8819
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xac64(%rip), %rax      # 0x13458
movss %xmm0, 0x1084(%rax)
jmp 0x812e
cmpl $0x1f, %r15d
movl $0x1f, %eax
cmovgel %eax, %r15d
movslq %r15d, %rdx
movq 0x80(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x3090
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xac18(%rip), %rax      # 0x13458
movss %xmm0, 0x1080(%rax)
jmp 0x812e
cmpl $0xa215, %r14d          # imm = 0xA215
jne 0x812e
leaq 0xabf7(%rip), %r14      # 0x13458
cmpl $0x0, 0x10a8(%r14)
jne 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
movl %eax, 0x10a8(%r14)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %rax
leaq 0xabb3(%rip), %rcx      # 0x13458
movl %eax, 0x1094(%rcx)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xab90(%rip), %rcx      # 0x13458
movl %eax, 0x1098(%rcx)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvtsd2ss %xmm0, %xmm0
leaq 0xab6d(%rip), %rax      # 0x13458
movss %xmm0, 0x1090(%rax)
jmp 0x812e
movq 0x8(%rsp), %rdi
movl %r13d, %esi
callq 0x7cd3
cvttsd2si %xmm0, %eax
leaq 0xab48(%rip), %rcx      # 0x13458
movl %eax, 0x10b0(%rcx)
jmp 0x812e
movq 0x98(%rsp), %r12
cmpq %r12, 0x90(%rsp)
ja 0x89bc
movq 0x88(%rsp), %rdi
callq 0x7a83
testl %eax, %eax
je 0x89bc
movl %eax, %ebx
movq 0x20(%rsp), %r14
addq %r14, %rbx
movl 0x14(%rsp), %ebp
cmpl %ebp, %eax
jbe 0x8977
addq $0x14, %r12
cmpq %r12, %rbx
jae 0x89ac
leaq 0xaaec(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x89bc
leaq 0x5260(%rip), %rdi      # 0xdbd0
callq 0x30c0
jmp 0x89bc
leaq 0xaad2(%rip), %rax      # 0x13450
cmpl $0x0, (%rax)
je 0x8996
leaq 0x4bb7(%rip), %rdi      # 0xd541
leaq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x3170
movq 0x18(%rsp), %rcx
incl %ecx
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x7f49
jmp 0x89bc
leaq 0x4b65(%rip), %rdi      # 0xd518
xorl %esi, %esi
xorl %edx, %edx
callq 0x76e0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq