// File: dannye[P]jed/src/decoder.cpp
// Function: decodeBlockComponent(JPGImage const*, BitReader&, int*, int&, unsigned int&, HuffmanTable const&, HuffmanTable const&)
bool decodeBlockComponent(
    const JPGImage* const image,
    BitReader& bitReader,
    int* const component,
    int& previousDC,
    uint& skips,
    const HuffmanTable& dcTable,
    const HuffmanTable& acTable
) {
    if (image->frameType == SOF0) {
        // get the DC value for this block component
        byte length = getNextSymbol(bitReader, dcTable);
        if (length == (byte)-1) {
            std::cout << "Error - Invalid DC value\n";
            return false;
        }
        if (length > 11) {
            std::cout << "Error - DC coefficient length greater than 11\n";
            return false;
        }

        int coeff = bitReader.readBits(length);
        if (coeff == -1) {
            std::cout << "Error - Invalid DC value\n";
            return false;
        }
        if (length != 0 && coeff < (1 << (length - 1))) {
            coeff -= (1 << length) - 1;
        }
        component[0] = coeff + previousDC;
        previousDC = component[0];

        // get the AC values for this block component
        for (uint i = 1; i < 64; ++i) {
            byte symbol = getNextSymbol(bitReader, acTable);
            if (symbol == (byte)-1) {
                std::cout << "Error - Invalid AC value\n";
                return false;
            }

            // symbol 0x00 means fill remainder of component with 0
            if (symbol == 0x00) {
                return true;
            }

            // otherwise, read next component coefficient
            byte numZeroes = symbol >> 4;
            byte coeffLength = symbol & 0x0F;
            coeff = 0;

            if (i + numZeroes >= 64) {
                std::cout << "Error - Zero run-length exceeded block component\n";
                return false;
            }
            i += numZeroes;

            if (coeffLength > 10) {
                std::cout << "Error - AC coefficient length greater than 10\n";
                return false;
            }
            coeff = bitReader.readBits(coeffLength);
            if (coeff == -1) {
                std::cout << "Error - Invalid AC value\n";
                return false;
            }
            if (coeff < (1 << (coeffLength - 1))) {
                coeff -= (1 << coeffLength) - 1;
            }
            component[zigZagMap[i]] = coeff;
        }
        return true;
    }
    else { // image->frameType == SOF2
        if (image->startOfSelection == 0 && image->successiveApproximationHigh == 0) {
            // DC first visit
            byte length = getNextSymbol(bitReader, dcTable);
            if (length == (byte)-1) {
                std::cout << "Error - Invalid DC value\n";
                return false;
            }
            if (length > 11) {
                std::cout << "Error - DC coefficient length greater than 11\n";
                return false;
            }

            int coeff = bitReader.readBits(length);
            if (coeff == -1) {
                std::cout << "Error - Invalid DC value\n";
                return false;
            }
            if (length != 0 && coeff < (1 << (length - 1))) {
                coeff -= (1 << length) - 1;
            }
            coeff += previousDC;
            previousDC = coeff;
            component[0] = coeff << image->successiveApproximationLow;
            return true;
        }
        else if (image->startOfSelection == 0 && image->successiveApproximationHigh != 0) {
            // DC refinement
            int bit = bitReader.readBit();
            if (bit == -1) {
                std::cout << "Error - Invalid DC value\n";
                return false;
            }
            component[0] |= bit << image->successiveApproximationLow;
            return true;
        }
        else if (image->startOfSelection != 0 && image->successiveApproximationHigh == 0) {
            // AC first visit
            if (skips > 0) {
                skips -= 1;
                return true;
            }
            for (uint i = image->startOfSelection; i <= image->endOfSelection; ++i) {
                byte symbol = getNextSymbol(bitReader, acTable);
                if (symbol == (byte)-1) {
                    std::cout << "Error - Invalid AC value\n";
                    return false;
                }

                byte numZeroes = symbol >> 4;
                byte coeffLength = symbol & 0x0F;

                if (coeffLength != 0) {
                    if (i + numZeroes > image->endOfSelection) {
                        std::cout << "Error - Zero run-length exceeded spectral selection\n";
                        return false;
                    }
                    for (uint j = 0; j < numZeroes; ++j, ++i) {
                        component[zigZagMap[i]] = 0;
                    }
                    if (coeffLength > 10) {
                        std::cout << "Error - AC coefficient length greater than 10\n";
                        return false;
                    }

                    int coeff = bitReader.readBits(coeffLength);
                    if (coeff == -1) {
                        std::cout << "Error - Invalid AC value\n";
                        return false;
                    }
                    if (coeff < (1 << (coeffLength - 1))) {
                        coeff -= (1 << coeffLength) - 1;
                    }
                    component[zigZagMap[i]] = coeff << image->successiveApproximationLow;
                }
                else {
                    if (numZeroes == 15) {
                        if (i + numZeroes > image->endOfSelection) {
                            std::cout << "Error - Zero run-length exceeded spectral selection\n";
                            return false;
                        }
                        for (uint j = 0; j < numZeroes; ++j, ++i) {
                            component[zigZagMap[i]] = 0;
                        }
                    }
                    else {
                        skips = (1 << numZeroes) - 1;
                        uint extraSkips = bitReader.readBits(numZeroes);
                        if (extraSkips == (uint)-1) {
                            std::cout << "Error - Invalid AC value\n";
                            return false;
                        }
                        skips += extraSkips;
                        break;
                    }
                }
            }
            return true;
        }
        else { // image->startOfSelection != 0 && image->successiveApproximationHigh != 0
            // AC refinement
            int positive = 1 << image->successiveApproximationLow;
            int negative = ((unsigned)-1) << image->successiveApproximationLow;
            int i = image->startOfSelection;
            if (skips == 0) {
                for (; i <= image->endOfSelection; ++i) {
                    byte symbol = getNextSymbol(bitReader, acTable);
                    if (symbol == (byte)-1) {
                        std::cout << "Error - Invalid AC value\n";
                        return false;
                    }

                    byte numZeroes = symbol >> 4;
                    byte coeffLength = symbol & 0x0F;
                    int coeff = 0;

                    if (coeffLength != 0) {
                        if (coeffLength != 1) {
                            std::cout << "Error - Invalid AC value\n";
                            return false;
                        }
                        switch (bitReader.readBit()) {
                        case 1:
                            coeff = positive;
                            break;
                        case 0:
                            coeff = negative;
                            break;
                        default: // -1, data stream is empty
                            std::cout << "Error - Invalid AC value\n";
                            return false;
                        }
                    }
                    else {
                        if (numZeroes != 15) {
                            skips = 1 << numZeroes;
                            uint extraSkips = bitReader.readBits(numZeroes);
                            if (extraSkips == (uint)-1) {
                                std::cout << "Error - Invalid AC value\n";
                                return false;
                            }
                            skips += extraSkips;
                            break;
                        }
                    }

                    do {
                        if (component[zigZagMap[i]] != 0) {
                            switch (bitReader.readBit()) {
                            case 1:
                                if ((component[zigZagMap[i]] & positive) == 0) {
                                    if (component[zigZagMap[i]] >= 0) {
                                        component[zigZagMap[i]] += positive;
                                    }
                                    else {
                                        component[zigZagMap[i]] += negative;
                                    }
                                }
                                break;
                            case 0:
                                // do nothing
                                break;
                            default: // -1, data stream is empty
                                std::cout << "Error - Invalid AC value\n";
                                return false;
                            }
                        }
                        else {
                            if (numZeroes == 0) {
                                break;
                            }
                            numZeroes -= 1;
                        }

                        i += 1;
                    } while (i <= image->endOfSelection);

                    if (coeff != 0 && i <= image->endOfSelection) {
                        component[zigZagMap[i]] = coeff;
                    }
                }
            }

            if (skips > 0) {
                for (; i <= image->endOfSelection; ++i) {
                    if (component[zigZagMap[i]] != 0) {
                        switch (bitReader.readBit()) {
                        case 1:
                            if ((component[zigZagMap[i]] & positive) == 0) {
                                if (component[zigZagMap[i]] >= 0) {
                                    component[zigZagMap[i]] += positive;
                                }
                                else {
                                    component[zigZagMap[i]] += negative;
                                }
                            }
                            break;
                        case 0:
                            // do nothing
                            break;
                        default: // -1, data stream is empty
                            std::cout << "Error - Invalid AC value\n";
                            return false;
                        }
                    }
                }
                skips -= 1;
            }
            return true;
        }
    }
}

// Assembly:
subq $0x98, %rsp
movq 0xa0(%rsp), %rax
movq %rdi, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
movq %rcx, 0x70(%rsp)
movq %r8, 0x68(%rsp)
movq %r9, 0x60(%rsp)
movq 0x88(%rsp), %rax
movzbl 0x2065(%rax), %eax
cmpl $0xc0, %eax
jne 0x5465
movq 0x80(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x5090
movb %al, 0x5f(%rsp)
movzbl 0x5f(%rsp), %eax
cmpl $0xff, %eax
jne 0x51ff
movq 0x6df2(%rip), %rdi      # 0xbfd8
leaq 0x473a(%rip), %rsi      # 0x9927
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x5f(%rsp), %eax
cmpl $0xb, %eax
jle 0x5229
movq 0x6dc8(%rip), %rdi      # 0xbfd8
leaq 0x472a(%rip), %rsi      # 0x9941
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movq 0x80(%rsp), %rdi
movzbl 0x5f(%rsp), %esi
callq 0x80c0
movl %eax, 0x58(%rsp)
cmpl $-0x1, 0x58(%rsp)
jne 0x5266
movq 0x6d8b(%rip), %rdi      # 0xbfd8
leaq 0x46d3(%rip), %rsi      # 0x9927
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x5f(%rsp), %eax
cmpl $0x0, %eax
je 0x52a4
movl 0x58(%rsp), %eax
movzbl 0x5f(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x52a4
movzbl 0x5f(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movl 0x58(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %ecx
movq 0x70(%rsp), %rax
addl (%rax), %ecx
movq 0x78(%rsp), %rax
movl %ecx, (%rax)
movq 0x78(%rsp), %rax
movl (%rax), %ecx
movq 0x70(%rsp), %rax
movl %ecx, (%rax)
movl $0x1, 0x54(%rsp)
cmpl $0x40, 0x54(%rsp)
jae 0x5458
movq 0x80(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x5090
movb %al, 0x53(%rsp)
movzbl 0x53(%rsp), %eax
cmpl $0xff, %eax
jne 0x531c
movq 0x6cd5(%rip), %rdi      # 0xbfd8
leaq 0x4666(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x53(%rsp), %eax
cmpl $0x0, %eax
jne 0x5333
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movzbl 0x53(%rsp), %eax
sarl $0x4, %eax
movb %al, 0x52(%rsp)
movzbl 0x53(%rsp), %eax
andl $0xf, %eax
movb %al, 0x51(%rsp)
movl $0x0, 0x58(%rsp)
movl 0x54(%rsp), %eax
movzbl 0x52(%rsp), %ecx
addl %ecx, %eax
cmpl $0x40, %eax
jb 0x5383
movq 0x6c6e(%rip), %rdi      # 0xbfd8
leaq 0x4619(%rip), %rsi      # 0x998a
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x52(%rsp), %eax
addl 0x54(%rsp), %eax
movl %eax, 0x54(%rsp)
movzbl 0x51(%rsp), %eax
cmpl $0xa, %eax
jle 0x53ba
movq 0x6c37(%rip), %rdi      # 0xbfd8
leaq 0x4614(%rip), %rsi      # 0x99bc
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movq 0x80(%rsp), %rdi
movzbl 0x51(%rsp), %esi
callq 0x80c0
movl %eax, 0x58(%rsp)
cmpl $-0x1, 0x58(%rsp)
jne 0x53f7
movq 0x6bfa(%rip), %rdi      # 0xbfd8
leaq 0x458b(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl 0x58(%rsp), %eax
movzbl 0x51(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x542b
movzbl 0x51(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movl 0x58(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %edx
movq 0x78(%rsp), %rax
movl 0x54(%rsp), %ecx
movl %ecx, %esi
leaq 0x462f(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
movl %edx, (%rax,%rcx,4)
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x52cc
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movq 0x88(%rsp), %rax
movzbl 0x2073(%rax), %eax
cmpl $0x0, %eax
jne 0x55c1
movq 0x88(%rsp), %rax
movzbl 0x2075(%rax), %eax
cmpl $0x0, %eax
jne 0x55c1
movq 0x80(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0x5090
movb %al, 0x50(%rsp)
movzbl 0x50(%rsp), %eax
cmpl $0xff, %eax
jne 0x54d7
movq 0x6b1a(%rip), %rdi      # 0xbfd8
leaq 0x4462(%rip), %rsi      # 0x9927
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x50(%rsp), %eax
cmpl $0xb, %eax
jle 0x5501
movq 0x6af0(%rip), %rdi      # 0xbfd8
leaq 0x4452(%rip), %rsi      # 0x9941
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movq 0x80(%rsp), %rdi
movzbl 0x50(%rsp), %esi
callq 0x80c0
movl %eax, 0x4c(%rsp)
cmpl $-0x1, 0x4c(%rsp)
jne 0x553e
movq 0x6ab3(%rip), %rdi      # 0xbfd8
leaq 0x43fb(%rip), %rsi      # 0x9927
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x50(%rsp), %eax
cmpl $0x0, %eax
je 0x557c
movl 0x4c(%rsp), %eax
movzbl 0x50(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x557c
movzbl 0x50(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movl 0x4c(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x4c(%rsp)
movq 0x70(%rsp), %rax
movl (%rax), %eax
addl 0x4c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %ecx
movq 0x70(%rsp), %rax
movl %ecx, (%rax)
movl 0x4c(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2076(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq 0x78(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movq 0x88(%rsp), %rax
movzbl 0x2073(%rax), %eax
cmpl $0x0, %eax
jne 0x564e
movq 0x88(%rsp), %rax
movzbl 0x2075(%rax), %eax
cmpl $0x0, %eax
je 0x564e
movq 0x80(%rsp), %rdi
callq 0x7ee0
movl %eax, 0x48(%rsp)
cmpl $-0x1, 0x48(%rsp)
jne 0x5621
movq 0x69d0(%rip), %rdi      # 0xbfd8
leaq 0x4318(%rip), %rsi      # 0x9927
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl 0x48(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2076(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq 0x78(%rsp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movq 0x88(%rsp), %rax
movzbl 0x2073(%rax), %eax
cmpl $0x0, %eax
je 0x59ad
movq 0x88(%rsp), %rax
movzbl 0x2075(%rax), %eax
cmpl $0x0, %eax
jne 0x59ad
movq 0x68(%rsp), %rax
cmpl $0x0, (%rax)
jbe 0x56a1
movq 0x68(%rsp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movl %ecx, (%rax)
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movq 0x88(%rsp), %rax
movzbl 0x2073(%rax), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
ja 0x59a0
movq 0x80(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x5090
movb %al, 0x43(%rsp)
movzbl 0x43(%rsp), %eax
cmpl $0xff, %eax
jne 0x5714
movq 0x68dd(%rip), %rdi      # 0xbfd8
leaq 0x426e(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x43(%rsp), %eax
sarl $0x4, %eax
movb %al, 0x42(%rsp)
movzbl 0x43(%rsp), %eax
andl $0xf, %eax
movb %al, 0x41(%rsp)
movzbl 0x41(%rsp), %eax
cmpl $0x0, %eax
je 0x5890
movl 0x44(%rsp), %eax
movzbl 0x42(%rsp), %ecx
addl %ecx, %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x5778
movq 0x6879(%rip), %rdi      # 0xbfd8
leaq 0x4285(%rip), %rsi      # 0x99eb
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
movzbl 0x42(%rsp), %ecx
cmpl %ecx, %eax
jae 0x57c2
movq 0x78(%rsp), %rax
movl 0x44(%rsp), %ecx
movl %ecx, %edx
leaq 0x42d1(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x5780
movzbl 0x41(%rsp), %eax
cmpl $0xa, %eax
jle 0x57ec
movq 0x6805(%rip), %rdi      # 0xbfd8
leaq 0x41e2(%rip), %rsi      # 0x99bc
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movq 0x80(%rsp), %rdi
movzbl 0x41(%rsp), %esi
callq 0x80c0
movl %eax, 0x38(%rsp)
cmpl $-0x1, 0x38(%rsp)
jne 0x5829
movq 0x67c8(%rip), %rdi      # 0xbfd8
leaq 0x4159(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl 0x38(%rsp), %eax
movzbl 0x41(%rsp), %ecx
subl $0x1, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x585d
movzbl 0x41(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movl 0x38(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x38(%rsp)
movl 0x38(%rsp), %edx
movq 0x88(%rsp), %rax
movzbl 0x2076(%rax), %ecx
shll %cl, %edx
movq 0x78(%rsp), %rax
movl 0x44(%rsp), %ecx
movl %ecx, %esi
leaq 0x41ec(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x598e
movzbl 0x42(%rsp), %eax
cmpl $0xf, %eax
jne 0x5928
movl 0x44(%rsp), %eax
movzbl 0x42(%rsp), %ecx
addl %ecx, %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jbe 0x58dc
movq 0x6715(%rip), %rdi      # 0xbfd8
leaq 0x4121(%rip), %rsi      # 0x99eb
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movzbl 0x42(%rsp), %ecx
cmpl %ecx, %eax
jae 0x5926
movq 0x78(%rsp), %rax
movl 0x44(%rsp), %ecx
movl %ecx, %edx
leaq 0x416d(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x58e4
jmp 0x598c
movzbl 0x42(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movq 0x68(%rsp), %rax
movl %ecx, (%rax)
movq 0x80(%rsp), %rdi
movzbl 0x42(%rsp), %esi
callq 0x80c0
movl %eax, 0x30(%rsp)
cmpl $-0x1, 0x30(%rsp)
jne 0x597d
movq 0x6674(%rip), %rdi      # 0xbfd8
leaq 0x4005(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl 0x30(%rsp), %ecx
movq 0x68(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x59a0
jmp 0x598e
jmp 0x5990
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x56b4
movb $0x1, 0x97(%rsp)
jmp 0x5e40
movq 0x88(%rsp), %rax
movzbl 0x2076(%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x2c(%rsp)
movq 0x88(%rsp), %rax
movzbl 0x2076(%rax), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movl %eax, 0x28(%rsp)
movq 0x88(%rsp), %rax
movzbl 0x2073(%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x68(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x5d03
jmp 0x5a04
movl 0x24(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jg 0x5d01
movq 0x80(%rsp), %rdi
movq 0xa0(%rsp), %rsi
callq 0x5090
movb %al, 0x23(%rsp)
movzbl 0x23(%rsp), %eax
cmpl $0xff, %eax
jne 0x5a64
movq 0x658d(%rip), %rdi      # 0xbfd8
leaq 0x3f1e(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movzbl 0x23(%rsp), %eax
sarl $0x4, %eax
movb %al, 0x22(%rsp)
movzbl 0x23(%rsp), %eax
andl $0xf, %eax
movb %al, 0x21(%rsp)
movl $0x0, 0x1c(%rsp)
movzbl 0x21(%rsp), %eax
cmpl $0x0, %eax
je 0x5b16
movzbl 0x21(%rsp), %eax
cmpl $0x1, %eax
je 0x5abc
movq 0x6535(%rip), %rdi      # 0xbfd8
leaq 0x3ec6(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movq 0x80(%rsp), %rdi
callq 0x7ee0
movl %eax, %ecx
movl %ecx, 0x14(%rsp)
testl %eax, %eax
je 0x5aea
jmp 0x5ad5
movl 0x14(%rsp), %eax
subl $0x1, %eax
jne 0x5af4
jmp 0x5ae0
movl 0x2c(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x5b14
movl 0x28(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x5b14
movq 0x64dd(%rip), %rdi      # 0xbfd8
leaq 0x3e6e(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
jmp 0x5b86
movzbl 0x22(%rsp), %eax
cmpl $0xf, %eax
je 0x5b84
movzbl 0x22(%rsp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq 0x68(%rsp), %rax
movl %ecx, (%rax)
movq 0x80(%rsp), %rdi
movzbl 0x22(%rsp), %esi
callq 0x80c0
movl %eax, 0x18(%rsp)
cmpl $-0x1, 0x18(%rsp)
jne 0x5b72
movq 0x647f(%rip), %rdi      # 0xbfd8
leaq 0x3e10(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
movl 0x18(%rsp), %ecx
movq 0x68(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x5d01
jmp 0x5b86
jmp 0x5b88
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3ed7(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x5c77
movq 0x80(%rsp), %rdi
callq 0x7ee0
movl %eax, %ecx
movl %ecx, 0x10(%rsp)
testl %eax, %eax
je 0x5c53
jmp 0x5bc4
movl 0x10(%rsp), %eax
subl $0x1, %eax
jne 0x5c55
jmp 0x5bd3
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3e8c(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
movl (%rax,%rcx,4), %eax
andl 0x2c(%rsp), %eax
cmpl $0x0, %eax
jne 0x5c51
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3e6b(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
cmpl $0x0, (%rax,%rcx,4)
jl 0x5c30
movl 0x2c(%rsp), %edx
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rsi
leaq 0x3e4c(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x5c4f
movl 0x28(%rsp), %edx
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rsi
leaq 0x3e2b(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x5c51
jmp 0x5c75
jmp 0x5c75
movq 0x637c(%rip), %rdi      # 0xbfd8
leaq 0x3d0d(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
jmp 0x5c8f
movzbl 0x22(%rsp), %eax
cmpl $0x0, %eax
jne 0x5c83
jmp 0x5cb5
movzbl 0x22(%rsp), %eax
subl $0x1, %eax
movb %al, 0x22(%rsp)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movl 0x24(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jle 0x5b88
cmpl $0x0, 0x1c(%rsp)
je 0x5cef
movl 0x24(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jg 0x5cef
movl 0x1c(%rsp), %edx
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rsi
leaq 0x3d88(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x5cf1
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x5a04
jmp 0x5d03
movq 0x68(%rsp), %rax
cmpl $0x0, (%rax)
jbe 0x5e38
jmp 0x5d13
movl 0x24(%rsp), %eax
movq 0x88(%rsp), %rcx
movzbl 0x2074(%rcx), %ecx
cmpl %ecx, %eax
jg 0x5e2c
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3d31(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x5e1a
movq 0x80(%rsp), %rdi
callq 0x7ee0
movl %eax, %ecx
movl %ecx, 0xc(%rsp)
testl %eax, %eax
je 0x5df9
jmp 0x5d6a
movl 0xc(%rsp), %eax
subl $0x1, %eax
jne 0x5dfb
jmp 0x5d79
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3ce6(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
movl (%rax,%rcx,4), %eax
andl 0x2c(%rsp), %eax
cmpl $0x0, %eax
jne 0x5df7
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rdx
leaq 0x3cc5(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rdx), %ecx
cmpl $0x0, (%rax,%rcx,4)
jl 0x5dd6
movl 0x2c(%rsp), %edx
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rsi
leaq 0x3ca6(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x5df5
movl 0x28(%rsp), %edx
movq 0x78(%rsp), %rax
movslq 0x24(%rsp), %rsi
leaq 0x3c85(%rip), %rcx      # 0x9a70
movzbl (%rcx,%rsi), %ecx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x5df7
jmp 0x5e18
jmp 0x5e18
movq 0x61d6(%rip), %rdi      # 0xbfd8
leaq 0x3b67(%rip), %rsi      # 0x9970
callq 0x2110
movb $0x0, 0x97(%rsp)
jmp 0x5e40
jmp 0x5e1a
jmp 0x5e1c
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x5d13
movq 0x68(%rsp), %rax
movl (%rax), %ecx
subl $0x1, %ecx
movl %ecx, (%rax)
movb $0x1, 0x97(%rsp)
movb 0x97(%rsp), %al
andb $0x1, %al
addq $0x98, %rsp
retq
nopw %cs:(%rax,%rax)