// File: /workspace/github_cpp_makefile_star2_O1/VanAndelInstitute[P]intent/src/edlib.cpp
// Function: obtainAlignment(unsigned char const*, unsigned char const*, int, unsigned char const*, unsigned char const*, int, EqualityDefinition const&, int, int, unsigned char**, int*)
static int obtainAlignment(
        const unsigned char* const query, const unsigned char* const rQuery, const int queryLength,
        const unsigned char* const target, const unsigned char* const rTarget, const int targetLength,
        const EqualityDefinition& equalityDefinition, const int alphabetLength, const int bestScore,
        unsigned char** const alignment, int* const alignmentLength) {

    // Handle special case when one of sequences has length of 0.
    if (queryLength == 0 || targetLength == 0) {
        *alignmentLength = targetLength + queryLength;
        *alignment = static_cast<unsigned char*>(malloc((*alignmentLength) * sizeof(unsigned char)));
        for (int i = 0; i < *alignmentLength; i++) {
            (*alignment)[i] = queryLength == 0 ? EDLIB_EDOP_DELETE : EDLIB_EDOP_INSERT;
        }
        return EDLIB_STATUS_OK;
    }

    const int maxNumBlocks = ceilDiv(queryLength, WORD_SIZE);
    const int W = maxNumBlocks * WORD_SIZE - queryLength;
    int statusCode;

    // TODO: think about reducing number of memory allocations in alignment functions, probably
    // by sharing some memory that is allocated only once. That refers to: Peq, columns in Hirschberg,
    // and it could also be done for alignments - we could have one big array for alignment that would be
    // sparsely populated by each of steps in recursion, and at the end we would just consolidate those results.

    // If estimated memory consumption for traceback algorithm is smaller than 1MB use it,
    // otherwise use Hirschberg's algorithm. By running few tests I choose boundary of 1MB as optimal.
    long long alignmentDataSize = (2ll * sizeof(Word) + sizeof(int)) * maxNumBlocks * targetLength
        + 2ll * sizeof(int) * targetLength;
    if (alignmentDataSize < 1024 * 1024) {
        int score_, endLocation_;  // Used only to call function.
        AlignmentData* alignData = NULL;
        Word* Peq = buildPeq(alphabetLength, query, queryLength, equalityDefinition);
        myersCalcEditDistanceNW(Peq, W, maxNumBlocks,
                                queryLength,
                                target, targetLength,
                                bestScore,
                                &score_, &endLocation_, true, &alignData, -1);
        //assert(score_ == bestScore);
        //assert(endLocation_ == targetLength - 1);

        statusCode = obtainAlignmentTraceback(queryLength, targetLength,
                                              bestScore, alignData, alignment, alignmentLength);
        delete alignData;
        delete[] Peq;
    } else {
        statusCode = obtainAlignmentHirschberg(query, rQuery, queryLength,
                                               target, rTarget, targetLength,
                                               equalityDefinition, alphabetLength, bestScore,
                                               alignment, alignmentLength);
    }
    return statusCode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r13
movq 0x110(%rsp), %r15
movq 0x108(%rsp), %rbx
testl %edx, %edx
setne %al
testl %r9d, %r9d
setne %sil
testb %sil, %al
jne 0x2c1f3
addl %edx, %r9d
movl %r9d, (%r15)
movslq %r9d, %r14
movq %r14, %rdi
movq %rdx, %r12
callq 0x6530
movq %rax, (%rbx)
testl %r14d, %r14d
jle 0x2d1df
xorl %ebp, %ebp
cmpl $0x1, %r12d
movl $0x0, %eax
adcb $0x1, %al
xorl %ecx, %ecx
movq (%rbx), %rdx
movb %al, (%rdx,%rcx)
incq %rcx
movslq (%r15), %rdx
cmpq %rdx, %rcx
jl 0x2c1dd
jmp 0x2d1e1
movq %rdi, %r12
testb $0x3f, %dl
je 0x2c20e
leal 0x3f(%rdx), %r10d
testl %edx, %edx
cmovnsl %edx, %r10d
sarl $0x6, %r10d
incl %r10d
jmp 0x2c215
movl %edx, %r10d
sarl $0x6, %r10d
movl 0xf8(%rsp), %edi
movq 0xf0(%rsp), %rbx
leal (,%r10,4), %eax
leal (%rax,%rax,4), %eax
cltq
movslq %r9d, %rsi
addq $0x8, %rax
imulq %rsi, %rax
cmpq $0xfffff, %rax          # imm = 0xFFFFF
movq %rdx, 0x38(%rsp)
movq %rcx, 0x48(%rsp)
movq %r9, 0x30(%rsp)
jg 0x2c27b
movl %r10d, %eax
shll $0x6, %eax
movq $0x0, 0x78(%rsp)
testb $0x3f, %dl
movq %r10, 0x8(%rsp)
je 0x2c296
leal 0x3f(%rdx), %ebp
testl %edx, %edx
cmovnsl %edx, %ebp
sarl $0x6, %ebp
incl %ebp
jmp 0x2c29b
testb $0x3f, %dl
je 0x2c3ea
leal 0x3f(%rdx), %eax
testl %edx, %edx
cmovnsl %edx, %eax
sarl $0x6, %eax
incl %eax
jmp 0x2c3ef
movl %edx, %ebp
sarl $0x6, %ebp
subl %edx, %eax
movl %eax, 0x18(%rsp)
leal 0x1(%rdi), %eax
imull %ebp, %eax
cltq
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x6030
movl 0xf8(%rsp), %r11d
movq %rax, 0x40(%rsp)
testl %r11d, %r11d
js 0x2c382
movslq 0x38(%rsp), %rax
movl %ebp, %ecx
xorl %esi, %esi
xorl %edx, %edx
movl %ebp, %r15d
testl %ebp, %ebp
jle 0x2c371
movl %esi, %r8d
imull %r15d, %r8d
movzbl %dl, %edi
movq 0x40(%rsp), %r9
leaq (%r9,%r8,8), %r8
movl $0x3f, %r14d
xorl %r10d, %r10d
cmpl %r11d, %esi
jge 0x2c35d
movq $0x0, (%r8,%r10,8)
movq %r10, %r11
shlq $0x6, %r11
movq %r14, %r9
xorl %ebp, %ebp
addq %rbp, %rbp
cmpq %rax, %r9
jge 0x2c33f
movzbl (%r12,%r9), %r13d
shll $0x8, %r13d
addq %rbx, %r13
cmpb $0x1, (%rdi,%r13)
jne 0x2c343
orq $0x1, %rbp
leaq -0x1(%r9), %r13
cmpq %r11, %r9
movq %r13, %r9
ja 0x2c324
movq %rbp, (%r8,%r10,8)
movl 0xf8(%rsp), %r11d
jmp 0x2c365
movq $-0x1, (%r8,%r10,8)
incq %r10
addq $0x40, %r14
cmpq %rcx, %r10
jne 0x2c30b
incb %dl
movzbl %dl, %esi
cmpl %r11d, %esi
movl %r15d, %ebp
jle 0x2c2e4
leaq 0x78(%rsp), %rbx
leaq 0x68(%rsp), %rax
leaq 0x70(%rsp), %r10
movq 0x40(%rsp), %rdi
movl 0x18(%rsp), %esi
movq 0x8(%rsp), %rdx
movq 0x38(%rsp), %r14
movl %r14d, %ecx
movq 0x48(%rsp), %r8
movq 0x30(%rsp), %r9
pushq $-0x1
pushq %rbx
pushq $0x1
pushq %rax
pushq %r10
movl 0x128(%rsp), %eax
pushq %rax
callq 0x2b689
addq $0x30, %rsp
movq (%rbx), %rax
movq %rax, 0x10(%rsp)
testb $0x3f, %r14b
je 0x2c413
leal 0x3f(%r14), %eax
testl %r14d, %r14d
cmovnsl %r14d, %eax
sarl $0x6, %eax
incl %eax
jmp 0x2c419
movl %edx, %eax
sarl $0x6, %eax
movl %eax, 0x10(%rsp)
movq %r8, 0x60(%rsp)
testb $0x3f, %dl
je 0x2ca1c
leal 0x3f(%rdx), %ebp
testl %edx, %edx
cmovnsl %edx, %ebp
sarl $0x6, %ebp
incl %ebp
jmp 0x2ca21
movl %r14d, %eax
sarl $0x6, %eax
movq %rax, 0x28(%rsp)
movl %eax, %r12d
shll $0x6, %r12d
movq 0x30(%rsp), %r15
leal -0x1(%r15), %ebx
leal (%r15,%r14), %eax
decl %eax
movq %r15, %r14
movslq %eax, %rdi
callq 0x6530
movq 0x28(%rsp), %r11
movq 0x108(%rsp), %rcx
movq %rax, (%rcx)
movq 0x110(%rsp), %rax
movl $0x0, (%rax)
leal -0x1(%r11), %eax
movq 0x10(%rsp), %r9
movq (%r9), %rcx
movq 0x8(%r9), %rsi
movl %r11d, %edx
imull %ebx, %edx
addl %r11d, %edx
decl %edx
movslq %edx, %rdx
cmpl $0x2, %r14d
jl 0x2c49d
movq 0x18(%r9), %r8
leal -0x2(%r14), %edi
cmpl (%r8,%rdi,4), %r11d
jle 0x2c49d
movq 0x20(%r9), %r8
cmpl (%r8,%rdi,4), %eax
setle %r10b
jmp 0x2c4a0
xorl %r10d, %r10d
subl 0x38(%rsp), %r12d
movq (%rcx,%rdx,8), %r9
movq (%rsi,%rdx,8), %rdx
testb %r10b, %r10b
je 0x2c4ca
addl $-0x2, %r14d
imull %r11d, %r14d
addl %eax, %r14d
movslq %r14d, %rdi
movq (%rcx,%rdi,8), %r8
movq (%rsi,%rdi,8), %rsi
jmp 0x2c4cf
xorl %r8d, %r8d
xorl %esi, %esi
movl %r12d, %ecx
shlq %cl, %r9
movq %r9, 0x18(%rsp)
shlq %cl, %rdx
movq %rdx, 0x20(%rsp)
movl $0x3f, %ecx
subl %r12d, %ecx
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl 0x100(%rsp), %ebp
movl %ebx, %r14d
movl %ebp, %r15d
movl %r12d, %edx
movl %r11d, %ebx
movl %eax, %r9d
shll $0x6, %r9d
leal (%r9,%rcx), %r12d
testl %r14d, %r14d
leal 0x1(%r9,%rcx), %r11d
cmovel %r11d, %ebx
cmovel %r12d, %edx
movq %rdx, 0x8(%rsp)
movzbl %r10b, %r10d
movl $0x1, %edx
cmovel %edx, %r10d
cmpl $-0x1, %ebx
jne 0x2c596
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb $0x1, %r10b
je 0x2c596
movq 0x10(%rsp), %rdx
movq 0x10(%rdx), %rdi
leal -0x1(%r14), %ebx
imull 0x28(%rsp), %ebx
addl %eax, %ebx
movslq %ebx, %rbx
movl (%rdi,%rbx,4), %edi
movl $0x3f, %ebx
subl %ecx, %ebx
testl %ebx, %ebx
jle 0x2c594
leal -0x3f(%rcx), %ebp
movq %r8, %rdx
sarq $0x3f, %rdx
movq %rsi, %rbx
shrq $0x3f, %rbx
addl %edi, %ebx
addl %edx, %ebx
addq %r8, %r8
addq %rsi, %rsi
movl %ebx, %edi
incl %ebp
jne 0x2c574
jmp 0x2c596
movl %edi, %ebx
cmpl $-0x1, 0x8(%rsp)
jne 0x2c5bd
cmpl $-0x1, %ebx
je 0x2c762
movq %r8, %rdx
sarq $0x3f, %rdx
movq %rsi, %rdi
shrq $0x3f, %rdi
addl %edx, %edi
addl %ebx, %edi
movq %rdi, 0x8(%rsp)
cmpl $-0x1, %r13d
jne 0x2c5f1
movq 0x18(%rsp), %rdi
movq %rdi, %rdx
sarq $0x3f, %rdx
movq 0x20(%rsp), %rbp
movq %rbp, %r13
shrq $0x3f, %r13
addl %edx, %r13d
addl %r15d, %r13d
addq %rdi, %rdi
movq %rdi, 0x18(%rsp)
addq %rbp, %rbp
movq %rbp, 0x20(%rsp)
cmpl $-0x1, %r13d
je 0x2c62e
leal 0x1(%r13), %edx
cmpl %r15d, %edx
jne 0x2c62e
testl %ecx, %ecx
je 0x2c6e3
decl %ecx
addq %r8, %r8
addq %rsi, %rsi
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movb $0x1, %r9b
movq 0x8(%rsp), %rdx
movl %edx, %r11d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %eax, %ebx
jmp 0x2c83f
cmpl $-0x1, %ebx
je 0x2c69b
leal 0x1(%rbx), %edx
cmpl %r15d, %edx
jne 0x2c69b
testl %r14d, %r14d
je 0x2d05e
leal -0x1(%r14), %ebp
cmpl $0x2, %r14d
jl 0x2c674
movq 0x10(%rsp), %rdx
movq 0x18(%rdx), %rdx
addl $-0x2, %r14d
cmpl (%rdx,%r14,4), %eax
jl 0x2c674
movq 0x10(%rsp), %rdx
movq 0x20(%rdx), %rdx
cmpl (%rdx,%r14,4), %eax
jle 0x2c940
movb $0x2, %r9b
testl %ebp, %ebp
je 0x2c822
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movq 0x8(%rsp), %rdx
movl %edx, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x2c82d
movq 0x8(%rsp), %rdi
cmpl $-0x1, %edi
je 0x2d16c
xorl %edx, %edx
cmpl %r15d, %edi
setne %dl
leal -0x1(%r14), %ebx
leal (%rdx,%rdx,2), %r15d
testl %r14d, %r14d
je 0x2c7bd
testl %ecx, %ecx
movq 0x10(%rsp), %r11
je 0x2c871
decl %ecx
leaq (%r8,%r8), %r9
leaq (%rsi,%rsi), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x2c8b2
testl %eax, %eax
je 0x2d121
leal -0x1(%rax), %ebx
movq 0x10(%rsp), %r12
movq (%r12), %r10
movq 0x8(%r12), %r11
movl %r14d, %ecx
imull 0x28(%rsp), %ecx
addl %eax, %ecx
decl %ecx
movslq %ecx, %rcx
movq (%r10,%rcx,8), %rdx
movq %rdx, 0x18(%rsp)
movq (%r11,%rcx,8), %rcx
movq %rcx, 0x20(%rsp)
movl $0x3f, %ecx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movb $0x1, %r9b
testl %r14d, %r14d
jle 0x2c74c
movq 0x18(%r12), %rdx
leal -0x1(%r14), %edi
cmpl (%rdx,%rdi,4), %eax
jle 0x2c74c
movq 0x20(%r12), %rax
cmpl (%rax,%rdi,4), %ebx
jle 0x2c989
xorl %r10d, %r10d
movq 0x8(%rsp), %rax
movl %eax, %r11d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x2c83f
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rdx, 0x8(%rsp)
testl %r14d, %r14d
jle 0x2c5bd
movq 0x10(%rsp), %rbp
movq 0x18(%rbp), %rdx
leal -0x1(%r14), %edi
cmpl (%rdx,%rdi,4), %eax
jle 0x2c5bd
leal -0x1(%rax), %edx
movq 0x20(%rbp), %rbp
cmpl (%rbp,%rdi,4), %edx
jg 0x2c5bd
movq 0x10(%rsp), %rdx
movq 0x10(%rdx), %rdx
imull 0x28(%rsp), %edi
addl %eax, %edi
movslq %edi, %rdi
movl -0x4(%rdx,%rdi,4), %edx
movq %rdx, 0x8(%rsp)
jmp 0x2c5bd
movq 0x108(%rsp), %rdx
movq (%rdx), %rdx
movq 0x110(%rsp), %r14
movslq (%r14), %rdi
leal 0x1(%rdi), %r11d
movl %r11d, (%r14)
movb %r15b, (%rdx,%rdi)
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
testl %r12d, %r12d
jle 0x2c814
negl %r9d
movq 0x108(%rsp), %r14
movq 0x110(%rsp), %r15
movq (%r14), %rdx
movslq (%r15), %rdi
leal 0x1(%rdi), %ebp
movl %ebp, (%r15)
movb $0x1, (%rdx,%rdi)
incl %r9d
cmpl %r9d, %ecx
jne 0x2c7fc
xorl %r9d, %r9d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x2c927
movb $0x1, %r10b
movq 0x8(%rsp), %rdx
movl %edx, %r15d
movq %r8, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movl %ebx, %r13d
movl %eax, %ebx
movl %ebp, %r14d
movl %r13d, %ebp
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq 0x110(%rsp), %r13
movslq (%r13), %rdx
leal 0x1(%rdx), %edi
movl %edi, (%r13)
movb %r9b, (%rax,%rdx)
movl %r15d, %r13d
movl %ebx, %eax
movl %r14d, %ebx
jmp 0x2c503
testl %eax, %eax
movq 0x108(%rsp), %rdi
movq 0x110(%rsp), %r9
je 0x2c9b1
movl %ebx, %ecx
imull 0x28(%rsp), %ecx
addl %eax, %ecx
decl %ecx
decl %eax
movslq %ecx, %rcx
movq (%r11), %rdx
movq 0x8(%r11), %rdi
movq (%rdx,%rcx,8), %r9
movq (%rdi,%rcx,8), %rcx
movq %rcx, 0x20(%rsp)
movl $0x3f, %ecx
cmpl $0x2, %r14d
movq %r9, 0x18(%rsp)
jl 0x2c8d9
movq 0x18(%r11), %rdx
addl $-0x2, %r14d
cmpl (%rdx,%r14,4), %eax
jl 0x2c8d9
movq 0x20(%r11), %rdx
cmpl (%rdx,%r14,4), %eax
jle 0x2c9f3
testl %ebx, %ebx
je 0x2c8ee
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x2c903
movl %eax, %edx
shll $0x6, %edx
leal (%rdx,%rcx), %r11d
incl %r11d
movl %edx, %r12d
addl %ecx, %r12d
movb $0x1, %r10b
movq 0x108(%rsp), %rdx
movq (%rdx), %rdx
movq 0x110(%rsp), %r14
movslq (%r14), %rdi
leal 0x1(%rdi), %r9d
movl %r9d, (%r14)
movb %r15b, (%rdx,%rdi)
movb $0x1, %r9b
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %r9b, %r9b
movq 0x8(%rsp), %rbp
jne 0x2c503
jmp 0x2d16c
imull 0x28(%rsp), %r14d
addl %eax, %r14d
movslq %r14d, %rdx
movq 0x10(%rsp), %r9
movq (%r9), %rdi
movq 0x8(%r9), %r9
movq %r8, 0x18(%rsp)
movq (%rdi,%rdx,8), %r8
movq %rsi, 0x20(%rsp)
movq (%r9,%rdx,8), %rsi
movb $0x1, %r10b
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movb $0x2, %r9b
movq 0x8(%rsp), %rdx
movl %edx, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x2c837
imull 0x28(%rsp), %edi
addl %ebx, %edi
movslq %edi, %rax
movq (%r10,%rax,8), %r8
movq (%r11,%rax,8), %rsi
movq 0x8(%rsp), %rax
movl %eax, %r11d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movb $0x1, %r10b
jmp 0x2c83f
movq (%rdi), %rax
movslq (%r9), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r9)
movb %r15b, (%rax,%rcx)
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
testl %r14d, %r14d
jle 0x2c9e1
movq (%rdi), %rax
movslq (%r9), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%r9)
movb $0x2, (%rax,%rcx)
decl %r14d
jne 0x2c9cc
xorl %ecx, %ecx
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %r9d, %r9d
jmp 0x2c927
imull 0x28(%rsp), %r14d
addl %eax, %r14d
movslq %r14d, %rdx
movq (%r11), %rsi
movq 0x8(%r11), %rdi
movq (%rsi,%rdx,8), %r8
movq (%rdi,%rdx,8), %rsi
movb $0x1, %r10b
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
jmp 0x2c8e6
movl %edx, %ebp
sarl $0x6, %ebp
movq %rdx, %r14
leal 0x1(%rdi), %ecx
movl %ebp, %eax
movl %ecx, 0x20(%rsp)
imull %ecx, %eax
cltq
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x6030
movl 0xf8(%rsp), %r8d
movq %rax, 0x18(%rsp)
movslq %r14d, %r14
testl %r8d, %r8d
js 0x2cb0b
movl %ebp, %eax
xorl %edx, %edx
xorl %ecx, %ecx
movl %ebp, 0x8(%rsp)
testl %ebp, %ebp
jle 0x2caf9
movl %edx, %edi
imull 0x8(%rsp), %edi
movzbl %cl, %esi
movq 0x18(%rsp), %r9
leaq (%r9,%rdi,8), %rdi
movl $0x3f, %ebp
xorl %r9d, %r9d
cmpl %r8d, %edx
jge 0x2cae5
movq $0x0, (%rdi,%r9,8)
movq %r9, %r10
shlq $0x6, %r10
movq %rbp, %r8
xorl %r11d, %r11d
addq %r11, %r11
cmpq %r14, %r8
jge 0x2cac7
movzbl (%r12,%r8), %r15d
shll $0x8, %r15d
addq %rbx, %r15
cmpb $0x1, (%rsi,%r15)
jne 0x2cacb
orq $0x1, %r11
leaq -0x1(%r8), %r15
cmpq %r10, %r8
movq %r15, %r8
ja 0x2caac
movq %r11, (%rdi,%r9,8)
movl 0xf8(%rsp), %r8d
jmp 0x2caed
movq $-0x1, (%rdi,%r9,8)
incq %r9
addq $0x40, %rbp
cmpq %rax, %r9
jne 0x2ca92
incb %cl
movzbl %cl, %edx
cmpl %r8d, %edx
movl 0x8(%rsp), %ebp
jle 0x2ca6f
movl 0x10(%rsp), %ecx
shll $0x6, %ecx
movq 0x38(%rsp), %rax
testb $0x3f, %al
je 0x2cb2a
leal 0x3f(%rax), %ebp
testl %eax, %eax
cmovnsl %eax, %ebp
sarl $0x6, %ebp
incl %ebp
jmp 0x2cb2f
movl %eax, %ebp
sarl $0x6, %ebp
movl 0x20(%rsp), %edx
subl %eax, %ecx
movl %ecx, 0x40(%rsp)
imull %ebp, %edx
movslq %edx, %rax
leaq (,%rax,8), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x6030
movq %rax, 0x20(%rsp)
movl 0xf8(%rsp), %r8d
testl %r8d, %r8d
js 0x2cc16
movl %ebp, %eax
xorl %edx, %edx
xorl %ecx, %ecx
movl %ebp, 0x8(%rsp)
testl %ebp, %ebp
jle 0x2cc04
movl %edx, %edi
imull 0x8(%rsp), %edi
movzbl %cl, %esi
movq 0x20(%rsp), %r9
leaq (%r9,%rdi,8), %rdi
movl $0x3f, %ebp
xorl %r9d, %r9d
cmpl %r8d, %edx
jge 0x2cbf0
movq $0x0, (%rdi,%r9,8)
movq %r9, %r10
shlq $0x6, %r10
movq %rbp, %r8
xorl %r11d, %r11d
addq %r11, %r11
cmpq %r14, %r8
jge 0x2cbd2
movzbl (%r13,%r8), %r15d
shll $0x8, %r15d
addq %rbx, %r15
cmpb $0x1, (%rsi,%r15)
jne 0x2cbd6
orq $0x1, %r11
leaq -0x1(%r8), %r15
cmpq %r10, %r8
movq %r15, %r8
ja 0x2cbb6
movq %r11, (%rdi,%r9,8)
movl 0xf8(%rsp), %r8d
jmp 0x2cbf8
movq $-0x1, (%rdi,%r9,8)
incq %r9
addq $0x40, %rbp
cmpq %rax, %r9
jne 0x2cb9c
incb %cl
movzbl %cl, %edx
cmpl %r8d, %edx
movl 0x8(%rsp), %ebp
jle 0x2cb79
movq 0x30(%rsp), %r15
movl %r15d, %eax
shrl $0x1f, %eax
addl %r15d, %eax
sarl %eax
movl %r15d, %ebp
subl %eax, %ebp
xorl %edx, %edx
leaq 0x78(%rsp), %rcx
movq %rdx, (%rcx)
movq %rcx, %r10
movq %rax, 0xa8(%rsp)
decl %eax
leaq 0x90(%rsp), %r11
movq 0x18(%rsp), %rdi
movl 0x40(%rsp), %esi
movl 0x10(%rsp), %edx
movq 0x38(%rsp), %rcx
movq 0x48(%rsp), %r8
movl %r15d, %r9d
pushq %rax
pushq %r10
movl $0x0, %eax
pushq %rax
pushq %r11
leaq 0xb4(%rsp), %rax
pushq %rax
movl 0x128(%rsp), %r14d
pushq %r14
callq 0x2b689
addq $0x30, %rsp
movl %eax, 0x8(%rsp)
leaq 0x70(%rsp), %rax
xorl %r11d, %r11d
movq %r11, (%rax)
movq %rbp, 0x58(%rsp)
leal -0x1(%rbp), %r10d
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
movl 0x40(%rsp), %esi
movl 0x10(%rsp), %edx
movq 0x38(%rsp), %rcx
movq 0x60(%rsp), %r8
movl %r15d, %r9d
pushq %r10
pushq %rax
pushq %r11
leaq 0xa8(%rsp), %rax
pushq %rax
leaq 0xb4(%rsp), %rax
pushq %rax
pushq %r14
callq 0x2b689
addq $0x30, %rsp
movl %eax, %r15d
movq 0x18(%rsp), %rdi
callq 0x64f0
movq %rbp, %rdi
callq 0x64f0
leaq 0x78(%rsp), %rax
movq (%rax), %r14
cmpl $0x1, 0x8(%rsp)
je 0x2d017
cmpl $0x1, %r15d
je 0x2d017
movq 0x18(%r14), %rax
movq %r14, 0xa0(%rsp)
movq 0x20(%r14), %rcx
movslq (%rax), %r14
movl (%rcx), %r15d
movl %r15d, %eax
subl %r14d, %eax
shll $0x6, %eax
addl $0x40, %eax
movq %rax, 0x30(%rsp)
cltq
leaq (,%rax,4), %rdi
testl %eax, %eax
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x6030
movq %r14, 0x8(%rsp)
movq %r15, 0x28(%rsp)
cmpl %r14d, %r15d
movq %rax, 0x20(%rsp)
jl 0x2ce03
movq 0xa0(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq 0x8(%rcx), %rdx
movq 0x10(%rcx), %rsi
movq 0x28(%rsp), %rcx
leal 0x1(%rcx), %edi
movq %rax, %r8
movq 0x8(%rsp), %r9
movq 0x18(%rsp), %rax
movq (%rax,%r9,8), %r10
movq (%rdx,%r9,8), %rbp
movl (%rsi,%r9,4), %r11d
movq %r9, %r14
subq 0x8(%rsp), %r14
shlq $0x8, %r14
movl $0x3f, %eax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movl %r11d, (%r8,%rax,4)
movq %rcx, %r15
andq %r10, %r15
cmpq $0x1, %r15
adcl $-0x1, %r11d
movq %rcx, %r15
andq %rbp, %r15
cmpq $0x1, %r15
sbbl $-0x1, %r11d
shrq %rcx
decq %rax
jne 0x2cdc3
movq 0x20(%rsp), %rax
movl %r11d, (%rax,%r14)
incq %r9
addq $0x100, %r8             # imm = 0x100
cmpl %r9d, %edi
jne 0x2cd97
movl 0x10(%rsp), %eax
decl %eax
xorl %ecx, %ecx
cmpl %eax, 0x28(%rsp)
cmovel 0x40(%rsp), %ecx
movl %ecx, 0x84(%rsp)
movq 0x70(%rsp), %rcx
movq 0x18(%rcx), %rax
movq %rcx, 0x98(%rsp)
movq 0x20(%rcx), %rcx
movslq (%rax), %r14
movslq (%rcx), %r15
movl %r15d, %eax
subl %r14d, %eax
shll $0x6, %eax
addl $0x40, %eax
movq %rax, 0x50(%rsp)
cltq
leaq (,%rax,4), %rdi
testl %eax, %eax
movq $-0x1, %rax
cmovsq %rax, %rdi
callq 0x6030
movq %rax, 0x18(%rsp)
movq %r15, %rdx
cmpl %r14d, %r15d
jl 0x2cf1e
movq 0x98(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x28(%rsp)
movq 0x10(%rax), %rsi
movq %rdx, %r8
leal 0x1(%rdx), %edi
shlq $0x8, %r8
movq %r14, %rax
shlq $0x8, %rax
subq %rax, %r8
addq 0x18(%rsp), %r8
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %r9
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %r11
movl (%rsi,%r14,4), %r10d
movq %rdx, %rbp
subq %r14, %rbp
shlq $0x8, %rbp
xorl %eax, %eax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
movl %r10d, (%r8,%rax,4)
movq %rcx, %r15
andq %r9, %r15
cmpq $0x1, %r15
adcl $-0x1, %r10d
movq %rcx, %r15
andq %r11, %r15
cmpq $0x1, %r15
sbbl $-0x1, %r10d
shrq %rcx
incq %rax
cmpq $0x3f, %rax
jne 0x2ced6
movq 0x18(%rsp), %rax
movl %r10d, 0xfc(%rax,%rbp)
incq %r14
addq $-0x100, %r8
cmpl %r14d, %edi
jne 0x2ceaa
shll $0x6, %edx
movq 0x38(%rsp), %rbp
subl %edx, %ebp
leal -0x40(%rbp), %r14d
sarl $0x1f, %r14d
andl 0x40(%rsp), %r14d
movq 0xa0(%rsp), %r15
testq %r15, %r15
je 0x2cf57
movq %r15, %rdi
callq 0x2d736
movl $0x28, %esi
movq %r15, %rdi
callq 0x63c0
movq 0x8(%rsp), %rax
movl %eax, %r15d
shll $0x6, %r15d
movq 0x30(%rsp), %r8
subl 0x84(%rsp), %r8d
leal (%r14,%rbp), %r10d
addl $-0x40, %r10d
movq 0x50(%rsp), %r11
subl %r14d, %r11d
movq 0x98(%rsp), %rbp
testq %rbp, %rbp
movq %r8, 0x30(%rsp)
movq %r10, 0x28(%rsp)
je 0x2cfc0
movq %rbp, %rdi
movq %r11, 0x50(%rsp)
callq 0x2d736
movl $0x28, %esi
movq %rbp, %rdi
callq 0x63c0
movq 0x28(%rsp), %r10
movq 0x30(%rsp), %r8
movq 0x50(%rsp), %r11
leal -0x1(%r10), %edx
movq %r15, %rbp
cmpl %edx, %ebp
movl %edx, %esi
cmovgl %ebp, %esi
movslq %r14d, %r14
leal (%r8,%r15), %edi
decl %edi
leal (%r10,%r11), %ecx
addl $-0x2, %ecx
cmpl %ecx, %edi
cmovll %edi, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x10(%rsp)
cmpl %ecx, %esi
jle 0x2d0b4
movq %r14, %r15
xorl %esi, %esi
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x100(%rsp), %r9d
movq 0x20(%rsp), %rdi
jmp 0x2d20a
testq %r14, %r14
je 0x2d031
movq %r14, %rdi
callq 0x2d736
movl $0x28, %esi
movq %r14, %rdi
callq 0x63c0
movq 0x70(%rsp), %rbx
movl $0x1, %ebp
testq %rbx, %rbx
je 0x2d1e1
movq %rbx, %rdi
callq 0x2d736
movl $0x28, %esi
movq %rbx, %rdi
callq 0x63c0
jmp 0x2d1e1
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq 0x110(%rsp), %rdi
movslq (%rdi), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rdi)
movb $0x2, (%rax,%rdx)
testl %r12d, %r12d
js 0x2d16c
leal (%rcx,%r9), %eax
incl %eax
movq 0x108(%rsp), %rcx
movq (%rcx), %rcx
movq 0x110(%rsp), %rdi
movslq (%rdi), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rdi)
movb $0x1, (%rcx,%rdx)
decl %eax
jne 0x2d08c
jmp 0x2d16c
cmpl %edx, %ebp
cmovgl %ebp, %edx
movslq %edx, %rdx
movslq %r10d, %r9
movslq %ebp, %r8
shlq $0x2, %r8
movq 0x20(%rsp), %rdi
movq %rdi, %rsi
subq %r8, %rsi
subl %edx, %ecx
incl %ecx
movq %r14, %r15
leaq (,%r14,4), %r8
shlq $0x2, %r9
subq %r9, %r8
movq 0x18(%rsp), %r9
leaq (%r8,%r9), %r10
addq $0x4, %r10
movl 0x100(%rsp), %r9d
movl (%rsi,%rdx,4), %r14d
movl (%r10,%rdx,4), %r8d
movq %r8, %rax
addl %r14d, %r8d
cmpl %r9d, %r8d
je 0x2d1f5
incq %rdx
decl %ecx
jne 0x2d0fc
xorl %esi, %esi
jmp 0x2d1fd
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq 0x110(%rsp), %rsi
movslq (%rsi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rsi)
movb $0x1, (%rax,%rcx)
testl %r14d, %r14d
js 0x2d16c
incl %r14d
movq 0x108(%rsp), %rax
movq (%rax), %rax
movq 0x110(%rsp), %rsi
movslq (%rsi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rsi)
movb $0x2, (%rax,%rcx)
decl %r14d
jne 0x2d148
movq 0x108(%rsp), %rbx
movq (%rbx), %rdi
movq 0x110(%rsp), %r14
movslq (%r14), %rsi
callq 0x6610
movq %rax, (%rbx)
movslq (%r14), %rcx
testq %rcx, %rcx
je 0x2d1bb
addq %rax, %rcx
decq %rcx
cmpq %rax, %rcx
jbe 0x2d1bb
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x2d1a0
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d736
movl $0x28, %esi
movq %rbx, %rdi
callq 0x63c0
movq 0x40(%rsp), %rdi
callq 0x64f0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %sil
movq %rdx, 0x10(%rsp)
movq %rax, %rdx
movq 0x30(%rsp), %r8
movq 0x28(%rsp), %r10
addl %r10d, %r11d
cmpl $0x0, 0x8(%rsp)
movq 0x38(%rsp), %rcx
jne 0x2d25a
testb %sil, %sil
jne 0x2d25a
testl %r10d, %r10d
jne 0x2d25a
movq 0x18(%rsp), %rdx
movl (%rdx,%r15,4), %edx
movq 0xa8(%rsp), %r14
leal (%rdx,%r14), %eax
cmpl %r9d, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r10
cmovel %eax, %r10d
movq %r10, 0x10(%rsp)
movzbl %sil, %eax
movl $0x1, %esi
cmovnel %eax, %esi
cmpl %ecx, %r11d
jne 0x2d2a3
addl %r8d, %ebp
cmpl %ecx, %ebp
jne 0x2d2a3
testb %sil, %sil
jne 0x2d2a3
movslq %r8d, %rax
movl -0x4(%rdi,%rax,4), %r14d
movq 0x58(%rsp), %rdx
leal (%r14,%rdx), %eax
decl %ecx
cmpl %r9d, %eax
movq 0x10(%rsp), %rax
cmovel %ecx, %eax
movq %rax, 0x10(%rsp)
movzbl %sil, %eax
movl $0x1, %r15d
cmovnel %eax, %r15d
movq %rdx, 0x8(%rsp)
jmp 0x2d2ab
movq %rdx, 0x8(%rsp)
movl %esi, %r15d
callq 0x64f0
movq 0x18(%rsp), %rdi
callq 0x64f0
movl $0x1, %ebp
testb %r15b, %r15b
je 0x2d1e1
movq 0x10(%rsp), %rax
leal 0x1(%rax), %edx
movq 0x38(%rsp), %rcx
subl %edx, %ecx
xorl %ebp, %ebp
leaq 0x68(%rsp), %rax
movq %rbp, (%rax)
movslq %ecx, %rcx
movq %rcx, 0x18(%rsp)
leaq (%rcx,%r13), %rsi
movslq 0x58(%rsp), %r8
addq 0x60(%rsp), %r8
subq $0x8, %rsp
leaq 0x94(%rsp), %r10
movq %r12, %rdi
movq 0x50(%rsp), %rcx
movq 0xb0(%rsp), %r15
movl %r15d, %r9d
pushq %r10
pushq %rax
pushq %r14
movl 0x118(%rsp), %r14d
pushq %r14
pushq %rbx
callq 0x2c179
addq $0x30, %rsp
movl %eax, 0x20(%rsp)
leaq 0xb0(%rsp), %rax
movq %rbp, (%rax)
movslq 0x10(%rsp), %rcx
leaq (%rcx,%r12), %rdi
incq %rdi
movslq %r15d, %rcx
addq 0x48(%rsp), %rcx
subq $0x8, %rsp
leaq 0x90(%rsp), %r10
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq 0x68(%rsp), %r8
movq 0x60(%rsp), %r9
pushq %r10
pushq %rax
pushq 0x20(%rsp)
pushq %r14
pushq %rbx
callq 0x2c179
addq $0x30, %rsp
orl 0x20(%rsp), %eax
je 0x2d3af
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2d398
callq 0x64b0
movq 0xb0(%rsp), %rbx
movl $0x1, %ebp
testq %rbx, %rbx
jne 0x2d414
jmp 0x2d1e1
movslq 0x8c(%rsp), %rbx
movslq 0x88(%rsp), %r15
leaq (%r15,%rbx), %rdi
movq 0x110(%rsp), %rax
movl %edi, (%rax)
callq 0x6530
movq %rax, %r12
movq 0x108(%rsp), %rax
movq %r12, (%rax)
movq 0x68(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6310
addq %rbx, %r12
movq 0xb0(%rsp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x6310
movq %r13, %rdi
callq 0x64b0
movq %rbx, %rdi
callq 0x64b0
jmp 0x2d1e1