// File: estwings57[P]CasHMC/sources/CrossbarSwitch.cpp
// Function: CasHMC::CrossbarSwitch::Update()
void CrossbarSwitch::Update()
{	
	//Downstream buffer state
	if(bufPopDelay == 0) {
		for(int i=0; i<downBuffers.size(); i++) {
			if(downBuffers[i] != NULL) {
				//Check request size and the maximum block size
				if(downBuffers[i]->reqDataSize > ADDRESS_MAPPING) {
					int segPacket = ceil((double)downBuffers[i]->reqDataSize/ADDRESS_MAPPING);
					downBuffers[i]->reqDataSize = ADDRESS_MAPPING;
					DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[i]<<"Down) Packet is DIVIDED into "<<segPacket<<" segment packets by max block size");
					
					//the packet is divided into segment packets.
					Packet *tempPacket = downBuffers[i];
					downBuffers.erase(downBuffers.begin()+i, downBuffers.begin()+i+downBuffers[i]->LNG);
					if(tempPacket->LNG > 1)	tempPacket->LNG = 1 + ADDRESS_MAPPING/16;	//one flit is 16 bytes
					for(int j=0; j<segPacket; j++) {
						Packet *vaultPacket = new Packet(*tempPacket);
						vaultPacket->ADRS += j*ADDRESS_MAPPING;
						if(j>0)	vaultPacket->trace = NULL;
						downBuffers.insert(downBuffers.begin()+i, vaultPacket);
						for(int k=1; k<vaultPacket->LNG; k++) {		//Virtual tail packet
							downBuffers.insert(downBuffers.begin()+i+1, NULL);
						}
						i += vaultPacket->LNG;
						vaultPacket->segment = true;
						pendingSegTag.push_back(vaultPacket->TAG);
					}
					delete tempPacket;
				}
				else {
					unsigned vaultMap = (downBuffers[i]->ADRS >> _log2(ADDRESS_MAPPING)) & (NUM_VAULTS-1);
					if(downBufferDest[vaultMap]->ReceiveDown(downBuffers[i])) {
						DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[i]<<"Down) SENDING packet to vault controller "<<vaultMap<<" (VC_"<<vaultMap<<")");
						downBuffers.erase(downBuffers.begin()+i, downBuffers.begin()+i+downBuffers[i]->LNG);
						i--;
					}
					else {
						//DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[i]<<"Down) Vault controller buffer FULL");	
					}
				}
			}
		}
	}
	
	//Upstream buffer state
	for(int i=0; i<upBuffers.size(); i++) {
		if(upBuffers[i] != NULL) {
			//If the segment packet is arrived
			if(upBuffers[i]->segment) {
				//Check a stored segment packet tag
				bool foundSeg = false;
				bool foundLastSeg = true;
				for(int j=0; j<pendingSegTag.size(); j++) {
					if(upBuffers[i]->TAG == pendingSegTag[j]) {
						pendingSegTag.erase(pendingSegTag.begin()+j);
						foundSeg = true;
						//Check whether upBuffers[i] packet is the last segment packet or not 
						for(int k=j; k<pendingSegTag.size(); k++) {
							if(upBuffers[i]->TAG == pendingSegTag[k]) {
								DEBUG(ALI(18)<<header<<ALI(15)<<*upBuffers[i]<<"Up)   Segment packet is WAITING for the others");
								foundLastSeg = false;
								break;
							}
						}
						if(foundLastSeg) {
							DEBUG(ALI(18)<<header<<ALI(15)<<*upBuffers[i]<<"Up)   The LAST segment packet is arrived");
						}
						break;
					}
				}
				if(!foundSeg) {
					ERROR(header<<"  == Error - pendingSegTag doesn't have segment packet tag ["<<*upBuffers[i]<<"]");
					exit(0);
				}
				
				//Segment packets are combined together
				foundSeg = false;
				for(int j=0; j<pendingSegPacket.size(); j++) {
					if(upBuffers[i]->TAG == pendingSegPacket[j]->TAG) {
						if(upBuffers[i]->LNG > 1)	pendingSegPacket[j]->LNG += ADDRESS_MAPPING/16;
						if(upBuffers[i]->trace != NULL) { //It is the first segment packet
							pendingSegPacket[j]->trace = upBuffers[i]->trace;
							pendingSegPacket[j]->ADRS = upBuffers[i]->ADRS;
						}
						//Delete a segment packet
						int packetLNG = upBuffers[i]->LNG;
						delete upBuffers[i];
						upBuffers.erase(upBuffers.begin()+i, upBuffers.begin()+i+packetLNG);
						foundSeg = true;
						//All segment packets are combined
						if(foundLastSeg) {
							Packet *combPacket = new Packet(*pendingSegPacket[j]);
							delete pendingSegPacket[j];
							pendingSegPacket.erase(pendingSegPacket.begin()+j);
							combPacket->segment = false;
							upBuffers.insert(upBuffers.begin(), combPacket);
							for(int k=1; k<combPacket->LNG; k++) {	//Virtual tail packet
								upBuffers.insert(upBuffers.begin()+1, NULL);
							}
						}
						else {
							i--;
						}
						break;
					}
				}
				//Thr first arrived segment packet
				if(!foundSeg) {
					pendingSegPacket.push_back(upBuffers[i]);
					upBuffers.erase(upBuffers.begin()+i, upBuffers.begin()+i+upBuffers[i]->LNG);
					i--;
				}
			}
			else {
				for(int l=0; l<NUM_LINKS; l++) {
					int link = FindAvailableLink(inServiceLink, upBufferDest);
					if(link == -1) {
						//DEBUG(ALI(18)<<header<<ALI(15)<<*upBuffers[i]<<"Up)   all packet buffer FULL");
					}
					else if(upBufferDest[link]->currentState != ACTIVE
					&& upBufferDest[link]->currentState != LINK_RETRY) {
						continue;
						//DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[0]<<"Down) link "<<l<<" is not ACTIVE mode ["<<downLinkMasters[link]->powerMode<<"]");
					}
					else {
						if(upBufferDest[link]->Receive(upBuffers[i])) {
							DEBUG(ALI(18)<<header<<ALI(15)<<*upBuffers[i]<<"Up)   SENDING packet to link master "<<link<<" (LM_U"<<link<<")");
							upBuffers.erase(upBuffers.begin()+i, upBuffers.begin()+i+upBuffers[i]->LNG);
							i--;
							break;
						}
						else {
							//DEBUG(ALI(18)<<header<<ALI(15)<<*upBuffers[i]<<"Up)   Link master buffer FULL");
						}
					}
				}
			}
		}
	}
	
	Step();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2e8(%rbp)
cmpl $0x0, 0x200(%rax)
jne 0x27f6a
movl $0x0, -0xc(%rbp)
movq -0x2e8(%rbp), %rdi
movslq -0xc(%rbp), %rax
movq %rax, -0x2f0(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x22d60
movq %rax, %rcx
movq -0x2f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x27f68
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
cmpq $0x0, (%rax)
je 0x27f58
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x424(%rax), %eax
leaq 0x3eec5(%rip), %rcx     # 0x6662c
cmpl (%rcx), %eax
jbe 0x27c52
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x424(%rax), %eax
cvtsi2sd %rax, %xmm0
leaq 0x3ee91(%rip), %rax     # 0x6662c
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x2e8(%rbp), %rdi
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
leaq 0x3ee6f(%rip), %rax     # 0x6662c
movl (%rax), %eax
movl %eax, -0x2f4(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movl -0x2f4(%rbp), %ecx
movq (%rax), %rax
movl %ecx, 0x424(%rax)
leaq 0x3ed3d(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x27903
leaq 0x3ed2e(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x27903
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
movq 0x3e7b5(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x318(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x318(%rbp), %rdi
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x310(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x310(%rbp), %rdi
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
callq 0x4440
movq %rax, -0x308(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x308(%rbp), %rdi
movb %al, -0x1d(%rbp)
movzbl -0x1d(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rdi
movq %rax, -0x300(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq -0x300(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2b501(%rip), %rsi     # 0x52dd6
callq 0x4380
movq %rax, %rdi
movl -0x10(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x2b505(%rip), %rsi     # 0x52df4
callq 0x4380
movq %rax, %rdi
movq 0x3e6b2(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x320(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0x40(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x29a20
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x29a60
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0x60(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x29a20
movq -0x2e8(%rbp), %rdi
movq %rax, -0x58(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, %esi
leaq -0x58(%rbp), %rdi
callq 0x29a20
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x29a60
movq -0x320(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x29960
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x1, 0x430(%rax)
jbe 0x27a0f
leaq 0x3ec36(%rip), %rax     # 0x6662c
movl (%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x430(%rax)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x27c2f
movl $0x468, %edi            # imm = 0x468
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x328(%rbp)
movq -0x28(%rbp), %rsi
callq 0x43ff0
jmp 0x27a44
movq -0x328(%rbp), %rax
movq %rax, -0x78(%rbp)
movl -0x6c(%rbp), %eax
leaq 0x3ebd3(%rip), %rcx     # 0x6662c
imull (%rcx), %eax
movslq %eax, %rcx
movq -0x78(%rbp), %rax
addq 0x450(%rax), %rcx
movq %rcx, 0x450(%rax)
cmpl $0x0, -0x6c(%rbp)
jle 0x27aaa
movq -0x78(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x27aaa
movq -0x328(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
movl $0x468, %esi            # imm = 0x468
callq 0x43a0
jmp 0x28f80
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x330(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0xa0(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x29a20
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x29a60
movq -0x330(%rbp), %rdi
movq -0x90(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x29aa0
movq %rax, -0xa8(%rbp)
movl $0x1, -0xac(%rbp)
movl -0xac(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x430(%rcx), %eax
jae 0x27be8
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x338(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0xd0(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x29a20
movq %rax, -0xc8(%rbp)
leaq -0xc8(%rbp), %rdi
movl $0x1, %esi
callq 0x29a20
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x29a60
movq -0x338(%rbp), %rdi
movq $0x0, -0xd8(%rbp)
movq -0xb8(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x29ca0
movq %rax, -0xe0(%rbp)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x27b26
movq -0x2e8(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x430(%rax), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movq -0x78(%rbp), %rax
movb $0x1, 0x422(%rax)
addq $0x240, %rdi            # imm = 0x240
movq -0x78(%rbp), %rsi
addq $0x42c, %rsi            # imm = 0x42C
callq 0x19ee0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x27a16
movq -0x28(%rbp), %rax
movq %rax, -0x340(%rbp)
cmpq $0x0, %rax
je 0x27c4d
movq -0x340(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x27f56
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movq 0x450(%rax), %rax
movq %rax, -0x350(%rbp)
leaq 0x3e9ab(%rip), %rax     # 0x6662c
movl (%rax), %edi
callq 0x29ce0
movq -0x2e8(%rbp), %rdi
movl %eax, %ecx
movq -0x350(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
leaq 0x3e978(%rip), %rcx     # 0x6661c
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
andq %rcx, %rax
movl %eax, -0xe4(%rbp)
addq $0x208, %rdi            # imm = 0x208
movl -0xe4(%rbp), %eax
movl %eax, %esi
callq 0x29d40
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x348(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq -0x348(%rbp), %rdi
movq (%rax), %rsi
callq 0x29d60
testb $0x1, %al
jne 0x27d02
jmp 0x27f52
leaq 0x3e81f(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x27e59
leaq 0x3e810(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x27e59
movl $0x12, %edi
callq 0x177b0
movl %eax, -0xe8(%rbp)
movl -0xe8(%rbp), %esi
movq 0x3e291(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x370(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x370(%rbp), %rdi
movb %al, -0xe9(%rbp)
movzbl -0xe9(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x368(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x368(%rbp), %rdi
movl %eax, -0xf0(%rbp)
movl -0xf0(%rbp), %esi
callq 0x4440
movq %rax, -0x360(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x360(%rbp), %rdi
movb %al, -0xf1(%rbp)
movzbl -0xf1(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rdi
movq %rax, -0x358(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq -0x358(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2b00c(%rip), %rsi     # 0x52e17
callq 0x4380
movq %rax, %rdi
movl -0xe4(%rbp), %esi
callq 0x44c0
movq %rax, %rdi
leaq 0x2cc32(%rip), %rsi     # 0x54a5a
callq 0x4380
movq %rax, %rdi
movl -0xe4(%rbp), %esi
callq 0x44c0
movq %rax, %rdi
leaq 0x2c534(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x3e15c(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x378(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0x110(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x29a20
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x29a60
movq -0x2e8(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x299f0
movq %rax, -0x130(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x29a20
movq -0x2e8(%rbp), %rdi
movq %rax, -0x128(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0xc(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, %esi
leaq -0x128(%rbp), %rdi
callq 0x29a20
movq %rax, -0x120(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x29a60
movq -0x378(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq -0x118(%rbp), %rdx
callq 0x29960
movq %rax, -0x138(%rbp)
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x27f54
jmp 0x27f54
jmp 0x27f56
jmp 0x27f58
jmp 0x27f5a
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x276ee
jmp 0x27f6a
movl $0x0, -0x13c(%rbp)
movq -0x2e8(%rbp), %rdi
movslq -0x13c(%rbp), %rax
movq %rax, -0x380(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x22d60
movq %rax, %rcx
movq -0x380(%rbp), %rax
cmpq %rcx, %rax
jae 0x28f6b
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
cmpq $0x0, (%rax)
je 0x28f55
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
testb $0x1, 0x422(%rax)
je 0x28bdc
movb $0x0, -0x13d(%rbp)
movb $0x1, -0x13e(%rbp)
movl $0x0, -0x144(%rbp)
movq -0x2e8(%rbp), %rdi
movslq -0x144(%rbp), %rax
movq %rax, -0x388(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x17eb0
movq %rax, %rcx
movq -0x388(%rbp), %rax
cmpq %rcx, %rax
jae 0x28428
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movl 0x42c(%rax), %eax
movl %eax, -0x38c(%rbp)
addq $0x240, %rdi            # imm = 0x240
movslq -0x144(%rbp), %rsi
callq 0x17e90
movq %rax, %rcx
movl -0x38c(%rbp), %eax
cmpl (%rcx), %eax
jne 0x28412
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x240, %rax            # imm = 0x240
movq %rax, -0x398(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x19bc0
movq %rax, -0x160(%rbp)
movslq -0x144(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x25950
movq %rax, -0x158(%rbp)
leaq -0x150(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x22aa0
movq -0x398(%rbp), %rdi
movq -0x150(%rbp), %rsi
callq 0x22a30
movq %rax, -0x168(%rbp)
movb $0x1, -0x13d(%rbp)
movl -0x144(%rbp), %eax
movl %eax, -0x16c(%rbp)
movq -0x2e8(%rbp), %rdi
movslq -0x16c(%rbp), %rax
movq %rax, -0x3a0(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x17eb0
movq %rax, %rcx
movq -0x3a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x282e1
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movl 0x42c(%rax), %eax
movl %eax, -0x3a4(%rbp)
addq $0x240, %rdi            # imm = 0x240
movslq -0x16c(%rbp), %rsi
callq 0x17e90
movq %rax, %rcx
movl -0x3a4(%rbp), %eax
cmpl (%rcx), %eax
jne 0x282cb
leaq 0x3e37f(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x282c2
leaq 0x3e370(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x282c2
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x170(%rbp)
movl -0x170(%rbp), %esi
movq 0x3ddf1(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x3c8(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x3c8(%rbp), %rdi
movb %al, -0x171(%rbp)
movzbl -0x171(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x3c0(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x3c0(%rbp), %rdi
movl %eax, -0x178(%rbp)
movl -0x178(%rbp), %esi
callq 0x4440
movq %rax, -0x3b8(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x3b8(%rbp), %rdi
movb %al, -0x179(%rbp)
movzbl -0x179(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rdi
movq %rax, -0x3b0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x3b0(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2ab93(%rip), %rsi     # 0x52e41
callq 0x4380
movq %rax, %rdi
movq 0x3dcf3(%rip), %rsi     # 0x65fb0
callq 0x43c0
movb $0x0, -0x13e(%rbp)
jmp 0x282e1
jmp 0x282cd
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x2811a
testb $0x1, -0x13e(%rbp)
je 0x28410
leaq 0x3e233(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x2840e
leaq 0x3e224(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x2840e
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x180(%rbp)
movl -0x180(%rbp), %esi
movq 0x3dca5(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x3e8(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x3e8(%rbp), %rdi
movb %al, -0x181(%rbp)
movzbl -0x181(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x3e0(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x3e0(%rbp), %rdi
movl %eax, -0x188(%rbp)
movl -0x188(%rbp), %esi
callq 0x4440
movq %rax, -0x3d8(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x3d8(%rbp), %rdi
movb %al, -0x189(%rbp)
movzbl -0x189(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rdi
movq %rax, -0x3d0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x3d0(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2aa76(%rip), %rsi     # 0x52e70
callq 0x4380
movq %rax, %rdi
movq 0x3dba7(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x28410
jmp 0x28428
jmp 0x28414
movl -0x144(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x144(%rbp)
jmp 0x2800e
testb $0x1, -0x13d(%rbp)
jne 0x284f9
movq 0x3dbb4(%rip), %rdi     # 0x65ff0
leaq 0x28bf7(%rip), %rsi     # 0x5103a
callq 0x4380
movq %rax, %rdi
leaq 0x2aa47(%rip), %rsi     # 0x52e99
callq 0x4380
movq %rax, %rdi
leaq 0x293d4(%rip), %rsi     # 0x51835
callq 0x4380
movq %rax, %rdi
movl $0x85, %esi
callq 0x4610
movq %rax, %rdi
leaq 0x28bdc(%rip), %rsi     # 0x51059
callq 0x4380
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x2aa15(%rip), %rsi     # 0x52eb4
callq 0x4380
movq -0x2e8(%rbp), %rdi
movq %rax, -0x3f0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x3f0(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2a53c(%rip), %rsi     # 0x52a1a
callq 0x4380
movq %rax, %rdi
movq 0x3dac3(%rip), %rsi     # 0x65fb0
callq 0x43c0
xorl %edi, %edi
callq 0x4460
movb $0x0, -0x13d(%rbp)
movl $0x0, -0x190(%rbp)
movq -0x2e8(%rbp), %rdi
movslq -0x190(%rbp), %rax
movq %rax, -0x3f8(%rbp)
addq $0x258, %rdi            # imm = 0x258
callq 0x22d60
movq %rax, %rcx
movq -0x3f8(%rbp), %rax
cmpq %rcx, %rax
jae 0x28a8b
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movl 0x42c(%rax), %eax
movl %eax, -0x3fc(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movq %rax, %rcx
movl -0x3fc(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x42c(%rcx), %eax
jne 0x28a75
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
cmpl $0x1, 0x430(%rax)
jbe 0x28605
movq -0x2e8(%rbp), %rdi
leaq 0x3e05f(%rip), %rax     # 0x6662c
movl (%rax), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, -0x400(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movl -0x400(%rbp), %ecx
movq (%rax), %rax
addl 0x430(%rax), %ecx
movl %ecx, 0x430(%rax)
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x286d3
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x410(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movq -0x410(%rbp), %rcx
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq %rcx, 0x8(%rax)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq 0x450(%rax), %rax
movq %rax, -0x408(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movq -0x408(%rbp), %rcx
movq (%rax), %rax
movq %rcx, 0x450(%rax)
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, -0x194(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movq %rax, -0x418(%rbp)
cmpq $0x0, %rax
je 0x28733
movq -0x418(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x420(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x1b0(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x29a20
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x29a60
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x1d0(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x29a20
movq %rax, -0x1c8(%rbp)
movslq -0x194(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x29a20
movq %rax, -0x1c0(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x29a60
movq -0x420(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
callq 0x29960
movq %rax, -0x1d8(%rbp)
movb $0x1, -0x13d(%rbp)
testb $0x1, -0x13e(%rbp)
je 0x28a64
movl $0x468, %edi            # imm = 0x468
callq 0x4390
movq -0x2e8(%rbp), %rdi
movq %rax, -0x428(%rbp)
movq %rax, -0x430(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movq -0x428(%rbp), %rdi
movq (%rax), %rsi
callq 0x43ff0
jmp 0x28863
movq -0x2e8(%rbp), %rdi
movq -0x430(%rbp), %rax
movq %rax, -0x1e0(%rbp)
addq $0x258, %rdi            # imm = 0x258
movslq -0x190(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movq %rax, -0x438(%rbp)
cmpq $0x0, %rax
je 0x288a8
movq -0x438(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x258, %rax            # imm = 0x258
movq %rax, -0x448(%rbp)
addq $0x258, %rdi            # imm = 0x258
callq 0x299f0
movq %rax, -0x1f8(%rbp)
movslq -0x190(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x29a20
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x29a60
movq -0x448(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
callq 0x29e80
movq -0x2e8(%rbp), %rdi
movq %rax, -0x200(%rbp)
movq -0x1e0(%rbp), %rax
movb $0x0, 0x422(%rax)
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x440(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x210(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x29a60
movq -0x440(%rbp), %rdi
movq -0x208(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x29aa0
movq %rax, -0x218(%rbp)
movl $0x1, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movq -0x1e0(%rbp), %rcx
cmpl 0x430(%rcx), %eax
jae 0x28a62
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x450(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x238(%rbp)
leaq -0x238(%rbp), %rdi
movl $0x1, %esi
callq 0x29a20
movq %rax, -0x230(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x29a60
movq -0x450(%rbp), %rdi
movq $0x0, -0x240(%rbp)
movq -0x228(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0x29ca0
movq %rax, -0x248(%rbp)
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x2898f
movq -0x430(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
movl $0x468, %esi            # imm = 0x468
callq 0x43a0
jmp 0x28f80
jmp 0x28a73
movl -0x13c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x28a8b
jmp 0x28a77
movl -0x190(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x190(%rbp)
jmp 0x2850a
testb $0x1, -0x13d(%rbp)
jne 0x28bd7
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x258, %rax            # imm = 0x258
movq %rax, -0x460(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x460(%rbp), %rdi
movq %rax, %rsi
callq 0x29ef0
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x458(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x260(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x260(%rbp), %rdi
callq 0x29a20
movq %rax, -0x258(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x29a60
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x280(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x280(%rbp), %rdi
callq 0x29a20
movq -0x2e8(%rbp), %rdi
movq %rax, -0x278(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, %esi
leaq -0x278(%rbp), %rdi
callq 0x29a20
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x29a60
movq -0x458(%rbp), %rdi
movq -0x250(%rbp), %rsi
movq -0x268(%rbp), %rdx
callq 0x29960
movq %rax, -0x288(%rbp)
movl -0x13c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x28f53
movl $0x0, -0x28c(%rbp)
movl -0x28c(%rbp), %eax
leaq 0x3d955(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x28f51
movq -0x2e8(%rbp), %rsi
movq %rsi, %rdi
addq $0x238, %rdi            # imm = 0x238
addq $0x220, %rsi            # imm = 0x220
callq 0x40270
movl %eax, -0x290(%rbp)
cmpl $-0x1, -0x290(%rbp)
jne 0x28c2c
jmp 0x28f3b
movq -0x2e8(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x290(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x0, 0x200(%rax)
je 0x28c7d
movq -0x2e8(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x290(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0xb, 0x200(%rax)
je 0x28c7d
jmp 0x28f3d
movq -0x2e8(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
movslq -0x290(%rbp), %rsi
callq 0x17770
movq -0x2e8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x468(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x468(%rbp), %rdi
movq (%rax), %rsi
callq 0x29f60
testb $0x1, %al
jne 0x28cd3
jmp 0x28f35
leaq 0x3d84e(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x28e2d
leaq 0x3d83f(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x28e2d
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x294(%rbp)
movl -0x294(%rbp), %esi
movq 0x3d2c0(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x488(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x488(%rbp), %rdi
movb %al, -0x295(%rbp)
movzbl -0x295(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x480(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x480(%rbp), %rdi
movl %eax, -0x29c(%rbp)
movl -0x29c(%rbp), %esi
callq 0x4440
movq %rax, -0x478(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x478(%rbp), %rdi
movb %al, -0x29d(%rbp)
movzbl -0x29d(%rbp), %esi
callq 0x4550
movq -0x2e8(%rbp), %rdi
movq %rax, -0x470(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq -0x470(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x2a112(%rip), %rsi     # 0x52ef1
callq 0x4380
movq %rax, %rdi
movl -0x290(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x2a11a(%rip), %rsi     # 0x52f16
callq 0x4380
movq %rax, %rdi
movl -0x290(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x2b560(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x3d188(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0x2e8(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x490(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x2b8(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x2b8(%rbp), %rdi
callq 0x29a20
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x29a60
movq -0x2e8(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x2d8(%rbp)
movslq -0x13c(%rbp), %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x29a20
movq -0x2e8(%rbp), %rdi
movq %rax, -0x2d0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
movslq -0x13c(%rbp), %rsi
callq 0x29940
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, %esi
leaq -0x2d0(%rbp), %rdi
callq 0x29a20
movq %rax, -0x2c8(%rbp)
leaq -0x2c0(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x29a60
movq -0x490(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
movq -0x2c0(%rbp), %rdx
callq 0x29960
movq %rax, -0x2e0(%rbp)
movl -0x13c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x28f51
jmp 0x28f37
jmp 0x28f39
jmp 0x28f3b
jmp 0x28f3d
movl -0x28c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28c(%rbp)
jmp 0x28be6
jmp 0x28f53
jmp 0x28f55
jmp 0x28f57
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x27f74
movq -0x2e8(%rbp), %rdi
callq 0x2a030
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x4630
nopl (%rax)