// File: CMU-SAFARI[P]MQSim/src/utils/Logical_Address_Partitioning_Unit.cpp
// Function: Utils::Logical_Address_Partitioning_Unit::Allocate_logical_address_for_flows(HostInterface_Types, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, std::vector<std::vector<unsigned int, std::allocator<unsigned int>>, std::allocator<std::vector<unsigned int, std::allocator<unsigned int>>>>, std::vector<std::vector<unsigned int, std::allocator<unsigned int>>, std::allocator<std::vector<unsigned int, std::allocator<unsigned int>>>>, std::vector<std::vector<unsigned int, std::allocator<unsigned int>>, std::allocator<std::vector<unsigned int, std::allocator<unsigned int>>>>, std::vector<std::vector<unsigned int, std::allocator<unsigned int>>, std::allocator<std::vector<unsigned int, std::allocator<unsigned int>>>>, unsigned int, unsigned int, unsigned int, double)
void Logical_Address_Partitioning_Unit::Allocate_logical_address_for_flows(HostInterface_Types hostinterface_type, unsigned int concurrent_stream_no,
		unsigned int channel_count, unsigned int chip_no_per_channel, unsigned int die_no_per_chip, unsigned int plane_no_per_die,
		std::vector<std::vector<flash_channel_ID_type>> stream_channel_ids, std::vector<std::vector<flash_chip_ID_type>> stream_chip_ids,
		std::vector<std::vector<flash_die_ID_type>> stream_die_ids, std::vector<std::vector<flash_plane_ID_type>> stream_plane_ids,
		unsigned int block_no_per_plane, unsigned int page_no_per_block, unsigned int sector_no_per_page, double overprovisioning_ratio) 
	{
		if (initialized) {
			return;
		}
		
		Logical_Address_Partitioning_Unit::hostinterface_type = hostinterface_type;

		Logical_Address_Partitioning_Unit::channel_count = channel_count;;
		Logical_Address_Partitioning_Unit::chip_no_per_channel = chip_no_per_channel;
		Logical_Address_Partitioning_Unit::die_no_per_chip = die_no_per_chip;
		Logical_Address_Partitioning_Unit::plane_no_per_die = plane_no_per_die;

		resource_list = new int***[channel_count];
		bool resource_sharing = false;
		for (flash_channel_ID_type channel_id = 0; channel_id < channel_count; channel_id++) {
			resource_list[channel_id] = new int**[chip_no_per_channel];
			for (flash_chip_ID_type chip_id = 0; chip_id < chip_no_per_channel; chip_id++) {
				resource_list[channel_id][chip_id] = new int*[die_no_per_chip];
				for (flash_die_ID_type die_id = 0; die_id < die_no_per_chip; die_id++) {
					resource_list[channel_id][chip_id][die_id] = new int[plane_no_per_die];
					for (flash_plane_ID_type plane_id = 0; plane_id < plane_no_per_die; plane_id++) {
						resource_list[channel_id][chip_id][die_id][plane_id] = 0;
					}
				}
			}
		}

		for (unsigned int stream_id = 0; stream_id < concurrent_stream_no; stream_id++)
		{
			for (flash_channel_ID_type channel_id = 0; channel_id < stream_channel_ids[stream_id].size(); channel_id++) {
				for (flash_chip_ID_type chip_id = 0; chip_id < stream_chip_ids[stream_id].size(); chip_id++) {
					for (flash_die_ID_type die_id = 0; die_id < stream_die_ids[stream_id].size(); die_id++) {
						for (flash_plane_ID_type plane_id = 0; plane_id < stream_plane_ids[stream_id].size(); plane_id++) {
							if (!(stream_channel_ids[stream_id][channel_id] < channel_count)) {
								PRINT_ERROR("Invalid channel ID specified for I/O flow " << stream_id);
							}

							if (!(stream_chip_ids[stream_id][chip_id] < chip_no_per_channel)) {
								PRINT_ERROR("Invalid chip ID specified for I/O flow " << stream_id);
							}

							if (!(stream_die_ids[stream_id][die_id] < die_no_per_chip)) {
								PRINT_ERROR("Invalid die ID specified for I/O flow " << stream_id);
							}

							if (!(stream_plane_ids[stream_id][plane_id] < plane_no_per_die)) {
								PRINT_ERROR("Invalid plane ID specified for I/O flow " << stream_id);
							}
							resource_list[stream_channel_ids[stream_id][channel_id]][stream_chip_ids[stream_id][chip_id]][stream_die_ids[stream_id][die_id]][stream_plane_ids[stream_id][plane_id]]++;
						}
					}
				}
			}
		}

		for (unsigned int stream_id = 0; stream_id < concurrent_stream_no; stream_id++)
		{
			std::vector<flash_channel_ID_type> channel_ids;
			Logical_Address_Partitioning_Unit::stream_channel_ids.push_back(channel_ids);
			for (flash_channel_ID_type channel_id = 0; channel_id < stream_channel_ids[stream_id].size(); channel_id++) {
				Logical_Address_Partitioning_Unit::stream_channel_ids[stream_id].push_back(stream_channel_ids[stream_id][channel_id]);
			}

			std::vector<flash_chip_ID_type> chip_ids;
			Logical_Address_Partitioning_Unit::stream_chip_ids.push_back(chip_ids);
			for (flash_chip_ID_type chip_id = 0; chip_id < stream_chip_ids[stream_id].size(); chip_id++) {
				Logical_Address_Partitioning_Unit::stream_chip_ids[stream_id].push_back(stream_chip_ids[stream_id][chip_id]);
			}

			std::vector<flash_die_ID_type> die_ids;
			Logical_Address_Partitioning_Unit::stream_die_ids.push_back(die_ids);
			for (flash_die_ID_type die_id = 0; die_id < stream_die_ids[stream_id].size(); die_id++) {
				Logical_Address_Partitioning_Unit::stream_die_ids[stream_id].push_back(stream_die_ids[stream_id][die_id]);
			}

			std::vector<flash_plane_ID_type> plane_ids;
			Logical_Address_Partitioning_Unit::stream_plane_ids.push_back(plane_ids);
			for (flash_plane_ID_type plane_id = 0; plane_id < stream_plane_ids[stream_id].size(); plane_id++) {
				Logical_Address_Partitioning_Unit::stream_plane_ids[stream_id].push_back(stream_plane_ids[stream_id][plane_id]);
			}
		}

		std::vector<LHA_type> lsa_count_per_stream;
		for (unsigned int stream_id = 0; stream_id < concurrent_stream_no; stream_id++) {
			LHA_type lsa_count = 0;
			for (flash_channel_ID_type channel_id = 0; channel_id < stream_channel_ids[stream_id].size(); channel_id++) {
				for (flash_chip_ID_type chip_id = 0; chip_id < stream_chip_ids[stream_id].size(); chip_id++) {
					for (flash_die_ID_type die_id = 0; die_id < stream_die_ids[stream_id].size(); die_id++) {
						for (flash_plane_ID_type plane_id = 0; plane_id < stream_plane_ids[stream_id].size(); plane_id++) {
							lsa_count += (LHA_type)((block_no_per_plane * page_no_per_block * sector_no_per_page * (1.0 - overprovisioning_ratio) *
								1.0 / double(resource_list[stream_channel_ids[stream_id][channel_id]][stream_chip_ids[stream_id][chip_id]][stream_die_ids[stream_id][die_id]][stream_plane_ids[stream_id][plane_id]])));
						}
					}
				}
			}
			pdas_per_flow.push_back(LHA_type(double(lsa_count) / (1.0 - overprovisioning_ratio)));
			total_pda_no += pdas_per_flow[stream_id];
			lsa_count_per_stream.push_back(lsa_count);
		}

		total_lha_no = 0;
		for (unsigned int stream_id = 0; stream_id < concurrent_stream_no; stream_id++) {
			start_lhas_per_flow.push_back(total_lha_no);
			end_lhas_per_flow.push_back(total_lha_no + lsa_count_per_stream[stream_id] - 1);
			total_lha_no += lsa_count_per_stream[stream_id];
		}

		initialized = true;
	}

// Assembly:
subq $0x238, %rsp            # imm = 0x238
movl 0x270(%rsp), %eax
movl 0x268(%rsp), %eax
movl 0x260(%rsp), %eax
movq 0x258(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x250(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0x248(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x240(%rsp), %rax
movq %rax, 0x108(%rsp)
movl %edi, 0x234(%rsp)
movl %esi, 0x230(%rsp)
movl %edx, 0x22c(%rsp)
movl %ecx, 0x228(%rsp)
movl %r8d, 0x224(%rsp)
movl %r9d, 0x220(%rsp)
movsd %xmm0, 0x218(%rsp)
testb $0x1, 0x3968c(%rip)     # 0xded84
je 0xa56ff
jmp 0xa67cd
movl 0x234(%rsp), %eax
movl %eax, 0x39674(%rip)     # 0xded80
movl 0x22c(%rsp), %eax
movl %eax, 0x396b7(%rip)     # 0xdedd0
movl 0x228(%rsp), %eax
movl %eax, 0x396ae(%rip)     # 0xdedd4
movl 0x224(%rsp), %eax
movl %eax, 0x396a5(%rip)     # 0xdedd8
movl 0x220(%rsp), %eax
movl %eax, 0x3969c(%rip)     # 0xdeddc
movl 0x22c(%rsp), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, 0x395a9(%rip)     # 0xded18
movb $0x0, 0x217(%rsp)
movl $0x0, 0x210(%rsp)
movl 0x210(%rsp), %eax
cmpl 0x22c(%rsp), %eax
jae 0xa5958
movl 0x228(%rsp), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rdx
movq 0x39550(%rip), %rax     # 0xded18
movl 0x210(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x20c(%rsp)
movl 0x20c(%rsp), %eax
cmpl 0x228(%rsp), %eax
jae 0xa5940
movl 0x224(%rsp), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rdx
movq 0x394f4(%rip), %rax     # 0xded18
movl 0x210(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x20c(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x208(%rsp)
movl 0x208(%rsp), %eax
cmpl 0x224(%rsp), %eax
jae 0xa5928
movl 0x220(%rsp), %eax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rdx
movq 0x3948d(%rip), %rax     # 0xded18
movl 0x210(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x20c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x208(%rsp), %ecx
movq %rdx, (%rax,%rcx,8)
movl $0x0, 0x204(%rsp)
movl 0x204(%rsp), %eax
cmpl 0x220(%rsp), %eax
jae 0xa5910
movq 0x3944a(%rip), %rax     # 0xded18
movl 0x210(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x20c(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x208(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x204(%rsp), %ecx
movl $0x0, (%rax,%rcx,4)
movl 0x204(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x204(%rsp)
jmp 0xa58b7
jmp 0xa5912
movl 0x208(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x208(%rsp)
jmp 0xa5845
jmp 0xa592a
movl 0x20c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20c(%rsp)
jmp 0xa57de
jmp 0xa5942
movl 0x210(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x210(%rsp)
jmp 0xa5782
movl $0x0, 0x200(%rsp)
movl 0x200(%rsp), %eax
cmpl 0x230(%rsp), %eax
jae 0xa5e59
movl $0x0, 0x1fc(%rsp)
movq 0x108(%rsp), %rdi
movl 0x1fc(%rsp), %eax
movq %rax, 0xe8(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0xe8(%rsp), %rax
cmpq %rcx, %rax
jae 0xa5e41
movl $0x0, 0x1f8(%rsp)
movq 0x100(%rsp), %rdi
movl 0x1f8(%rsp), %eax
movq %rax, 0xe0(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0xe0(%rsp), %rax
cmpq %rcx, %rax
jae 0xa5e29
movl $0x0, 0x1f4(%rsp)
movq 0xf8(%rsp), %rdi
movl 0x1f4(%rsp), %eax
movq %rax, 0xd8(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0xd8(%rsp), %rax
cmpq %rcx, %rax
jae 0xa5e11
movl $0x0, 0x1f0(%rsp)
movq 0xf0(%rsp), %rdi
movl 0x1f0(%rsp), %eax
movq %rax, 0xd0(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0xd0(%rsp), %rax
cmpq %rcx, %rax
jae 0xa5df9
movq 0x108(%rsp), %rdi
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1fc(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movl (%rax), %eax
cmpl 0x22c(%rsp), %eax
jb 0xa5b33
movq 0x34510(%rip), %rdi     # 0xd9ff0
leaq 0x4e01(%rip), %rsi      # 0xaa8e8
callq 0x8440
movq 0x344fd(%rip), %rdi     # 0xd9ff0
leaq 0x6d61(%rip), %rsi      # 0xac85b
callq 0x8440
movq %rax, %rdi
movl 0x200(%rsp), %esi
callq 0x85b0
movq %rax, %rdi
movq 0x34440(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x344ac(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq 0x100(%rsp), %rdi
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f8(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movl (%rax), %eax
cmpl 0x228(%rsp), %eax
jb 0xa5bbf
movq 0x34484(%rip), %rdi     # 0xd9ff0
leaq 0x4d75(%rip), %rsi      # 0xaa8e8
callq 0x8440
movq 0x34471(%rip), %rdi     # 0xd9ff0
leaq 0x6d00(%rip), %rsi      # 0xac886
callq 0x8440
movq %rax, %rdi
movl 0x200(%rsp), %esi
callq 0x85b0
movq %rax, %rdi
movq 0x343b4(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x34420(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq 0xf8(%rsp), %rdi
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f4(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movl (%rax), %eax
cmpl 0x224(%rsp), %eax
jb 0xa5c4b
movq 0x343f8(%rip), %rdi     # 0xd9ff0
leaq 0x4ce9(%rip), %rsi      # 0xaa8e8
callq 0x8440
movq 0x343e5(%rip), %rdi     # 0xd9ff0
leaq 0x6c9c(%rip), %rsi      # 0xac8ae
callq 0x8440
movq %rax, %rdi
movl 0x200(%rsp), %esi
callq 0x85b0
movq %rax, %rdi
movq 0x34328(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x34394(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq 0xf0(%rsp), %rdi
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f0(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movl (%rax), %eax
cmpl 0x220(%rsp), %eax
jb 0xa5cd7
movq 0x3436c(%rip), %rdi     # 0xd9ff0
leaq 0x4c5d(%rip), %rsi      # 0xaa8e8
callq 0x8440
movq 0x34359(%rip), %rdi     # 0xd9ff0
leaq 0x6c37(%rip), %rsi      # 0xac8d5
callq 0x8440
movq %rax, %rdi
movl 0x200(%rsp), %esi
callq 0x85b0
movq %rax, %rdi
movq 0x3429c(%rip), %rsi     # 0xd9f58
callq 0x8480
movq 0x34308(%rip), %rdi     # 0xd9fd0
callq 0x84f0
movl $0x1, %edi
callq 0x8500
movq 0x108(%rsp), %rdi
movq 0x39032(%rip), %rax     # 0xded18
movq %rax, 0xb0(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1fc(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x100(%rsp), %rdi
movq %rax, %rcx
movq 0xb0(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0xb8(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f8(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0xf8(%rsp), %rdi
movq %rax, %rcx
movq 0xb8(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0xc0(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f4(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0xf0(%rsp), %rdi
movq %rax, %rcx
movq 0xc0(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0xc8(%rsp)
movl 0x200(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1f0(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq %rax, %rcx
movq 0xc8(%rsp), %rax
movl (%rcx), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl 0x1f0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f0(%rsp)
jmp 0xa5a66
jmp 0xa5dfb
movl 0x1f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f4(%rsp)
jmp 0xa5a1a
jmp 0xa5e13
movl 0x1f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f8(%rsp)
jmp 0xa59ce
jmp 0xa5e2b
movl 0x1fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1fc(%rsp)
jmp 0xa5982
jmp 0xa5e43
movl 0x200(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x200(%rsp)
jmp 0xa5963
movl $0x0, 0x1ec(%rsp)
movl 0x1ec(%rsp), %eax
cmpl 0x230(%rsp), %eax
jae 0xa62cc
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x21580
movq 0xa8(%rsp), %rsi
leaq 0x38e84(%rip), %rdi     # 0xded20
callq 0x2cfd0
jmp 0xa5ea3
movl $0x0, 0x1c0(%rsp)
movq 0x108(%rsp), %rdi
movl 0x1c0(%rsp), %eax
movq %rax, 0xa0(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0xa5f76
movl 0x1ec(%rsp), %eax
movl %eax, %esi
leaq 0x38e21(%rip), %rdi     # 0xded20
callq 0x2d040
movq 0x108(%rsp), %rdi
movq %rax, 0x98(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1c0(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x98(%rsp), %rdi
movq %rax, %rsi
callq 0x2d060
jmp 0xa5f45
jmp 0xa5f47
movl 0x1c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c0(%rsp)
jmp 0xa5eae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xa62ba
leaq 0x1a8(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x21580
movq 0x90(%rsp), %rsi
leaq 0x38d9e(%rip), %rdi     # 0xded38
callq 0x2cfd0
jmp 0xa5fa1
movl $0x0, 0x1a4(%rsp)
movq 0x100(%rsp), %rdi
movl 0x1a4(%rsp), %eax
movq %rax, 0x88(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x88(%rsp), %rax
cmpq %rcx, %rax
jae 0xa6074
movl 0x1ec(%rsp), %eax
movl %eax, %esi
leaq 0x38d3b(%rip), %rdi     # 0xded38
callq 0x2d040
movq 0x100(%rsp), %rdi
movq %rax, 0x80(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x1a4(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x2d060
jmp 0xa6043
jmp 0xa6045
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0xa5fac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xa62ad
leaq 0x188(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x21580
movq 0x78(%rsp), %rsi
leaq 0x38cbe(%rip), %rdi     # 0xded50
callq 0x2cfd0
jmp 0xa6099
movl $0x0, 0x184(%rsp)
movq 0xf8(%rsp), %rdi
movl 0x184(%rsp), %eax
movq %rax, 0x70(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x70(%rsp), %rax
cmpq %rcx, %rax
jae 0xa6160
movl 0x1ec(%rsp), %eax
movl %eax, %esi
leaq 0x38c61(%rip), %rdi     # 0xded50
callq 0x2d040
movq 0xf8(%rsp), %rdi
movq %rax, 0x68(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x184(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x68(%rsp), %rdi
movq %rax, %rsi
callq 0x2d060
jmp 0xa612f
jmp 0xa6131
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0xa60a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xa62a0
leaq 0x168(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x21580
movq 0x60(%rsp), %rsi
leaq 0x38bea(%rip), %rdi     # 0xded68
callq 0x2cfd0
jmp 0xa6185
movl $0x0, 0x164(%rsp)
movq 0xf0(%rsp), %rdi
movl 0x164(%rsp), %eax
movq %rax, 0x58(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jae 0xa6256
movl 0x1ec(%rsp), %eax
movl %eax, %esi
leaq 0x38b8d(%rip), %rdi     # 0xded68
callq 0x2d040
movq 0xf0(%rsp), %rdi
movq %rax, 0x50(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x164(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x2d060
jmp 0xa621b
jmp 0xa621d
movl 0x164(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0xa6190
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x20b00
jmp 0xa62a0
leaq 0x168(%rsp), %rdi
callq 0x20b00
leaq 0x188(%rsp), %rdi
callq 0x20b00
leaq 0x1a8(%rsp), %rdi
callq 0x20b00
leaq 0x1d0(%rsp), %rdi
callq 0x20b00
movl 0x1ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ec(%rsp)
jmp 0xa5e64
leaq 0x188(%rsp), %rdi
callq 0x20b00
leaq 0x1a8(%rsp), %rdi
callq 0x20b00
leaq 0x1d0(%rsp), %rdi
callq 0x20b00
jmp 0xa67d5
leaq 0x148(%rsp), %rdi
callq 0x21550
movl $0x0, 0x144(%rsp)
movl 0x144(%rsp), %eax
cmpl 0x230(%rsp), %eax
jae 0xa66ef
movq $0x0, 0x138(%rsp)
movl $0x0, 0x134(%rsp)
movq 0x108(%rsp), %rdi
movl 0x134(%rsp), %eax
movq %rax, 0x48(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0xa65e9
movl $0x0, 0x130(%rsp)
movq 0x100(%rsp), %rdi
movl 0x130(%rsp), %eax
movq %rax, 0x40(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jae 0xa65d1
movl $0x0, 0x12c(%rsp)
movq 0xf8(%rsp), %rdi
movl 0x12c(%rsp), %eax
movq %rax, 0x38(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0xa65b9
movl $0x0, 0x128(%rsp)
movq 0xf0(%rsp), %rdi
movl 0x128(%rsp), %eax
movq %rax, 0x30(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
callq 0x2e770
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0xa65a1
movq 0x108(%rsp), %rdi
movl 0x260(%rsp), %eax
movl 0x268(%rsp), %ecx
imull %ecx, %eax
movl 0x270(%rsp), %ecx
imull %ecx, %eax
cvtsi2sd %rax, %xmm0
movsd 0x218(%rsp), %xmm2
movsd 0x586b(%rip), %xmm1     # 0xabcc0
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
movq 0x388ae(%rip), %rax     # 0xded18
movq %rax, 0x8(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x134(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0x100(%rsp), %rdi
movq %rax, %rcx
movq 0x8(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x130(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0xf8(%rsp), %rdi
movq %rax, %rcx
movq 0x10(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x12c(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movq 0xf0(%rsp), %rdi
movq %rax, %rcx
movq 0x18(%rsp), %rax
movl (%rcx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
movl 0x144(%rsp), %eax
movl %eax, %esi
callq 0x2d040
movq %rax, %rdi
movl 0x128(%rsp), %eax
movl %eax, %esi
callq 0x3b3e0
movsd 0x20(%rsp), %xmm0
movq %rax, %rcx
movq 0x28(%rsp), %rax
movl (%rcx), %ecx
cvtsi2sdl (%rax,%rcx,4), %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x2a9c(%rip), %xmm1     # 0xa9008
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
addq 0x138(%rsp), %rax
movq %rax, 0x138(%rsp)
movl 0x128(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x128(%rsp)
jmp 0xa63e1
jmp 0xa65a3
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0xa639b
jmp 0xa65bb
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0xa6355
jmp 0xa65d3
movl 0x134(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x134(%rsp)
jmp 0xa630f
movaps 0x53c0(%rip), %xmm1     # 0xab9b0
movq 0x138(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x53bb(%rip), %xmm1     # 0xab9c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x218(%rsp), %xmm2
movsd 0x569b(%rip), %xmm1     # 0xabcc0
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x29c4(%rip), %xmm1     # 0xa9008
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, 0x120(%rsp)
leaq 0x38726(%rip), %rdi     # 0xded88
leaq 0x120(%rsp), %rsi
callq 0x3b170
jmp 0xa6671
movl 0x144(%rsp), %eax
movl %eax, %esi
leaq 0x38707(%rip), %rdi     # 0xded88
callq 0x3b3c0
movq (%rax), %rcx
movq 0x38750(%rip), %rax     # 0xdede0
addq %rcx, %rax
movq %rax, 0x38746(%rip)     # 0xdede0
leaq 0x148(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x59be0
jmp 0xa66b1
jmp 0xa66b3
movl 0x144(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x144(%rsp)
jmp 0xa62e4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
leaq 0x148(%rsp), %rdi
callq 0x20b80
jmp 0xa67d5
movq $0x0, 0x386ee(%rip) # 0xdede8
movl $0x0, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
cmpl 0x230(%rsp), %eax
jae 0xa67b9
leaq 0x38680(%rip), %rdi     # 0xdeda0
leaq 0x386c1(%rip), %rsi     # 0xdede8
callq 0x59be0
jmp 0xa672e
movq 0x386b3(%rip), %rax     # 0xdede8
movq %rax, (%rsp)
movl 0x11c(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0x3b3c0
movq %rax, %rcx
movq (%rsp), %rax
movq (%rcx), %rcx
leaq -0x1(%rax,%rcx), %rax
movq %rax, 0x110(%rsp)
leaq 0x3864b(%rip), %rdi     # 0xdedb8
leaq 0x110(%rsp), %rsi
callq 0x3b170
jmp 0xa677c
movl 0x11c(%rsp), %eax
movl %eax, %esi
leaq 0x148(%rsp), %rdi
callq 0x3b3c0
movq (%rax), %rax
addq 0x3864c(%rip), %rax     # 0xdede8
movq %rax, 0x38645(%rip)     # 0xdede8
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0xa6705
movb $0x1, 0x385c4(%rip)     # 0xded84
leaq 0x148(%rsp), %rdi
callq 0x20b80
addq $0x238, %rsp            # imm = 0x238
retq
movq 0x1c8(%rsp), %rdi
callq 0x8770
nopw %cs:(%rax,%rax)