// File: ksherlock[P]wdc-utils/omf.cpp
// Function: add_relocs(std::vector<unsigned char, std::allocator<unsigned char>>&, unsigned long, omf::segment&, bool, bool)
uint32_t add_relocs(std::vector<uint8_t> &data, size_t data_offset, omf::segment &seg, bool compress, bool super) {

	std::array< optional<super_helper>, 38 > ss;


	uint32_t reloc_size = 0;

	for (auto &r : seg.relocs) {

		if (compress && r.can_compress()) {

			if (super) {
				if (r.shift == 0 && r.size == 2) {
					constexpr int n = SUPER_RELOC2;

					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.value;
					for (int i = 0; i < 2; ++i, value >>= 8)
						data[data_offset + r.offset + i] = value; 
					continue;
				}

				// sreloc 3 is for 3 bytes.  however 4 bytes is also ok since 
				// it's 24-bit address space.
				if (r.shift == 0 && (r.size == 2 || r.size == 3))
				{
					constexpr int n = SUPER_RELOC3;

					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.value;
					for (int i = 0; i < 3; ++i, value >>= 8)
						data[data_offset + r.offset + i] = value; 
					continue;	
				}

				// if size == 2 && shift == -16, -> SUPER INTERSEG 
				if (seg.segnum <= 12 && r.shift == 0xf0 && r.size == 2) {

					int n = SUPER_INTERSEG24 + seg.segnum;
					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.value;
					for (int i = 0; i < 2; ++i, value >>= 8)
						data[data_offset + r.offset + i] = value; 
					continue;
				}
			}

			push(data, (uint8_t)omf::cRELOC);
			push(data, (uint8_t)r.size);
			push(data, (uint8_t)r.shift);
			push(data, (uint16_t)r.offset);
			push(data, (uint16_t)r.value);
			reloc_size += 7;
		} else {
			push(data, (uint8_t)omf::RELOC);
			push(data, (uint8_t)r.size);
			push(data, (uint8_t)r.shift);
			push(data, (uint32_t)r.offset);
			push(data, (uint32_t)r.value);
			reloc_size += 11;
		}
	}

	for (const auto &r : seg.intersegs) {
		if (compress && r.can_compress()) {

			if (super) {

				if (r.shift == 0 && r.size == 3) {
					constexpr int n = SUPER_INTERSEG1;
					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.segment_offset;

					data[data_offset + r.offset + 0] = value; value >>= 8;
					data[data_offset + r.offset + 1] = value; value >>= 8;
					data[data_offset + r.offset + 2] = r.segment;
					continue;
				}


				if (r.shift == 0 && r.size == 2 && r.segment <= 12) {

					int n = SUPER_INTERSEG12 + r.segment;
					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.segment_offset;
					for (int i = 0; i < 2; ++i, value >>= 8)
						data[data_offset + r.offset + i] = value; 
					continue;
				}

				if (r.shift == 0xf0 && r.size == 2 && r.segment <= 12) {

					int n = SUPER_INTERSEG24 + r.segment;
					auto &sr = ss[n];
					if (!sr) sr.emplace();
					sr->append(r.offset);

					uint32_t value = r.segment_offset;
					for (int i = 0; i < 2; ++i, value >>= 8)
						data[data_offset + r.offset + i] = value; 
					continue;
				}
			}


			push(data, (uint8_t)omf::cINTERSEG);
			push(data, (uint8_t)r.size);
			push(data, (uint8_t)r.shift);
			push(data, (uint16_t)r.offset);
			push(data, (uint8_t)r.segment);
			push(data, (uint16_t)r.segment_offset);
			reloc_size += 8;
		} else {
			push(data, (uint8_t)omf::INTERSEG);
			push(data, (uint8_t)r.size);
			push(data, (uint8_t)r.shift);
			push(data, (uint32_t)r.offset);
			push(data, (uint16_t)r.file);
			push(data, (uint16_t)r.segment);
			push(data, (uint32_t)r.segment_offset);
			reloc_size += 15;
		}
	}


	for (int i = 0; i < ss.size(); ++i) {
		auto &s = ss[i];
		if (!s) continue;

		auto tmp = s->data();
		if (tmp.empty()) continue;

		reloc_size += tmp.size() + 6;
		data.push_back(omf::SUPER);
		push(data, ((uint32_t)tmp.size() + 1));
		data.push_back(i);

		data.insert(data.end(), tmp.begin(), tmp.end());
	}

	return reloc_size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x7f0, %rsp            # imm = 0x7F0
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %cl
movb %cl, -0x19(%rbp)
andb $0x1, %al
movb %al, -0x1a(%rbp)
leaq -0x610(%rbp), %rdi
callq 0x258f0
movl $0x0, -0x614(%rbp)
movq -0x18(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x620(%rbp)
movq -0x620(%rbp), %rdi
callq 0x1b110
movq %rax, -0x628(%rbp)
movq -0x620(%rbp), %rdi
callq 0x1af40
movq %rax, -0x630(%rbp)
leaq -0x628(%rbp), %rdi
leaq -0x630(%rbp), %rsi
callq 0x25940
testb $0x1, %al
jne 0x2388e
jmp 0x23d8a
leaq -0x628(%rbp), %rdi
callq 0x1b5d0
movq %rax, -0x638(%rbp)
testb $0x1, -0x19(%rbp)
je 0x23d03
movq -0x638(%rbp), %rdi
callq 0x25980
movb %al, -0x741(%rbp)
jmp 0x238bf
movb -0x741(%rbp), %al
testb $0x1, %al
jne 0x238ce
jmp 0x23d03
testb $0x1, -0x1a(%rbp)
je 0x23c8b
movq -0x638(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x23a14
movq -0x638(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x23a14
movl $0x0, -0x648(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x610(%rbp), %rdi
callq 0x259c0
movq %rax, -0x650(%rbp)
movq -0x650(%rbp), %rdi
callq 0x259f0
movb %al, -0x742(%rbp)
jmp 0x23934
movb -0x742(%rbp), %al
testb $0x1, %al
jne 0x23967
jmp 0x23940
movq -0x650(%rbp), %rdi
callq 0x25a10
jmp 0x2394e
jmp 0x23967
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x640(%rbp)
movl %eax, -0x644(%rbp)
jmp 0x245df
movq -0x650(%rbp), %rdi
callq 0x25a60
movq %rax, -0x750(%rbp)
jmp 0x2397c
movq -0x750(%rbp), %rdi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x23994
movq -0x638(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x654(%rbp)
movl $0x0, -0x658(%rbp)
cmpl $0x2, -0x658(%rbp)
jge 0x23a0f
movl -0x654(%rbp), %eax
movb %al, -0x751(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
movslq -0x658(%rbp), %rax
addq %rax, %rsi
callq 0xc230
movb -0x751(%rbp), %cl
movb %cl, (%rax)
movl -0x658(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x658(%rbp)
movl -0x654(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x654(%rbp)
jmp 0x239ae
jmp 0x23d79
movq -0x638(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x23b49
movq -0x638(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
je 0x23a4a
movq -0x638(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x23b49
movl $0x1, -0x65c(%rbp)
leaq -0x610(%rbp), %rdi
movl $0x1, %esi
callq 0x259c0
movq %rax, -0x668(%rbp)
movq -0x668(%rbp), %rdi
callq 0x259f0
movb %al, -0x752(%rbp)
jmp 0x23a80
movb -0x752(%rbp), %al
testb $0x1, %al
jne 0x23a9c
jmp 0x23a8c
movq -0x668(%rbp), %rdi
callq 0x25a10
jmp 0x23a9a
jmp 0x23a9c
movq -0x668(%rbp), %rdi
callq 0x25a60
movq %rax, -0x760(%rbp)
jmp 0x23ab1
movq -0x760(%rbp), %rdi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x23ac9
movq -0x638(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x66c(%rbp)
movl $0x0, -0x670(%rbp)
cmpl $0x3, -0x670(%rbp)
jge 0x23b44
movl -0x66c(%rbp), %eax
movb %al, -0x761(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
movslq -0x670(%rbp), %rax
addq %rax, %rsi
callq 0xc230
movb -0x761(%rbp), %cl
movb %cl, (%rax)
movl -0x670(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x670(%rbp)
movl -0x66c(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x66c(%rbp)
jmp 0x23ae3
jmp 0x23d79
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
cmpl $0xc, %eax
jg 0x23c89
movq -0x638(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xf0, %eax
jne 0x23c89
movq -0x638(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x23c89
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
addl $0x19, %eax
movl %eax, -0x674(%rbp)
movslq -0x674(%rbp), %rsi
leaq -0x610(%rbp), %rdi
callq 0x259c0
movq %rax, -0x680(%rbp)
movq -0x680(%rbp), %rdi
callq 0x259f0
movb %al, -0x762(%rbp)
jmp 0x23bc0
movb -0x762(%rbp), %al
testb $0x1, %al
jne 0x23bdc
jmp 0x23bcc
movq -0x680(%rbp), %rdi
callq 0x25a10
jmp 0x23bda
jmp 0x23bdc
movq -0x680(%rbp), %rdi
callq 0x25a60
movq %rax, -0x770(%rbp)
jmp 0x23bf1
movq -0x770(%rbp), %rdi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x23c09
movq -0x638(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x684(%rbp)
movl $0x0, -0x688(%rbp)
cmpl $0x2, -0x688(%rbp)
jge 0x23c84
movl -0x684(%rbp), %eax
movb %al, -0x771(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
movslq -0x688(%rbp), %rax
addq %rax, %rsi
callq 0xc230
movb -0x771(%rbp), %cl
movb %cl, (%rax)
movl -0x688(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x688(%rbp)
movl -0x684(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x684(%rbp)
jmp 0x23c23
jmp 0x23d79
jmp 0x23c8b
movq -0x8(%rbp), %rdi
movl $0xf5, %esi
callq 0x23550
jmp 0x23c9b
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzbl (%rax), %esi
callq 0x23550
jmp 0x23cb0
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0x23550
jmp 0x23cc6
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzwl 0x4(%rax), %esi
callq 0x23580
jmp 0x23cdc
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzwl 0x8(%rax), %esi
callq 0x23580
jmp 0x23cf2
movl -0x614(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x614(%rbp)
jmp 0x23d77
movq -0x8(%rbp), %rdi
movl $0xe2, %esi
callq 0x23550
jmp 0x23d13
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzbl (%rax), %esi
callq 0x23550
jmp 0x23d28
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0x23550
jmp 0x23d3e
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x235e0
jmp 0x23d53
movq -0x8(%rbp), %rdi
movq -0x638(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x235e0
jmp 0x23d68
movl -0x614(%rbp), %eax
addl $0xb, %eax
movl %eax, -0x614(%rbp)
jmp 0x23d79
leaq -0x628(%rbp), %rdi
callq 0x25bd0
jmp 0x23872
movq -0x18(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x690(%rbp)
movq -0x690(%rbp), %rdi
callq 0x1b960
movq %rax, -0x698(%rbp)
movq -0x690(%rbp), %rdi
callq 0x1b7a0
movq %rax, -0x6a0(%rbp)
leaq -0x698(%rbp), %rdi
leaq -0x6a0(%rbp), %rsi
callq 0x25bf0
testb $0x1, %al
jne 0x23ddb
jmp 0x2436d
leaq -0x698(%rbp), %rdi
callq 0x1be10
movq %rax, -0x6a8(%rbp)
testb $0x1, -0x19(%rbp)
je 0x242ba
movq -0x6a8(%rbp), %rdi
callq 0x25c30
movb %al, -0x772(%rbp)
jmp 0x23e0c
movb -0x772(%rbp), %al
testb $0x1, %al
jne 0x23e1b
jmp 0x242ba
testb $0x1, -0x1a(%rbp)
je 0x24229
movq -0x6a8(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x23f99
movq -0x6a8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x23f99
movl $0x2, -0x6ac(%rbp)
leaq -0x610(%rbp), %rdi
movl $0x2, %esi
callq 0x259c0
movq %rax, -0x6b8(%rbp)
movq -0x6b8(%rbp), %rdi
callq 0x259f0
movb %al, -0x773(%rbp)
jmp 0x23e82
movb -0x773(%rbp), %al
testb $0x1, %al
jne 0x23e9e
jmp 0x23e8e
movq -0x6b8(%rbp), %rdi
callq 0x25a10
jmp 0x23e9c
jmp 0x23e9e
movq -0x6b8(%rbp), %rdi
callq 0x25a60
movq %rax, -0x780(%rbp)
jmp 0x23eb3
movq -0x780(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x23ecb
movq -0x6a8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x6bc(%rbp)
movl -0x6bc(%rbp), %eax
movb %al, -0x783(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
addq $0x0, %rsi
callq 0xc230
movb -0x783(%rbp), %cl
movb %cl, (%rax)
movl -0x6bc(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x6bc(%rbp)
movl -0x6bc(%rbp), %eax
movb %al, -0x782(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
addq $0x1, %rsi
callq 0xc230
movb -0x782(%rbp), %cl
movb %cl, (%rax)
movl -0x6bc(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x6bc(%rbp)
movq -0x6a8(%rbp), %rax
movw 0xa(%rax), %ax
movb %al, -0x781(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
addq $0x2, %rsi
callq 0xc230
movb -0x781(%rbp), %cl
movb %cl, (%rax)
jmp 0x2435c
movq -0x6a8(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x240df
movq -0x6a8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x240df
movq -0x6a8(%rbp), %rax
movzwl 0xa(%rax), %eax
cmpl $0xc, %eax
jg 0x240df
movq -0x6a8(%rbp), %rax
movzwl 0xa(%rax), %eax
addl $0xd, %eax
movl %eax, -0x6c0(%rbp)
movslq -0x6c0(%rbp), %rsi
leaq -0x610(%rbp), %rdi
callq 0x259c0
movq %rax, -0x6c8(%rbp)
movq -0x6c8(%rbp), %rdi
callq 0x259f0
movb %al, -0x784(%rbp)
jmp 0x24016
movb -0x784(%rbp), %al
testb $0x1, %al
jne 0x24032
jmp 0x24022
movq -0x6c8(%rbp), %rdi
callq 0x25a10
jmp 0x24030
jmp 0x24032
movq -0x6c8(%rbp), %rdi
callq 0x25a60
movq %rax, -0x790(%rbp)
jmp 0x24047
movq -0x790(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x2405f
movq -0x6a8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x6cc(%rbp)
movl $0x0, -0x6d0(%rbp)
cmpl $0x2, -0x6d0(%rbp)
jge 0x240da
movl -0x6cc(%rbp), %eax
movb %al, -0x791(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
movslq -0x6d0(%rbp), %rax
addq %rax, %rsi
callq 0xc230
movb -0x791(%rbp), %cl
movb %cl, (%rax)
movl -0x6d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6d0(%rbp)
movl -0x6cc(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x6cc(%rbp)
jmp 0x24079
jmp 0x2435c
movq -0x6a8(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xf0, %eax
jne 0x24227
movq -0x6a8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x24227
movq -0x6a8(%rbp), %rax
movzwl 0xa(%rax), %eax
cmpl $0xc, %eax
jg 0x24227
movq -0x6a8(%rbp), %rax
movzwl 0xa(%rax), %eax
addl $0x19, %eax
movl %eax, -0x6d4(%rbp)
movslq -0x6d4(%rbp), %rsi
leaq -0x610(%rbp), %rdi
callq 0x259c0
movq %rax, -0x6e0(%rbp)
movq -0x6e0(%rbp), %rdi
callq 0x259f0
movb %al, -0x792(%rbp)
jmp 0x2415e
movb -0x792(%rbp), %al
testb $0x1, %al
jne 0x2417a
jmp 0x2416a
movq -0x6e0(%rbp), %rdi
callq 0x25a10
jmp 0x24178
jmp 0x2417a
movq -0x6e0(%rbp), %rdi
callq 0x25a60
movq %rax, -0x7a0(%rbp)
jmp 0x2418f
movq -0x7a0(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x25a80
jmp 0x241a7
movq -0x6a8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x6e4(%rbp)
movl $0x0, -0x6e8(%rbp)
cmpl $0x2, -0x6e8(%rbp)
jge 0x24222
movl -0x6e4(%rbp), %eax
movb %al, -0x7a1(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %eax
addq %rax, %rsi
movslq -0x6e8(%rbp), %rax
addq %rax, %rsi
callq 0xc230
movb -0x7a1(%rbp), %cl
movb %cl, (%rax)
movl -0x6e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6e8(%rbp)
movl -0x6e4(%rbp), %eax
shrl $0x8, %eax
movl %eax, -0x6e4(%rbp)
jmp 0x241c1
jmp 0x2435c
jmp 0x24229
movq -0x8(%rbp), %rdi
movl $0xf6, %esi
callq 0x23550
jmp 0x24239
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzbl (%rax), %esi
callq 0x23550
jmp 0x2424e
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0x23550
jmp 0x24264
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzwl 0x4(%rax), %esi
callq 0x23580
jmp 0x2427a
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzbl 0xa(%rax), %esi
callq 0x23550
jmp 0x24290
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzwl 0xc(%rax), %esi
callq 0x23580
jmp 0x242a6
movl -0x614(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x614(%rbp)
jmp 0x2435a
movq -0x8(%rbp), %rdi
movl $0xe3, %esi
callq 0x23550
jmp 0x242ca
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzbl (%rax), %esi
callq 0x23550
jmp 0x242df
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzbl 0x1(%rax), %esi
callq 0x23550
jmp 0x242f5
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x235e0
jmp 0x2430a
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzwl 0x8(%rax), %esi
callq 0x23580
jmp 0x24320
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movzwl 0xa(%rax), %esi
callq 0x23580
jmp 0x24336
movq -0x8(%rbp), %rdi
movq -0x6a8(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x235e0
jmp 0x2434b
movl -0x614(%rbp), %eax
addl $0xf, %eax
movl %eax, -0x614(%rbp)
jmp 0x2435c
leaq -0x698(%rbp), %rdi
callq 0x25c90
jmp 0x23dbf
movl $0x0, -0x6ec(%rbp)
movslq -0x6ec(%rbp), %rax
movq %rax, -0x7b0(%rbp)
leaq -0x610(%rbp), %rdi
callq 0x25cb0
movq %rax, %rcx
movq -0x7b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x245ae
movslq -0x6ec(%rbp), %rsi
leaq -0x610(%rbp), %rdi
callq 0x259c0
movq %rax, -0x6f8(%rbp)
movq -0x6f8(%rbp), %rdi
callq 0x259f0
movb %al, -0x7b1(%rbp)
jmp 0x243d2
movb -0x7b1(%rbp), %al
testb $0x1, %al
jne 0x243e3
jmp 0x243de
jmp 0x2457a
movq -0x6f8(%rbp), %rdi
callq 0x25a60
movq %rax, -0x7c0(%rbp)
jmp 0x243f8
movq -0x7c0(%rbp), %rdi
callq 0x25cc0
movq %rax, -0x7c8(%rbp)
jmp 0x2440d
movq -0x7c8(%rbp), %rsi
leaq -0x710(%rbp), %rdi
callq 0x14120
jmp 0x24422
leaq -0x710(%rbp), %rdi
callq 0x25cd0
testb $0x1, %al
jne 0x24434
jmp 0x24443
movl $0x17, -0x714(%rbp)
jmp 0x2455e
leaq -0x710(%rbp), %rdi
callq 0xa700
movl %eax, %edx
movl -0x614(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x6(%rax,%rcx), %eax
movl %eax, -0x614(%rbp)
movq -0x8(%rbp), %rdi
movb $-0x9, -0x715(%rbp)
leaq -0x715(%rbp), %rsi
callq 0x25720
jmp 0x2447e
movq -0x8(%rbp), %rax
movq %rax, -0x7d0(%rbp)
leaq -0x710(%rbp), %rdi
callq 0xa700
movq -0x7d0(%rbp), %rdi
movl %eax, %esi
incl %esi
callq 0x235e0
jmp 0x244a7
movq -0x8(%rbp), %rdi
movb -0x6ec(%rbp), %al
movb %al, -0x716(%rbp)
leaq -0x716(%rbp), %rsi
callq 0x25720
jmp 0x244c5
movq -0x8(%rbp), %rdi
movq %rdi, -0x7e0(%rbp)
callq 0xa870
movq %rax, -0x728(%rbp)
leaq -0x720(%rbp), %rdi
leaq -0x728(%rbp), %rsi
callq 0xa8a0
leaq -0x710(%rbp), %rdi
movq %rdi, -0x7e8(%rbp)
callq 0xce10
movq -0x7e8(%rbp), %rdi
movq %rax, -0x730(%rbp)
callq 0xa870
movq -0x7e0(%rbp), %rdi
movq %rax, -0x738(%rbp)
movq -0x720(%rbp), %rsi
movq -0x730(%rbp), %rdx
movq -0x738(%rbp), %rcx
callq 0x25d10
movq %rax, -0x7d8(%rbp)
jmp 0x24546
movq -0x7d8(%rbp), %rax
movq %rax, -0x740(%rbp)
movl $0x0, -0x714(%rbp)
leaq -0x710(%rbp), %rdi
callq 0xcc10
movl -0x714(%rbp), %eax
testl %eax, %eax
je 0x24578
jmp 0x24576
jmp 0x2457a
jmp 0x2457a
movl -0x6ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6ec(%rbp)
jmp 0x24377
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x640(%rbp)
movl %eax, -0x644(%rbp)
leaq -0x710(%rbp), %rdi
callq 0xcc10
jmp 0x245df
movl -0x614(%rbp), %eax
movl %eax, -0x7ec(%rbp)
movl $0x1, -0x714(%rbp)
leaq -0x610(%rbp), %rdi
callq 0x25dc0
movl -0x7ec(%rbp), %eax
addq $0x7f0, %rsp            # imm = 0x7F0
popq %rbp
retq
leaq -0x610(%rbp), %rdi
callq 0x25dc0
movq -0x640(%rbp), %rdi
callq 0x3540
nopw (%rax,%rax)