// File: Bartor[P]kompilator/middle/abstract_assembler/Constant.cpp
// Function: Constant::generateConstant(Constants*, ResolvableAddress&, ResolvableAddress&)
InstructionList &Constant::generateConstant(Constants *constantsData, ResolvableAddress &primaryAccumulator, ResolvableAddress &secondaryAccumulator) {
    InstructionList &instructions = *new InstructionList();

    if (value == 0) {
        instructions.append(new Sub(primaryAccumulator))
                .append(new Store(address));

        return instructions;
    } // 1 and -1 are covered separately

    long long bestPrefix = 0;
    Constant *bestFit = nullptr;

    Constant *closest = nullptr;
    for (auto const &constant : constantsData->getConstants()) {
        if (constant == this) break;
        if (llabs(constant->value) > llabs(value)) break;

        if ((value > 0 && constant->value > 0) || (value < 0 && constant->value < 0)) {
            if (llabs(value) > llabs(constant->value)) {
                if (closest) {
                    if (llabs(value - constant->value) < llabs(value - closest->value)) {
                        closest = constant;
                    }
                } else {
                    closest = constant;
                }
            }
        }

        long long prefix = calculatePrefix(this, constant);
        if (prefix > bestPrefix || (prefix == bestPrefix && constant->value > 0)) {
            bestPrefix = prefix;
            bestFit = constant;
        }
    }

    if (closest && llabs(value - closest->value) < 10) {
        instructions.append(new Load(closest->getAddress()));

        for (long long i = 0; i < llabs(value - closest->value); i++) {
            if (value < 0) {
                instructions.append(new Dec());
            } else {
                instructions.append(new Inc());
            }
        }

        instructions.append(new Store(address));

        return instructions;
    }

    bool byBestFit = false;
    if (bestFit) {
        if (bestPrefix == binaryString.size()) { // the number is actually the same, just with different sign
            byBestFit = true;

            instructions.append(new Sub(primaryAccumulator))
                    .append(new Sub(bestFit->address))
                    .append(new Store(address));
        } else { // numbers differ by last (binaryString.length - bestPrefix) bits
            long long backShifts = bestFit->binaryString.size() - bestPrefix;
            long long cost = (backShifts - 1) * 5 + bestFit->value < 0 ? 20 : 10; // load + shift [-1]s cost
            for (long long i = bestPrefix; i < binaryString.size(); i++) {
                if (binaryString[i] == '1') cost++;
                if (i != binaryString.size() - 1) cost += 5;
            }

            if (cost < generationCost) {
                byBestFit = true;

                if (bestFit->value > 0) {
                    instructions.append(new Load(bestFit->address));
                } else {
                    bestFit->value < 0;
                    instructions.append(new Sub(primaryAccumulator))
                            .append(new Sub(bestFit->getAddress()));
                }

                for (long long i = 0; i < backShifts; i++) instructions.append(new Shift(constantsData->getConstant(-1)->getAddress()));
                instructions.append(new Shift(constantsData->getConstant(1)->getAddress()));
                for (long long i = bestPrefix; i < binaryString.size(); i++) {
                    if (binaryString[i] == '1') instructions.append(new Inc());
                    if (i != binaryString.size() - 1) instructions.append(new Shift(constantsData->getConstant(1)->getAddress()));
                }
                if (value < 0) {
                    instructions.append(new Store(secondaryAccumulator))
                            .append(new Sub(secondaryAccumulator))
                            .append(new Sub(secondaryAccumulator));
                }
                instructions.append(new Store(address));
            } else {
                byBestFit = false;
            }
        }
    }


    if (!byBestFit) {
        instructions.append(new Sub(primaryAccumulator));
        for (long long i = 0; i < binaryString.size(); i++) {
            if (binaryString[i] == '1')instructions.append(new Inc());
            if (i != binaryString.size() - 1) instructions.append(new Shift(constantsData->getConstant(1)->getAddress()));
        }
        if (value < 0)
            instructions.append(new Store(secondaryAccumulator))
                    .append(new Sub(secondaryAccumulator))
                    .append(new Sub(secondaryAccumulator));
        instructions.append(new Store(address));
    }

    return instructions;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x330, %rsp            # imm = 0x330
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe8(%rbp)
callq 0x2b0c0
jmp 0x21f04
movq -0xf0(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, -0x30(%rbp)
cmpq $0x0, 0x8(%rax)
jne 0x22016
movq -0x30(%rbp), %rax
movq %rax, -0x100(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rsi
callq 0x20220
jmp 0x21f4e
movq -0xf8(%rbp), %rsi
movq -0x100(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x110(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq -0xf0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x108(%rbp)
movq (%rax), %rsi
callq 0x200a0
jmp 0x21f90
movq -0x108(%rbp), %rsi
movq -0x110(%rbp), %rdi
callq 0x2b3a0
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x230a2
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x1f8a0
leaq -0x78(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1f8d0
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rdi
callq 0x1f900
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1f930
testb $0x1, %al
jne 0x22083
movl $0x2, -0x8c(%rbp)
jmp 0x22272
leaq -0x80(%rbp), %rdi
callq 0x1f970
movq -0xf0(%rbp), %rcx
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq %rcx, (%rax)
jne 0x220b5
movl $0x2, -0x8c(%rbp)
jmp 0x22272
movq -0xf0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, %rdx
negq %rdx
cmovnsq %rdx, %rax
movq 0x8(%rcx), %rcx
movq %rcx, %rdx
negq %rdx
cmovnsq %rdx, %rcx
cmpq %rcx, %rax
jle 0x220f6
movl $0x2, -0x8c(%rbp)
jmp 0x22272
movq -0xf0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jle 0x22115
movq -0x98(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jg 0x2213c
movq -0xf0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jge 0x221d5
movq -0x98(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jge 0x221d5
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, %rcx
negq %rcx
cmovnsq %rcx, %rax
movq -0x98(%rbp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, %rdx
negq %rdx
cmovnsq %rdx, %rcx
cmpq %rcx, %rax
jle 0x221d3
cmpq $0x0, -0x58(%rbp)
je 0x221c3
movq -0xf0(%rbp), %rcx
movq 0x8(%rcx), %rax
movq -0x98(%rbp), %rdx
movq (%rdx), %rdx
subq 0x8(%rdx), %rax
movq %rax, %rdx
negq %rdx
cmovnsq %rdx, %rax
movq 0x8(%rcx), %rcx
movq -0x58(%rbp), %rdx
subq 0x8(%rdx), %rcx
movq %rcx, %rdx
negq %rdx
cmovnsq %rdx, %rcx
cmpq %rcx, %rax
jge 0x221c1
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x221d1
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x221d3
jmp 0x221d5
movq -0xf0(%rbp), %rdi
movq -0x98(%rbp), %rax
movq (%rax), %rsi
callq 0x21ca0
movq %rax, -0x118(%rbp)
jmp 0x221f4
movq -0x118(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
cmpq -0x48(%rbp), %rax
jg 0x2222d
movq -0xa0(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x22262
movq -0x98(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
jle 0x22262
movq -0xa0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x22262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x1f9b0
jmp 0x230af
jmp 0x22264
leaq -0x80(%rbp), %rdi
callq 0x1f990
jmp 0x22060
leaq -0x78(%rbp), %rdi
callq 0x1f9b0
cmpq $0x0, -0x58(%rbp)
je 0x2248f
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x58(%rbp), %rcx
subq 0x8(%rcx), %rax
movq %rax, %rcx
negq %rcx
cmovnsq %rcx, %rax
cmpq $0xa, %rax
jge 0x2248f
movq -0x30(%rbp), %rax
movq %rax, -0x130(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x128(%rbp)
movq -0x58(%rbp), %rdi
callq 0x230c0
movq %rax, -0x120(%rbp)
jmp 0x222db
movq -0x120(%rbp), %rsi
movq -0x128(%rbp), %rdi
callq 0x201a0
jmp 0x222f0
movq -0x128(%rbp), %rsi
movq -0x130(%rbp), %rdi
callq 0x2b3a0
movq $0x0, -0xa8(%rbp)
movq -0xf0(%rbp), %rcx
movq -0xa8(%rbp), %rax
movq 0x8(%rcx), %rcx
movq -0x58(%rbp), %rdx
subq 0x8(%rdx), %rcx
movq %rcx, %rdx
negq %rdx
cmovnsq %rdx, %rcx
cmpq %rcx, %rax
jge 0x2241a
movq -0xf0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jge 0x223b7
movq -0x30(%rbp), %rax
movq %rax, -0x140(%rbp)
movl $0x18, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, -0x138(%rbp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x6160
movq -0x138(%rbp), %rdi
callq 0x202e0
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
callq 0x2b3a0
jmp 0x22401
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x150(%rbp)
movl $0x18, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, -0x148(%rbp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x6160
movq -0x148(%rbp), %rdi
callq 0x20320
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
callq 0x2b3a0
jmp 0x22403
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa8(%rbp)
jmp 0x2230e
movq -0x30(%rbp), %rax
movq %rax, -0x160(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq -0xf0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x158(%rbp)
movq (%rax), %rsi
callq 0x200a0
jmp 0x2244d
movq -0x158(%rbp), %rsi
movq -0x160(%rbp), %rdi
callq 0x2b3a0
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x230a2
movq -0x158(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movb $0x0, -0xa9(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x22d0c
movq -0xf0(%rbp), %rdi
movq -0x48(%rbp), %rax
movq %rax, -0x168(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x168(%rbp), %rax
cmpq %rcx, %rax
jne 0x22602
movb $0x1, -0xa9(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x178(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x170(%rbp)
movq -0x20(%rbp), %rsi
callq 0x20220
jmp 0x22503
movq -0x170(%rbp), %rsi
movq -0x178(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x188(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x180(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rsi
callq 0x20220
jmp 0x22542
movq -0x180(%rbp), %rsi
movq -0x188(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x198(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq -0xf0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x190(%rbp)
movq (%rax), %rsi
callq 0x200a0
jmp 0x22584
movq -0x190(%rbp), %rsi
movq -0x198(%rbp), %rdi
callq 0x2b3a0
jmp 0x22d0a
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x190(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
callq 0x61a0
subq -0x48(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
subq $0x1, %rax
imulq $0x5, %rax, %rdx
movq -0x50(%rbp), %rax
addq 0x8(%rax), %rdx
movl $0xa, %eax
movl $0x14, %ecx
cmpq $0x0, %rdx
cmovll %ecx, %eax
cltq
movq %rax, -0xc0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq %rax, -0x1a0(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x1a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x22714
movq -0xf0(%rbp), %rdi
addq $0x18, %rdi
movq -0xc8(%rbp), %rsi
callq 0x6580
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x226b8
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x226fb
movq -0xc0(%rbp), %rax
addq $0x5, %rax
movq %rax, -0xc0(%rbp)
jmp 0x226fd
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
jmp 0x22656
movq -0xf0(%rbp), %rcx
movq -0xc0(%rbp), %rax
cmpq 0x10(%rcx), %rax
jge 0x22d01
movb $0x1, -0xa9(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jle 0x227a8
movq -0x30(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1b0(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rsi
callq 0x201a0
jmp 0x2276e
movq -0x1b0(%rbp), %rsi
movq -0x1b8(%rbp), %rdi
callq 0x2b3a0
jmp 0x22880
movq -0x1b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1c0(%rbp)
movq -0x20(%rbp), %rsi
callq 0x20220
jmp 0x227d5
movq -0x1c0(%rbp), %rsi
movq -0x1c8(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x1e0(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x1d8(%rbp)
movq -0x50(%rbp), %rdi
callq 0x230c0
movq %rax, -0x1d0(%rbp)
jmp 0x22812
movq -0x1d0(%rbp), %rsi
movq -0x1d8(%rbp), %rdi
callq 0x20220
jmp 0x22827
movq -0x1d8(%rbp), %rsi
movq -0x1e0(%rbp), %rdi
callq 0x2b3a0
jmp 0x22880
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x1d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq $0x0, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x2294a
movq -0x30(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x1f0(%rbp)
movq -0x18(%rbp), %rdi
movq $-0x1, %rsi
callq 0x23910
movq %rax, -0x1e8(%rbp)
jmp 0x228d4
movq -0x1e8(%rbp), %rdi
callq 0x230c0
movq %rax, -0x200(%rbp)
jmp 0x228e9
movq -0x200(%rbp), %rsi
movq -0x1f0(%rbp), %rdi
callq 0x20450
jmp 0x228fe
movq -0x1f0(%rbp), %rsi
movq -0x1f8(%rbp), %rdi
callq 0x2b3a0
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x2288b
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x218(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x210(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x23910
movq %rax, -0x208(%rbp)
jmp 0x2297d
movq -0x208(%rbp), %rdi
callq 0x230c0
movq %rax, -0x220(%rbp)
jmp 0x22992
movq -0x220(%rbp), %rsi
movq -0x210(%rbp), %rdi
callq 0x20450
jmp 0x229a7
movq -0x210(%rbp), %rsi
movq -0x218(%rbp), %rdi
callq 0x2b3a0
movq -0x48(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xd8(%rbp), %rax
movq %rax, -0x228(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x228(%rbp), %rax
cmpq %rcx, %rax
jae 0x22b65
movq -0xf0(%rbp), %rdi
addq $0x18, %rdi
movq -0xd8(%rbp), %rsi
callq 0x6580
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x22a83
movq -0x30(%rbp), %rax
movq %rax, -0x238(%rbp)
movl $0x18, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, -0x230(%rbp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x6160
movq -0x230(%rbp), %rdi
callq 0x20320
movq -0x238(%rbp), %rdi
movq -0x230(%rbp), %rsi
callq 0x2b3a0
jmp 0x22a83
movq -0x210(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0xf0(%rbp), %rdi
movq -0xd8(%rbp), %rax
movq %rax, -0x240(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x240(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x22b4c
movq -0x30(%rbp), %rax
movq %rax, -0x258(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x250(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x23910
movq %rax, -0x248(%rbp)
jmp 0x22aeb
movq -0x248(%rbp), %rdi
callq 0x230c0
movq %rax, -0x260(%rbp)
jmp 0x22b00
movq -0x260(%rbp), %rsi
movq -0x250(%rbp), %rdi
callq 0x20450
jmp 0x22b15
movq -0x250(%rbp), %rsi
movq -0x258(%rbp), %rdi
callq 0x2b3a0
jmp 0x22b4c
movq -0x250(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
jmp 0x22b4e
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
jmp 0x229c5
movq -0xf0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jge 0x22c97
movq -0x30(%rbp), %rax
movq %rax, -0x270(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x268(%rbp)
movq -0x28(%rbp), %rsi
callq 0x200a0
jmp 0x22ba4
movq -0x268(%rbp), %rsi
movq -0x270(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x280(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x278(%rbp)
movq -0x28(%rbp), %rsi
callq 0x20220
jmp 0x22be0
movq -0x278(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x290(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x288(%rbp)
movq -0x28(%rbp), %rsi
callq 0x20220
jmp 0x22c1c
movq -0x288(%rbp), %rsi
movq -0x290(%rbp), %rdi
callq 0x2b3a0
jmp 0x22c97
movq -0x268(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x278(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x288(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq -0xf0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x298(%rbp)
movq (%rax), %rsi
callq 0x200a0
jmp 0x22cca
movq -0x298(%rbp), %rsi
movq -0x2a0(%rbp), %rdi
callq 0x2b3a0
jmp 0x22d08
movq -0x298(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movb $0x0, -0xa9(%rbp)
jmp 0x22d0a
jmp 0x22d0c
testb $0x1, -0xa9(%rbp)
jne 0x2309a
movq -0x30(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2a8(%rbp)
movq -0x20(%rbp), %rsi
callq 0x20220
jmp 0x22d46
movq -0x2a8(%rbp), %rsi
movq -0x2b0(%rbp), %rdi
callq 0x2b3a0
movq $0x0, -0xe0(%rbp)
movq -0xf0(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq %rax, -0x2b8(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x2b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x22f04
movq -0xf0(%rbp), %rdi
addq $0x18, %rdi
movq -0xe0(%rbp), %rsi
callq 0x6580
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x22e22
movq -0x30(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movl $0x18, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, -0x2c0(%rbp)
xorl %esi, %esi
movl $0x18, %edx
callq 0x6160
movq -0x2c0(%rbp), %rdi
callq 0x20320
movq -0x2c8(%rbp), %rdi
movq -0x2c0(%rbp), %rsi
callq 0x2b3a0
jmp 0x22e22
movq -0x2a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0xf0(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq %rax, -0x2d0(%rbp)
addq $0x18, %rdi
callq 0x61a0
movq %rax, %rcx
movq -0x2d0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x22eeb
movq -0x30(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, -0x2e0(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x23910
movq %rax, -0x2d8(%rbp)
jmp 0x22e8a
movq -0x2d8(%rbp), %rdi
callq 0x230c0
movq %rax, -0x2f0(%rbp)
jmp 0x22e9f
movq -0x2f0(%rbp), %rsi
movq -0x2e0(%rbp), %rdi
callq 0x20450
jmp 0x22eb4
movq -0x2e0(%rbp), %rsi
movq -0x2e8(%rbp), %rdi
callq 0x2b3a0
jmp 0x22eeb
movq -0x2e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
jmp 0x22eed
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x22d64
movq -0xf0(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jge 0x23033
movq -0x30(%rbp), %rax
movq %rax, -0x300(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2f8(%rbp)
movq -0x28(%rbp), %rsi
callq 0x200a0
jmp 0x22f43
movq -0x2f8(%rbp), %rsi
movq -0x300(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x310(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x308(%rbp)
movq -0x28(%rbp), %rsi
callq 0x20220
jmp 0x22f7f
movq -0x308(%rbp), %rsi
movq -0x310(%rbp), %rdi
callq 0x2b3a0
movq %rax, -0x320(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x318(%rbp)
movq -0x28(%rbp), %rsi
callq 0x20220
jmp 0x22fbb
movq -0x318(%rbp), %rsi
movq -0x320(%rbp), %rdi
callq 0x2b3a0
jmp 0x23033
movq -0x2f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x308(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x318(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x330(%rbp)
movl $0x20, %edi
callq 0x6260
movq %rax, %rdi
movq -0xf0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x328(%rbp)
movq (%rax), %rsi
callq 0x200a0
jmp 0x23066
movq -0x328(%rbp), %rsi
movq -0x330(%rbp), %rdi
callq 0x2b3a0
jmp 0x2309a
movq -0x328(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x20, %esi
callq 0x6270
jmp 0x230af
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x330, %rsp            # imm = 0x330
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x64d0
nopl (%rax,%rax)