// File: Thilotilo[P]DoaERando/Randomizer.cpp
// Function: DoaERando::Randomizer::RewriteTitleScreen(int, int, int, int)
void Randomizer::RewriteTitleScreen(int major, int minor, int patch, int seed)
{
    // I assume there are line pointers here, but I simply don't know where
    // they are, so I'm simply replacing the extra characters I don't want
    // display with 0xFF, but I'm not actually moving any line starts

    // Line format:
    // first 2 bytes - location to write (lower nibble of byte 2
    //                 defines horizontal start position)
    // third byte - number of bytes to write
    const int CREDIT_START = 0x349A1;
    int index = CREDIT_START;

    // adding scoping braces for readability
    // RANDOMIZER
    {
        std::vector<BYTE> randomizerLine {
            0x21,0xAB,0x0A,0x21,0x10,0x1D,0x13,0x1E,0x1C,0x18,0x29,0x14,0x21 // RANDOMIZER
        };
        // Fill remaining bytes for this line with 0xFF
        randomizerLine.resize(0x0F, 0xFF);
        // Write the data
        for (int i = 0; i < randomizerLine.size(); ++i, ++index)
        {
            myRom->WriteByte(index, randomizerLine[i]);
        }
    }


    // VERSION X.Y.Z
    {
        int combinedVersionDigits = numDigits(major) + numDigits(minor) + numDigits(patch);
        BYTE versionLineLen = 8 + combinedVersionDigits + 2; // 8 for VERSION_, 2 for dots between versions
        if (versionLineLen % 2 == 1) // Make sure we always have an even number of characters for centering
        {
            versionLineLen++;
        }
        // Set the lower nibble to a centering offset based upon the version length
        BYTE versionOffset = (0x10 - static_cast<BYTE>(versionLineLen/2)) | 0xE0;
        // Write VERSION_
        std::vector<BYTE> versionLine {0x21, versionOffset, 0x17, 0x25,0x14,0x21,0x22,0x18,0x1E,0x1D,0x0A};
        if (combinedVersionDigits % 2 == 1) // Add an extra space to get us to an even number of characters
        {
            versionLine.push_back(0x0A);
        }
        // Add patch numbers
        appendNumber(versionLine, major);
        versionLine.push_back(0x63);
        appendNumber(versionLine, minor);
        versionLine.push_back(0x63);
        appendNumber(versionLine, patch);
        // Fill remaining bytes for this line with 0xFF
        versionLine.resize(0x1A, 0xFF);
        // Write the data
        for (int i = 0; i < versionLine.size(); ++i, ++index)
        {
            myRom->WriteByte(index, versionLine[i]);
        }
    }

    // SEED X
    {
        int seedDigits = numDigits(seed);
        BYTE seedLineLen = 5 + seedDigits;
        if (seedLineLen % 2 == 1) // Make sure we always have an even number of characters for centering
        {
            seedLineLen++;
        }
        // Set the lower nibble to a centering offset based upon the seed length
        BYTE seedOffset = (0x10 - static_cast<BYTE>(seedLineLen/2)) | 0x20;
        // Write SEED_
        std::vector<BYTE> seedLine {0x22,seedOffset,0x12,0x22,0x14,0x14,0x13,0x0A};
        if (seedDigits % 2 == 0) // Write an extra space if needed to get to even character count
        {
            seedLine.push_back(0x0A);
        }
        // Add seed number
        appendNumber(seedLine, seed);
        // Fill remaining bytes for this line with 0xFF
        seedLine.resize(0x15, 0xFF);
        // Write the data
        for (int i = 0; i < seedLine.size(); ++i, ++index)
        {
            myRom->WriteByte(index, seedLine[i]);
        }
    }

    // 4 BLANK LINES
    {
        std::vector<BYTE> blankLine0 {0x22, 0x65, 0x0F};
        blankLine0.resize(0x12, 0xFF);
        for (int i = 0; i < blankLine0.size(); ++i, ++index)
        {
            myRom->WriteByte(index, blankLine0[i]);
        }

        std::vector<BYTE> blankLine1 {0x22, 0xA2, 0x1D};
        blankLine1.resize(0x20, 0xFF);
        for (int i = 0; i < blankLine1.size(); ++i, ++index)
        {
            myRom->WriteByte(index, blankLine1[i]);
        }

        std::vector<BYTE> blankLine2 {0x22, 0xE6, 0x13};
        blankLine2.resize(0x16, 0xFF);
        for (int i = 0; i < blankLine2.size(); ++i, ++index)
        {
            myRom->WriteByte(index, blankLine2[i]);
        }

        std::vector<BYTE> blankLine3 {0x23, 0x29, 0x0B};
        blankLine3.resize(0x0E, 0xFF);
        for (int i = 0; i < blankLine3.size(); ++i, ++index)
        {
            myRom->WriteByte(index, blankLine3[i]);
        }
    }

    // CREATED BY THILOTILO
    {
        // Text data
        std::vector<BYTE> createdByLine {
            0x23,0x66,0x18,0x12,0x21,0x14,0x10,0x23,0x14,0x13,0x0A,0x11,0x28,0x0A,0x23,0x17,0x18,0x1B,0x1E,0x23,0x18,0x1B,0x1E};
        // Fill remaining bytes for this line with 0xFF
        createdByLine.resize(0x1B, 0xFF);
        // Write the data
        for (int i = 0; i < createdByLine.size(); ++i, ++index)
        {
            myRom->WriteByte(index, createdByLine[i]);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movl $0x349a1, -0x1c(%rbp)   # imm = 0x349A1
movl $0x349a1, -0x20(%rbp)   # imm = 0x349A1
movb $0x21, -0x55(%rbp)
movb $-0x55, -0x54(%rbp)
movb $0xa, -0x53(%rbp)
movb $0x21, -0x52(%rbp)
movb $0x10, -0x51(%rbp)
movb $0x1d, -0x50(%rbp)
movb $0x13, -0x4f(%rbp)
movb $0x1e, -0x4e(%rbp)
movb $0x1c, -0x4d(%rbp)
movb $0x18, -0x4c(%rbp)
movb $0x29, -0x4b(%rbp)
movb $0x14, -0x4a(%rbp)
movb $0x21, -0x49(%rbp)
leaq -0x55(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0xd, -0x40(%rbp)
leaq -0x56(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x404e70
movq -0x230(%rbp), %rcx
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x40fb50
jmp 0x40ec23
leaq -0x56(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x65(%rbp)
leaq -0x38(%rbp), %rdi
movl $0xf, %esi
leaq -0x65(%rbp), %rdx
callq 0x4102b0
jmp 0x40ec44
movl $0x0, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
movq %rax, -0x240(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x240(%rbp), %rax
cmpq %rcx, %rax
jae 0x40ecfa
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x250(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x244(%rbp)
movslq -0x6c(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x405030
movq -0x250(%rbp), %rdi
movl -0x244(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40ecb0
jmp 0x40ecb2
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40ec4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x56(%rbp), %rdi
callq 0x404fb0
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x404f50
jmp 0x40f922
leaq -0x38(%rbp), %rdi
callq 0x404f50
movl -0xc(%rbp), %edi
callq 0x40f930
movl %eax, -0x258(%rbp)
movl -0x10(%rbp), %edi
callq 0x40f930
movl %eax, %ecx
movl -0x258(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x254(%rbp)
movl -0x14(%rbp), %edi
callq 0x40f930
movl %eax, %ecx
movl -0x254(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
addl $0x8, %eax
addl $0x2, %eax
movb %al, -0x71(%rbp)
movzbl -0x71(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x40ed63
movb -0x71(%rbp), %al
addb $0x1, %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %cl
shrb %cl
movb $0x10, %al
subb %cl, %al
orb $-0x20, %al
movb %al, -0x72(%rbp)
movb $0x21, -0xab(%rbp)
movb -0x72(%rbp), %al
movb %al, -0xaa(%rbp)
movb $0x17, -0xa9(%rbp)
movb $0x25, -0xa8(%rbp)
movb $0x14, -0xa7(%rbp)
movb $0x21, -0xa6(%rbp)
movb $0x22, -0xa5(%rbp)
movb $0x18, -0xa4(%rbp)
movb $0x1e, -0xa3(%rbp)
movb $0x1d, -0xa2(%rbp)
movb $0xa, -0xa1(%rbp)
leaq -0xab(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq $0xb, -0x98(%rbp)
leaq -0xac(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x404e70
movq -0x260(%rbp), %rcx
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x40fb50
jmp 0x40ee0f
leaq -0xac(%rbp), %rdi
callq 0x404fb0
movl -0x70(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x40ee83
movb $0xa, -0xad(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xad(%rbp), %rsi
callq 0x40fab0
jmp 0x40ee47
jmp 0x40ee83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xac(%rbp), %rdi
callq 0x404fb0
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x404f50
jmp 0x40f922
movl -0xc(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x40f980
jmp 0x40ee94
movb $0x63, -0xae(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xae(%rbp), %rsi
callq 0x40fab0
jmp 0x40eeb0
movl -0x10(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x40f980
jmp 0x40eec1
movb $0x63, -0xaf(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xaf(%rbp), %rsi
callq 0x40fab0
jmp 0x40eedd
movl -0x14(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x40f980
jmp 0x40eeee
movb $-0x1, -0xb0(%rbp)
leaq -0x90(%rbp), %rdi
movl $0x1a, %esi
leaq -0xb0(%rbp), %rdx
callq 0x4102b0
jmp 0x40ef0f
movl $0x0, -0xb4(%rbp)
movslq -0xb4(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
jae 0x40efa5
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x278(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x26c(%rbp)
movslq -0xb4(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x405030
movq -0x278(%rbp), %rdi
movl -0x26c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40ef86
jmp 0x40ef88
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40ef19
leaq -0x90(%rbp), %rdi
callq 0x404f50
movl -0x18(%rbp), %edi
callq 0x40f930
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
addl $0x5, %eax
movb %al, -0xb9(%rbp)
movzbl -0xb9(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
jne 0x40eff0
movb -0xb9(%rbp), %al
addb $0x1, %al
movb %al, -0xb9(%rbp)
movzbl -0xb9(%rbp), %eax
shrl %eax
movb %al, %cl
movb $0x10, %al
subb %cl, %al
orb $0x20, %al
movb %al, -0xba(%rbp)
movb $0x22, -0xf0(%rbp)
movb -0xba(%rbp), %al
movb %al, -0xef(%rbp)
movb $0x12, -0xee(%rbp)
movb $0x22, -0xed(%rbp)
movb $0x14, -0xec(%rbp)
movb $0x14, -0xeb(%rbp)
movb $0x13, -0xea(%rbp)
movb $0xa, -0xe9(%rbp)
leaq -0xf0(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq $0x8, -0xe0(%rbp)
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x404e70
movq -0x280(%rbp), %rcx
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x40fb50
jmp 0x40f093
leaq -0xf1(%rbp), %rdi
callq 0x404fb0
movl -0xb8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x40f10a
movb $0xa, -0xf2(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xf2(%rbp), %rsi
callq 0x40fab0
jmp 0x40f0ce
jmp 0x40f10a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf1(%rbp), %rdi
callq 0x404fb0
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x404f50
jmp 0x40f922
movl -0x18(%rbp), %esi
leaq -0xd8(%rbp), %rdi
callq 0x40f980
jmp 0x40f11b
movb $-0x1, -0xf3(%rbp)
leaq -0xd8(%rbp), %rdi
movl $0x15, %esi
leaq -0xf3(%rbp), %rdx
callq 0x4102b0
jmp 0x40f13c
movl $0x0, -0xf8(%rbp)
movslq -0xf8(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x288(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f1d2
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x298(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x28c(%rbp)
movslq -0xf8(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x405030
movq -0x298(%rbp), %rdi
movl -0x28c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f1b3
jmp 0x40f1b5
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f146
leaq -0xd8(%rbp), %rdi
callq 0x404f50
movb $0x22, -0x123(%rbp)
movb $0x65, -0x122(%rbp)
movb $0xf, -0x121(%rbp)
leaq -0x123(%rbp), %rax
movq %rax, -0x120(%rbp)
movq $0x3, -0x118(%rbp)
leaq -0x124(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x404e70
movq -0x2a0(%rbp), %rcx
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rdx
leaq -0x110(%rbp), %rdi
callq 0x40fb50
jmp 0x40f242
leaq -0x124(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x125(%rbp)
leaq -0x110(%rbp), %rdi
movl $0x12, %esi
leaq -0x125(%rbp), %rdx
callq 0x4102b0
jmp 0x40f26f
movl $0x0, -0x12c(%rbp)
movslq -0x12c(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x2a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f337
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x2b8(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x2ac(%rbp)
movslq -0x12c(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x405030
movq -0x2b8(%rbp), %rdi
movl -0x2ac(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f2ea
jmp 0x40f2ec
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f279
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x124(%rbp), %rdi
callq 0x404fb0
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x40f8cb
movb $0x22, -0x15b(%rbp)
movb $-0x5e, -0x15a(%rbp)
movb $0x1d, -0x159(%rbp)
leaq -0x15b(%rbp), %rax
movq %rax, -0x158(%rbp)
movq $0x3, -0x150(%rbp)
leaq -0x15c(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x404e70
movq -0x2c0(%rbp), %rcx
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
leaq -0x148(%rbp), %rdi
callq 0x40fb50
jmp 0x40f39b
leaq -0x15c(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x15d(%rbp)
leaq -0x148(%rbp), %rdi
movl $0x20, %esi
leaq -0x15d(%rbp), %rdx
callq 0x4102b0
jmp 0x40f3c8
movl $0x0, -0x164(%rbp)
movslq -0x164(%rbp), %rax
movq %rax, -0x2c8(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x2c8(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f490
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x2d8(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x2cc(%rbp)
movslq -0x164(%rbp), %rsi
leaq -0x148(%rbp), %rdi
callq 0x405030
movq -0x2d8(%rbp), %rdi
movl -0x2cc(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f443
jmp 0x40f445
movl -0x164(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x164(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f3d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x15c(%rbp), %rdi
callq 0x404fb0
jmp 0x40f8cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x40f8bf
movb $0x22, -0x193(%rbp)
movb $-0x1a, -0x192(%rbp)
movb $0x13, -0x191(%rbp)
leaq -0x193(%rbp), %rax
movq %rax, -0x190(%rbp)
movq $0x3, -0x188(%rbp)
leaq -0x194(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x404e70
movq -0x2e0(%rbp), %rcx
movq -0x190(%rbp), %rsi
movq -0x188(%rbp), %rdx
leaq -0x180(%rbp), %rdi
callq 0x40fb50
jmp 0x40f4f4
leaq -0x194(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x195(%rbp)
leaq -0x180(%rbp), %rdi
movl $0x16, %esi
leaq -0x195(%rbp), %rdx
callq 0x4102b0
jmp 0x40f521
movl $0x0, -0x19c(%rbp)
movslq -0x19c(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x2e8(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f5e9
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x2f8(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x2ec(%rbp)
movslq -0x19c(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x405030
movq -0x2f8(%rbp), %rdi
movl -0x2ec(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f59c
jmp 0x40f59e
movl -0x19c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x19c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f52b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x194(%rbp), %rdi
callq 0x404fb0
jmp 0x40f8bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x40f8b3
movb $0x23, -0x1cb(%rbp)
movb $0x29, -0x1ca(%rbp)
movb $0xb, -0x1c9(%rbp)
leaq -0x1cb(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq $0x3, -0x1c0(%rbp)
leaq -0x1cc(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x404e70
movq -0x300(%rbp), %rcx
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
leaq -0x1b8(%rbp), %rdi
callq 0x40fb50
jmp 0x40f64d
leaq -0x1cc(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x1cd(%rbp)
leaq -0x1b8(%rbp), %rdi
movl $0xe, %esi
leaq -0x1cd(%rbp), %rdx
callq 0x4102b0
jmp 0x40f67a
movl $0x0, -0x1d4(%rbp)
movslq -0x1d4(%rbp), %rax
movq %rax, -0x308(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x308(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f74e
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x318(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x30c(%rbp)
movslq -0x1d4(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x405030
movq -0x318(%rbp), %rdi
movl -0x30c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f6f5
jmp 0x40f6f7
movl -0x1d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d4(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f684
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1cc(%rbp), %rdi
callq 0x404fb0
jmp 0x40f8b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x404f50
jmp 0x40f8b3
leaq -0x1b8(%rbp), %rdi
callq 0x404f50
leaq -0x180(%rbp), %rdi
callq 0x404f50
leaq -0x148(%rbp), %rdi
callq 0x404f50
leaq -0x110(%rbp), %rdi
callq 0x404f50
movabsq $0x1e1b18231e1b1817, %rax # imm = 0x1E1B18231E1B1817
movq %rax, -0x211(%rbp)
movups 0x18bd31(%rip), %xmm0   # 0x59b4c7
movaps %xmm0, -0x220(%rbp)
leaq -0x220(%rbp), %rax
movq %rax, -0x200(%rbp)
movq $0x17, -0x1f8(%rbp)
leaq -0x221(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x404e70
movq -0x320(%rbp), %rcx
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x1f0(%rbp), %rdi
callq 0x40fb50
jmp 0x40f7ec
leaq -0x221(%rbp), %rdi
callq 0x404fb0
movb $-0x1, -0x222(%rbp)
leaq -0x1f0(%rbp), %rdi
movl $0x1b, %esi
leaq -0x222(%rbp), %rdx
callq 0x4102b0
jmp 0x40f819
movl $0x0, -0x228(%rbp)
movslq -0x228(%rbp), %rax
movq %rax, -0x328(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x405010
movq %rax, %rcx
movq -0x328(%rbp), %rax
cmpq %rcx, %rax
jae 0x40f90d
movq -0x238(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x338(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x32c(%rbp)
movslq -0x228(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
callq 0x405030
movq -0x338(%rbp), %rdi
movl -0x32c(%rbp), %esi
movzbl (%rax), %edx
callq 0x404c20
jmp 0x40f894
jmp 0x40f896
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x40f823
leaq -0x180(%rbp), %rdi
callq 0x404f50
leaq -0x148(%rbp), %rdi
callq 0x404f50
leaq -0x110(%rbp), %rdi
callq 0x404f50
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x221(%rbp), %rdi
callq 0x404fb0
jmp 0x40f922
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x404f50
jmp 0x40f922
leaq -0x1f0(%rbp), %rdi
callq 0x404f50
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4c9ba0
nopl (%rax,%rax)