// File: /workspace/github_c_makefile_star2_O3/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::CreateGlobalDecompressionTable(int, int, int, int, int, bool&, int&, int&)
void GECompression::CreateGlobalDecompressionTable(int bit1TableChoice, int size2, int bit12STableSChoice, int bit12BTableChoice, int numBits, bool& returnValue, int& numReturnBits, int& returnStartIndex)
{
	//if (bit1TableChoice == 0) bt1Table1 else bt1Table2
	//if (bit12STableSChoice == 0) bt12Table1S else bt12Table2S
	//if (bit12BTableChoice == 0) bt12Table1B else bt12Table2B
	CString temp; // temp var del later

	tableEntry localTableEntry;
	localTableEntry.bits = 0;
	localTableEntry.flags = 0;
	localTableEntry.nextIndex = 0;
	localTableEntry.wordValue = 0;

	int table1Size = 0;

	int returnIndex = -1;

	unsigned long seventeenints1[17];
	for (int x = 0; x < 17; x++)
		seventeenints1[x] = 0;

	if (bit1TableChoice == TABLE1)
	{
		table1Size = 288;
		for (int x = 0; x < 288; x++)
		{
			seventeenints1[bt1Table1[x]]++;
		}
	}
	else if (bit1TableChoice == TABLE2)
	{
		table1Size = 30;
		for (int x = 0; x < 30; x++)
		{
			seventeenints1[bt1Table2[x]]++;
		}
	}
	else if (bit1TableChoice == VARIABLETABLE)
	{
		table1Size = 0x13;		
		for (int x = 0; x < 0x13; x++)
		{
			seventeenints1[variableTable[x]]++;			
		}
	}
	else if (bit1TableChoice == WORDTABLEBEGIN)
	{
		table1Size = tableSize;		
		for (int x = 0; x < table1Size; x++)
		{
			seventeenints1[wordTable[x]]++;			
		}
	}
	else if (bit1TableChoice == WORDTABLEEND)
	{
		table1Size = ((tableSize + fiveBits) - tableSize);
		for (int x = 0; x < table1Size; x++)
		{
			seventeenints1[wordTable[tableSize + x]]++;			
		}
	}

	int firstBit = 1;
	while (seventeenints1[firstBit] == 0)
		firstBit++;

	int lastBit = 16;	
	while (seventeenints1[lastBit] == 0)
		lastBit--;

	if (numBits < firstBit)
		numBits = firstBit;
	if (numBits > lastBit)
		numBits = lastBit;

	unsigned long v1temp = (1<<firstBit);
	if (firstBit != lastBit)
	{
		for (int bitNum = firstBit; bitNum < lastBit; bitNum++)
		{
			v1temp = ((v1temp - seventeenints1[bitNum])*2);
		}	
	}

	int oldLastBitCount = seventeenints1[lastBit];
	seventeenints1[lastBit] = v1temp;
	v1temp = v1temp - oldLastBitCount;

	unsigned long seventeenints2[17];
	for (int x = 0; x < 17; x++)
		seventeenints2[x] = 0;

	int accumulator = 0;
	for (int index = 1; index < lastBit; index++)
	{
		accumulator = accumulator + seventeenints1[index];
		seventeenints2[index+1] = accumulator;
	}


	unsigned long* moreWords;
	moreWords = new unsigned long[table1Size];
	int moreWordsIndex = 0;
	int index = 0;

	for (int x = 0; x < table1Size; x++)
	{
		moreWords[x] = 0;
	}

	for (int x = 0; x < table1Size; x++)
	{

		if (bit1TableChoice == TABLE1)
		{
			if ((bt1Table1[x]) != 0)
			{
				moreWords[seventeenints2[bt1Table1[x]]] = index;
				seventeenints2[bt1Table1[x]]++;
			}
		}
		else if (bit1TableChoice == TABLE2)
		{
			if ((bt1Table2[x]) != 0)
			{
				moreWords[seventeenints2[bt1Table2[x]]] = index;
				seventeenints2[bt1Table2[x]]++;
			}
		}
		else if (bit1TableChoice == VARIABLETABLE)
		{
			if ((variableTable[x]) != 0)
			{
				moreWords[seventeenints2[variableTable[x]]] = index;
				seventeenints2[variableTable[x]]++;	
			}
		}
		else if (bit1TableChoice == WORDTABLEBEGIN)
		{
			if ((wordTable[x]) != 0)
			{
				moreWords[seventeenints2[wordTable[x]]] = index;
				seventeenints2[wordTable[x]]++;
			}
		}
		else if (bit1TableChoice == WORDTABLEEND)
		{
			if ((wordTable[tableSize + x]) != 0)
			{
				moreWords[seventeenints2[wordTable[tableSize + x]]] = index;
				seventeenints2[wordTable[tableSize + x]]++;
			}
		}
		index++;
	}

	int stemp2_v1 = -numBits;
	int blockNum = -1;
	int bitPattern = 0;

	int unpackTableStarts[0x20000];
	int unpackTableStartsIndex = -1;

	unsigned long temp_a3 = 0;
	int thisTableStart = 0;

	for (int bitNum = firstBit; bitNum < (lastBit+1); bitNum++)
	{
		int iterationsLeft = seventeenints1[bitNum];
		unsigned long lv34 = (1<<(bitNum-1));
		int moreWordsIndex2 = table1Size;

		while (iterationsLeft)
		{
			if (iterationsLeft < 0)
				break;
			stemp2_v1 = stemp2_v1 + numBits;
			while (stemp2_v1 < bitNum)
			{
				blockNum++;

				unsigned long temp_t0 = 0;

				if (numBits < (lastBit-stemp2_v1))
					temp_t0=numBits;
				else
					temp_t0 = lastBit-stemp2_v1;

				temp_a3 = bitNum - stemp2_v1;

				if (iterationsLeft < (1<<temp_a3))
				{
					unsigned long another_var_v1= ((1 << temp_a3) - iterationsLeft);
					temp_a3++;

					index = bitNum + 1;
					while (temp_a3 < temp_t0)
					{
						if (seventeenints1[index] < (another_var_v1*2))
						{
							temp_a3++;
							another_var_v1 = another_var_v1*2 - seventeenints1[index];
						}
						index++;
					}
				}
				if (returnIndex==-1)
					returnIndex=unpackTableIndex + 1;
				
				unpackTableStartsIndex++;
				unpackTableStarts[unpackTableStartsIndex] = (unpackTableIndex+1);
				
				thisTableStart = unpackTableIndex + 1;

				if (blockNum != 0)
				{
					seventeenints2[blockNum] = bitPattern;
					localTableEntry.bits = numBits;
					localTableEntry.flags = temp_a3 + 0x10;
					localTableEntry.nextIndex= unpackTableIndex + 1;
					localTableEntry.wordValue = -1;
					unpackTable[(bitPattern>>(stemp2_v1-numBits))+unpackTableStarts[blockNum-1]].bits = localTableEntry.bits;
					unpackTable[(bitPattern>>(stemp2_v1-numBits))+unpackTableStarts[blockNum-1]].flags = localTableEntry.flags;
					unpackTable[(bitPattern>>(stemp2_v1-numBits))+unpackTableStarts[blockNum-1]].wordValue = localTableEntry.wordValue;
					unpackTable[(bitPattern>>(stemp2_v1-numBits))+unpackTableStarts[blockNum-1]].nextIndex = localTableEntry.nextIndex;
				}

				unpackTableIndex=unpackTableIndex + ((1<<temp_a3)+1);
				stemp2_v1+=numBits;
			}
			stemp2_v1 = stemp2_v1 - numBits;

			localTableEntry.bits = bitNum - stemp2_v1;
			localTableEntry.nextIndex = 0;
			if (moreWordsIndex >= moreWordsIndex2)
				localTableEntry.flags = 0x63;
			else
			{
				unsigned long tempWord = moreWords[moreWordsIndex];
				if (tempWord<size2)
				{
					if (tempWord >= 0x100)
						localTableEntry.flags = 0xf;
					else
						localTableEntry.flags = 0x10;
					localTableEntry.wordValue = tempWord;
				}
				else
				{
					if (bit12STableSChoice == TABLE1)
					{
						localTableEntry.flags = bt12Table1B[moreWords[moreWordsIndex]-size2];
						localTableEntry.wordValue = bt12Table1S[moreWords[moreWordsIndex]-size2];
					}
					else if (bit12STableSChoice == TABLE2)
					{
						localTableEntry.flags = bt12Table2B[moreWords[moreWordsIndex]-size2];
						localTableEntry.wordValue = bt12Table2S[moreWords[moreWordsIndex]-size2];
					}
					else if (bit12STableSChoice == VARIABLETABLE)
					{
						// shouldn't happen

					}
				}
				moreWordsIndex++;
			}
		
			unsigned long nu_accum_a3 = (bitPattern >> stemp2_v1);
			unsigned long stride_v0 = (1<<(bitNum - stemp2_v1));
			/*if (thisTableStart==744)
			{
				if thisTableStart+nu_accum_a3==758
				{
					if stride_v0==16:
					{
						debugIt=1
					}
				}
			}*/
			while ((1<<temp_a3) > nu_accum_a3)
			{
				if ((thisTableStart+nu_accum_a3) > 0xFFFF)
				{
					delete [] moreWords;
					return;
				}
				unpackTable[thisTableStart+nu_accum_a3].bits = localTableEntry.bits;
				unpackTable[thisTableStart+nu_accum_a3].flags = localTableEntry.flags;
				unpackTable[thisTableStart+nu_accum_a3].wordValue = localTableEntry.wordValue;
				unpackTable[thisTableStart+nu_accum_a3].nextIndex = localTableEntry.nextIndex;
				nu_accum_a3 = nu_accum_a3 + stride_v0;
			}

			unsigned long tempLv=lv34;
			
			while (bitPattern & tempLv)
			{
				bitPattern = bitPattern ^ tempLv;
				tempLv = tempLv >> 1;
			}
			bitPattern = bitPattern ^ tempLv;
			while((bitPattern & ((1 << stemp2_v1)-1)) != seventeenints2[blockNum])
			{
				blockNum = blockNum- 1;
				stemp2_v1=0;
			}

			iterationsLeft = iterationsLeft - 1;
		}
	}
	delete [] moreWords;
	if (v1temp > 0)
	{
		returnValue = (0<(lastBit^1));
		numReturnBits = numBits;
		returnStartIndex = returnIndex;
	}
	else
	{
		returnValue = 0;
		numReturnBits = numBits;
		returnStartIndex = returnIndex;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x801d8, %rsp          # imm = 0x801D8
movq %r9, -0x48(%rbp)
movl %ecx, -0x7c(%rbp)
movl %edx, -0x2c(%rbp)
movl %esi, %r14d
movq %rdi, %r12
leaq -0xd0(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x200(%rbp), %rdi
movq $0x0, -0x38(%rbp)
movl $0x88, %edx
xorl %esi, %esi
callq 0x20f0
leaq 0x5fea(%rip), %r15      # 0xa180
testl %r14d, %r14d
je 0x41e0
leal -0x1(%r14), %eax
cmpl $0x3, %eax
ja 0x427e
leaq 0x306d(%rip), %rcx      # 0x721c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
leaq 0x60df(%rip), %rcx      # 0xa2a0
movzbl (%rax,%rcx), %edx
incq -0x200(%rbp,%rdx,8)
incq %rax
cmpq $0x1e, %rax
jne 0x41c1
movl $0x1e, %eax
jmp 0x427a
xorl %eax, %eax
movzbl (%rax,%r15), %ecx
incq -0x200(%rbp,%rcx,8)
incq %rax
cmpq $0x120, %rax            # imm = 0x120
jne 0x41e2
movl $0x120, %eax            # imm = 0x120
jmp 0x427a
movzwl 0x70(%r12), %eax
testl %eax, %eax
je 0x427e
movq 0x78(%r12), %rcx
movl %eax, %edx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
incq -0x200(%rbp,%rdi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x4214
jmp 0x425a
movzbl 0x72(%r12), %eax
testl %eax, %eax
je 0x427e
movzwl 0x70(%r12), %ecx
movl %eax, %edx
shll $0x3, %ecx
addq 0x78(%r12), %rcx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
incq -0x200(%rbp,%rdi,8)
incq %rsi
cmpq %rsi, %rdx
jne 0x4246
jmp 0x427a
xorl %eax, %eax
movzbl 0x5c(%r12,%rax), %ecx
incq -0x200(%rbp,%rcx,8)
incq %rax
cmpq $0x13, %rax
jne 0x425e
movl $0x13, %eax
movq %rax, -0x38(%rbp)
movq %r12, -0x40(%rbp)
leaq -0x1f8(%rbp), %rsi
xorl %r12d, %r12d
incq %r12
cmpq $0x0, (%rsi)
leaq 0x8(%rsi), %rsi
je 0x428c
leaq -0x8(%rsi), %rax
movl $0x10, %ecx
movq %rcx, %rbx
movq -0x200(%rbp,%rcx,8), %rdi
decq %rcx
testq %rdi, %rdi
je 0x42a2
movq -0x48(%rbp), %rcx
cmpl %ecx, %r12d
cmovgl %r12d, %ecx
cmpl %ebx, %ecx
cmovgel %ebx, %ecx
movq %rcx, -0x60(%rbp)
movl $0x1, %edx
movl %r12d, %ecx
shll %cl, %edx
movslq %edx, %rdx
cmpq %rbx, %r12
movq %rsi, -0x88(%rbp)
movq %rdi, -0xa8(%rbp)
jge 0x42fc
movl %r12d, %ecx
subq (%rax), %rdx
addq %rdx, %rdx
addq $0x8, %rax
incl %ecx
cmpl %ebx, %ecx
jl 0x42ec
movq %rdx, -0xa0(%rbp)
movq %rdx, -0x200(%rbp,%rbx,8)
leaq -0x170(%rbp), %rdi
movl $0x88, %edx
xorl %esi, %esi
callq 0x20f0
cmpq $0x2, %rbx
jl 0x434b
movl %ebx, %eax
decq %rax
xorl %ecx, %ecx
xorl %edx, %edx
movslq %edx, %rdx
addq -0x1f8(%rbp,%rcx,8), %rdx
movslq %edx, %rsi
movq %rsi, -0x160(%rbp,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x432d
movq %rbx, -0x70(%rbp)
movq -0x38(%rbp), %rbx
leal (,%rbx,8), %edi
movq %rdi, %r13
callq 0x2030
testl %ebx, %ebx
movq %rax, -0x58(%rbp)
je 0x4449
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20f0
movq %r14, %r10
movq -0x58(%rbp), %r11
movq -0x40(%rbp), %rcx
movq 0x78(%rcx), %rax
movzwl 0x70(%rcx), %edx
movl -0x38(%rbp), %ecx
leaq (%rax,%rdx,8), %rdx
leal -0x1(%r14), %esi
leaq 0x2e8a(%rip), %rdi      # 0x722c
leaq 0x5ef7(%rip), %r8       # 0xa2a0
testl %r10d, %r10d
je 0x43c8
cmpl $0x3, %esi
ja 0x443d
movslq (%rdi,%rsi,4), %r9
addq %rdi, %r9
jmpq *%r9
movzbl (%rbx,%r8), %r9d
jmp 0x441d
movzbl (%rbx,%r15), %r9d
jmp 0x441d
movq (%rax,%rbx,8), %r9
testq %r9, %r9
je 0x443d
movq -0x170(%rbp,%r9,8), %r9
movq %rbx, (%r11,%r9,8)
movq (%rax,%rbx,8), %r9
jmp 0x4403
movq (%rdx,%rbx,8), %r9
testq %r9, %r9
je 0x443d
movq -0x170(%rbp,%r9,8), %r9
movq %rbx, (%r11,%r9,8)
movq (%rdx,%rbx,8), %r9
leaq -0x170(,%r9,8), %r9
addq %rbp, %r9
movq (%r9), %r10
jmp 0x4434
movq -0x40(%rbp), %r9
movzbl 0x5c(%r9,%rbx), %r9d
testq %r9, %r9
je 0x443d
leaq -0x170(,%r9,8), %r9
addq %rbp, %r9
movq (%r9), %r10
movq %rbx, (%r11,%r10,8)
incq %r10
movq %r10, (%r9)
movq %r14, %r10
incq %rbx
cmpq %rbx, %rcx
jne 0x43a9
movq -0x40(%rbp), %rdx
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movq -0x70(%rbp), %r13
cmpq %r13, %r12
jle 0x449e
movslq -0xa8(%rbp), %rbx
movq -0x58(%rbp), %rdi
callq 0x21e0
cmpq %rbx, -0xa0(%rbp)
setne %al
xorl $0x1, %r13d
setg %cl
andb %al, %cl
movq 0x10(%rbp), %rax
movb %cl, (%rax)
movq 0x18(%rbp), %rax
movq -0x60(%rbp), %rcx
movl %ecx, (%rax)
movq 0x20(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x483f
movq -0x60(%rbp), %rax
movl %eax, %r15d
negl %r15d
cltq
movq %rax, -0xc0(%rbp)
movslq -0x2c(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x48(%rbp), %r14
cmpl %r12d, %r14d
cmovlel %r12d, %r14d
cmpq %r14, %r13
cmovlq %r13, %r14
movslq %r13d, %rax
movq %rax, -0x90(%rbp)
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
xorl %esi, %esi
movl $0x0, -0x2c(%rbp)
xorl %edi, %edi
xorl %eax, %eax
xorl %r11d, %r11d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0x0, -0x4c(%rbp)
movl $0xffffffff, -0x30(%rbp) # imm = 0xFFFFFFFF
movq %r14, -0x48(%rbp)
movl -0x200(%rbp,%r12,8), %r8d
leal -0x1(%r12), %ecx
movl $0x1, %r9d
shll %cl, %r9d
movq %r8, -0x78(%rbp)
testl %r8d, %r8d
jle 0x4804
movl %r9d, -0x80(%rbp)
movslq %r9d, %rcx
movq %rcx, -0xb0(%rbp)
movq %rdx, %r9
movq %rsi, %r14
movq -0x60(%rbp), %rcx
addl %r15d, %ecx
movslq %ecx, %rcx
cmpq %rcx, %r12
jle 0x4662
movslq %r11d, %rax
movq %rax, -0x68(%rbp)
movq 0x28(%r9), %r8
movslq %r15d, %rdx
addq -0x48(%rbp), %rdx
movslq %r10d, %r10
movslq %ebx, %r9
movq -0x70(%rbp), %rax
movl %eax, %edi
subl %edx, %edi
movq -0x60(%rbp), %rax
cmpl %edi, %eax
cmovll %eax, %edi
movq %r12, %rax
subq %rdx, %rax
movl $0x1, %ebx
movl %eax, %ecx
shll %cl, %ebx
subl -0x78(%rbp), %ebx
jle 0x45be
movslq %edi, %rcx
incq %rax
cmpq %rcx, %rax
jae 0x45be
movslq %ebx, %rdi
movq -0x88(%rbp), %rbx
leaq (%rdi,%rdi), %r13
xorl %esi, %esi
subq (%rbx), %r13
seta %sil
cmovaq %r13, %rdi
addq %rsi, %rax
addq $0x8, %rbx
cmpq %rcx, %rax
jb 0x45a1
leaq 0x1(%r9), %rbx
movq -0x40(%rbp), %r13
movl 0x30(%r13), %edi
incl %edi
movl -0x30(%rbp), %ecx
cmpl $-0x1, %ecx
cmovel %edi, %ecx
movl %ecx, -0x30(%rbp)
movl %edi, -0x801fc(%rbp,%r10,4)
testq %rbx, %rbx
je 0x4637
movq -0x68(%rbp), %rcx
movq %rcx, -0x170(%rbp,%rbx,8)
leal 0x10(%rax), %r14d
movl %ecx, %esi
movl %r15d, %ecx
sarl %cl, %esi
movslq -0x80200(%rbp,%r9,4), %rcx
movslq %esi, %rsi
addq %rcx, %rsi
leaq (%rsi,%rsi,2), %rcx
movq -0xc0(%rbp), %rsi
movq %rsi, (%r8,%rcx,8)
movl %r14d, -0x2c(%rbp)
movb %r14b, 0x8(%r8,%rcx,8)
movq $-0x1, 0x10(%r8,%rcx,8)
movl %edi, 0xc(%r8,%rcx,8)
movq $-0x1, %r14
movl $0x1, %esi
movl %eax, %ecx
shll %cl, %esi
incq %r10
addl %edi, %esi
movl %esi, 0x30(%r13)
movl %edx, %r15d
movq -0x48(%rbp), %rcx
addq %rdx, %rcx
movq %rbx, %r9
movq %rcx, %rdx
cmpq %r12, %rcx
jl 0x4567
movl %r15d, %esi
movl -0x4c(%rbp), %r8d
cmpl -0x38(%rbp), %r8d
jge 0x469d
movslq %r8d, %rcx
movq -0x58(%rbp), %rdx
movq (%rdx,%rcx,8), %rdx
movq %rdx, %rcx
subq -0x98(%rbp), %rcx
jae 0x46a4
cmpq $0x100, %rdx            # imm = 0x100
movl $0x0, %ecx
adcb $0xf, %cl
movl %ecx, -0x2c(%rbp)
movq %rdx, %r14
jmp 0x46df
movb $0x63, %cl
movl %ecx, -0x2c(%rbp)
jmp 0x46e6
movl -0x7c(%rbp), %edx
cmpl $0x1, %edx
je 0x46c6
testl %edx, %edx
jne 0x46df
leaq 0x5c49(%rip), %rdx      # 0xa300
movb (%rdx,%rcx,2), %dl
movl %edx, -0x2c(%rbp)
leaq 0x5bfc(%rip), %rdx      # 0xa2c0
jmp 0x46da
leaq 0x5cb3(%rip), %rdx      # 0xa380
movb (%rdx,%rcx,2), %dl
movl %edx, -0x2c(%rbp)
leaq 0x5c66(%rip), %rdx      # 0xa340
movzwl (%rdx,%rcx,2), %r14d
incl %r8d
movl %r8d, -0x4c(%rbp)
movl %r12d, %ecx
subl %esi, %ecx
movslq %ecx, %r9
movl %r11d, %edx
movl %esi, %ecx
sarl %cl, %edx
movl $0x1, %r8d
movq %r9, -0x68(%rbp)
movl %r9d, %ecx
shll %cl, %r8d
movl $0x1, %r9d
movl %eax, %ecx
shll %cl, %r9d
cmpl %r9d, %edx
jae 0x478e
movslq %r8d, %rcx
movslq %r9d, %r8
movq %r8, -0xb8(%rbp)
movslq %edx, %r9
movslq %edi, %r15
movq -0x40(%rbp), %rdx
movq 0x28(%rdx), %rdx
leaq (%r15,%r9), %r13
leaq (%r13,%r13,2), %r13
leaq (%rdx,%r13,8), %rdx
addq $0x10, %rdx
leaq (,%rcx,8), %r13
leaq (%r13,%r13,2), %r13
movq %r14, %r8
leaq (%r15,%r9), %r14
cmpq $0x10000, %r14          # imm = 0x10000
jae 0x4836
movq -0x68(%rbp), %r14
movq %r14, -0x10(%rdx)
movl -0x2c(%rbp), %r14d
movb %r14b, -0x8(%rdx)
movq %r8, %r14
movq %r8, (%rdx)
movl $0x0, -0x4(%rdx)
addq %rcx, %r9
addq %r13, %rdx
cmpq -0xb8(%rbp), %r9
jb 0x474e
movq -0xb0(%rbp), %rcx
movl -0x80(%rbp), %r8d
movl %r8d, %edx
testl %r11d, %r8d
je 0x47b1
xorl %ecx, %r11d
shrq %rcx
movslq %r11d, %rdx
testq %rdx, %rcx
jne 0x47a1
movl %ecx, %edx
xorl %edx, %r11d
movslq %ebx, %rcx
leal 0x1(%rcx), %ebx
leaq -0x170(,%rcx,8), %rdx
addq %rbp, %rdx
movq -0x40(%rbp), %r9
movl %esi, %r15d
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %r8d
notl %r8d
andl %r11d, %r8d
decl %ebx
leaq -0x8(%rdx), %rcx
xorl %esi, %esi
cmpq %r8, (%rdx)
movq %rcx, %rdx
jne 0x47c9
movq -0x78(%rbp), %rdx
leal -0x1(%rdx), %ecx
cmpl $0x1, %edx
movq %rcx, -0x78(%rbp)
jg 0x453c
jmp 0x480a
movq %rdx, %r9
movq %rsi, %r14
movq %r14, %rsi
movq %r9, %rdx
leaq 0x1(%r12), %rcx
addq $0x8, -0x88(%rbp)
cmpq -0x90(%rbp), %r12
movq %rcx, %r12
movq -0x70(%rbp), %r13
jl 0x4505
jmp 0x445d
movq -0x58(%rbp), %rdi
callq 0x21e0
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x4861
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x2190
addq $0x801d8, %rsp          # imm = 0x801D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop