// File: estwings57[P]CasHMC/sources/VaultController.cpp
// Function: CasHMC::VaultController::ConvPacketIntoCMDs(CasHMC::Packet*)
bool VaultController::ConvPacketIntoCMDs(Packet *packet)
{
	unsigned bankAdd, colAdd, rowAdd;
	AddressMapping(packet->ADRS, bankAdd, colAdd, rowAdd);
	
	DRAMCommandType tempCMD;
	bool tempPosted = false;
	bool atomic = false;
	switch(packet->CMD) {
		//Write
		case WR16:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR32:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR48:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR64:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR80:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR96:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR112:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR128:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case WR256:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		case MD_WR:		tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	break;
		//Poseted Write
		case P_WR16:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR32:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR48:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR64:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR80:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR96:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR112:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR128:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		case P_WR256:	tempCMD = OPEN_PAGE ? WRITE : WRITE_P;	tempPosted = true;	break;
		//Read
		case RD16:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD32:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD48:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD64:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD80:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD96:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD112:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD128:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case RD256:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		case MD_RD:		tempCMD = OPEN_PAGE ? READ : READ_P;	break;
		//Arithmetic atomic
		case _2ADD8:	atomic = true;	tempCMD = READ;	break;
		case ADD16:		atomic = true;	tempCMD = READ;	break;
		case P_2ADD8:	atomic = true;	tempCMD = READ;	tempPosted = true;	break;
		case P_ADD16:	atomic = true;	tempCMD = READ;	tempPosted = true;	break;
		case _2ADDS8R:	atomic = true;	tempCMD = READ;	break;
		case ADDS16R:	atomic = true;	tempCMD = READ;	break;
		case INC8:		atomic = true;	tempCMD = READ;	break;
		case P_INC8:	atomic = true;	tempCMD = READ;	tempPosted = true;	break;
		//Boolean atomic
		case XOR16:		atomic = true;	tempCMD = READ;	break;
		case OR16:		atomic = true;	tempCMD = READ;	break;
		case NOR16:		atomic = true;	tempCMD = READ;	break;
		case AND16:		atomic = true;	tempCMD = READ;	break;
		case NAND16:	atomic = true;	tempCMD = READ;	break;
		//Comparison atomic
		case CASGT8:	atomic = true;	tempCMD = READ;	break;
		case CASLT8:	atomic = true;	tempCMD = READ;	break;
		case CASGT16:	atomic = true;	tempCMD = READ;	break;
		case CASLT16:	atomic = true;	tempCMD = READ;	break;
		case CASEQ8:	atomic = true;	tempCMD = READ;	break;
		case CASZERO16:	atomic = true;	tempCMD = READ;	break;
		case EQ16:		atomic = true;	tempCMD = READ;	break;
		case EQ8:		atomic = true;	tempCMD = READ;	break;
		//Bitwise atomic
		case BWR:		atomic = true;	tempCMD = READ;	break;
		case P_BWR:		atomic = true;	tempCMD = READ;	tempPosted = true;	break;
		case BWR8R:		atomic = true;	tempCMD = READ;	break;
		case SWAP16:	atomic = true;	tempCMD = READ;	break;
		
		default:
			ERROR(header<<"  == Error - WRONG packet command type  (CurrentClock : "<<currentClockCycle<<")");
			exit(0);
	}
	
	//Due to the internal 32-byte granularity of the DRAM data bus within each vault in the HMC (HMC spec v2.1 p.99)
	if(commandQueue->AvailableSpace(bankAdd, ceil((double)packet->reqDataSize/32)+1)) {
		DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<"Down) phyAdd : 0x"<<hex<<setw(9)<<setfill('0')<<packet->ADRS<<dec<<"  bankAdd : "<<bankAdd<<"  colAdd : "<<colAdd<<"  rowAdd : "<<rowAdd);
		//cmdtype, tag, bnk, col, rw, *dt, dSize, pst, *lat
		DRAMCommand *actCMD = new DRAMCommand(ACTIVATE, packet->TAG, bankAdd, colAdd, rowAdd, 0, false, packet->trace, true, packet->CMD, atomic, packet->segment);
		commandQueue->Enqueue(bankAdd, actCMD);
		
		for(int i=0; i<ceil((double)packet->reqDataSize/32); i++) {
			DRAMCommand *rwCMD;
			if(i < ceil((double)packet->reqDataSize/32)-1) {
				if(tempCMD == WRITE_P) {
					rwCMD = new DRAMCommand(WRITE, packet->TAG, bankAdd, colAdd, rowAdd, packet->reqDataSize, tempPosted, packet->trace, false, packet->CMD, atomic, packet->segment);
				}
				else if(tempCMD == READ_P) {
					rwCMD = new DRAMCommand(READ, packet->TAG, bankAdd, colAdd, rowAdd, packet->reqDataSize, tempPosted, packet->trace, false, packet->CMD, atomic, packet->segment);
				}
				else {
					rwCMD = new DRAMCommand(tempCMD, packet->TAG, bankAdd, colAdd, rowAdd, packet->reqDataSize, tempPosted, packet->trace, false, packet->CMD, atomic, packet->segment);
				}
			}
			else {
				rwCMD = new DRAMCommand(tempCMD, packet->TAG, bankAdd, colAdd, rowAdd, packet->reqDataSize, tempPosted, packet->trace, true, packet->CMD, atomic, packet->segment);
			}
			commandQueue->Enqueue(bankAdd, rwCMD);
			if(tempCMD == READ || tempCMD == READ_P) {
				pendingReadData.push_back(packet->TAG);
			}
		}
		return true;
	}
	else{
		return false;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq %rdi, -0x98(%rbp)
movq -0x38(%rbp), %rax
movq 0x450(%rax), %rsi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x4f730
movb $0x0, -0x49(%rbp)
movb $0x0, -0x4a(%rbp)
movq -0x38(%rbp), %rax
movl 0x434(%rax), %eax
addl $-0x8, %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x6f, %eax
ja 0x4eed0
movq -0x90(%rbp), %rax
leaq 0x5f32(%rip), %rcx      # 0x54878
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x17cdb(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17cba(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17c99(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17c78(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17c57(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17c36(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17c15(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17bf4(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17bd3(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17bb2(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17b91(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17b6c(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17b47(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17b22(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17afd(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17ad8(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17ab3(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17a8e(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17a69(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x4, %eax
movl $0x3, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
leaq 0x17a44(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17a23(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x17a02(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x179e1(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x179c0(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x1799f(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x1797e(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x1795d(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x1793c(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
leaq 0x1791b(%rip), %rax     # 0x66631
movb (%rax), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movb $0x1, -0x4a(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x4ef77
movq 0x17119(%rip), %rdi     # 0x65ff0
leaq 0x215c(%rip), %rsi      # 0x5103a
callq 0x4380
movq %rax, %rdi
leaq 0x5bc3(%rip), %rsi      # 0x54ab0
callq 0x4380
movq %rax, %rdi
leaq 0x2939(%rip), %rsi      # 0x51835
callq 0x4380
movq %rax, %rdi
movl $0x1b3, %esi            # imm = 0x1B3
callq 0x4610
movq %rax, %rdi
leaq 0x2141(%rip), %rsi      # 0x51059
callq 0x4380
movq -0x98(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x5eec(%rip), %rsi      # 0x54e26
callq 0x4380
movq %rax, %rdi
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x541d(%rip), %rsi      # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x17045(%rip), %rsi     # 0x65fb0
callq 0x43c0
xorl %edi, %edi
callq 0x4460
movq -0x98(%rbp), %rax
movq 0x218(%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x38(%rbp), %rax
movl 0x424(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x58bc(%rip), %xmm1     # 0x54868
mulsd %xmm1, %xmm0
callq 0x40a0
movq -0xa8(%rbp), %rdi
movl -0x9c(%rbp), %esi
movsd 0x20e6(%rip), %xmm1     # 0x510b0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %edx
callq 0x1cd00
testb $0x1, %al
jne 0x4efe3
jmp 0x4f639
leaq 0x1753e(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x4f18d
leaq 0x1752f(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x4f18d
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %esi
movq 0x16fb6(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0xd0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0xd0(%rbp), %rdi
movb %al, -0x51(%rbp)
movzbl -0x51(%rbp), %esi
callq 0x4550
movq -0x98(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0xc8(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0xc8(%rbp), %rdi
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %esi
callq 0x4440
movq %rax, -0xc0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0xc0(%rbp), %rdi
movb %al, -0x59(%rbp)
movzbl -0x59(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x5dac(%rip), %rsi      # 0x54e5f
callq 0x4380
movq %rax, %rdi
leaq -0xb752(%rip), %rsi     # 0x43970
callq 0x4150
movq %rax, -0xb8(%rbp)
movl $0x9, %edi
callq 0x177b0
movq -0xb8(%rbp), %rdi
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %esi
callq 0x4440
movq %rax, -0xb0(%rbp)
movl $0x30, %edi
callq 0x177d0
movq -0xb0(%rbp), %rdi
movb %al, -0x61(%rbp)
movzbl -0x61(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x38(%rbp), %rax
movq 0x450(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq -0xb78b(%rip), %rsi     # 0x439a0
callq 0x4150
movq %rax, %rdi
leaq 0x5d37(%rip), %rsi      # 0x54e71
callq 0x4380
movq %rax, %rdi
movl -0x3c(%rbp), %esi
callq 0x44c0
movq %rax, %rdi
leaq 0x5d2a(%rip), %rsi      # 0x54e7e
callq 0x4380
movq %rax, %rdi
movl -0x40(%rbp), %esi
callq 0x44c0
movq %rax, %rdi
leaq 0x5d1c(%rip), %rsi      # 0x54e8a
callq 0x4380
movq %rax, %rdi
movl -0x44(%rbp), %esi
callq 0x44c0
movq %rax, %rdi
movq 0x16e28(%rip), %rsi     # 0x65fb0
callq 0x43c0
movl $0x38, %edi
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
movq -0x38(%rbp), %rax
movl 0x42c(%rax), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl -0x44(%rbp), %r9d
movq 0x8(%rax), %rsi
movl 0x434(%rax), %r10d
movzbl 0x422(%rax), %ebx
movzbl -0x4a(%rbp), %r11d
andl $0x1, %ebx
movq %rsp, %rax
movl %ebx, 0x30(%rax)
andl $0x1, %r11d
movl %r11d, 0x28(%rax)
movl %r10d, 0x20(%rax)
movq %rsi, 0x10(%rax)
movl $0x1, 0x18(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
xorl %esi, %esi
callq 0x30d90
jmp 0x4f206
movq -0x98(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, -0x70(%rbp)
movq 0x218(%rax), %rdi
movl -0x3c(%rbp), %esi
movq -0x70(%rbp), %rdx
callq 0x1cdd0
movl $0x0, -0x80(%rbp)
cvtsi2sdl -0x80(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movq -0x38(%rbp), %rax
movl 0x424(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x561a(%rip), %xmm1     # 0x54870
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0xe0(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x4f633
cvtsi2sdl -0x80(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movq -0x38(%rbp), %rax
movl 0x424(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x55db(%rip), %xmm1     # 0x54870
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0xe8(%rbp), %xmm1
movsd 0x1e02(%rip), %xmm2     # 0x510b0
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4f526
cmpl $0x4, -0x48(%rbp)
jne 0x4f3a2
movl $0x38, %edi
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq -0x38(%rbp), %rax
movl 0x42c(%rax), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl -0x44(%rbp), %r9d
movl 0x424(%rax), %esi
movq 0x8(%rax), %r11
movl 0x434(%rax), %ebx
movzbl 0x422(%rax), %r15d
movzbl -0x49(%rbp), %r10d
movzbl -0x4a(%rbp), %r14d
andl $0x1, %r15d
movq %rsp, %rax
movl %r15d, 0x30(%rax)
andl $0x1, %r14d
movl %r14d, 0x28(%rax)
movl %ebx, 0x20(%rax)
movq %r11, 0x10(%rax)
andl $0x1, %r10d
movl %r10d, 0x8(%rax)
movl %esi, (%rax)
movl $0x0, 0x18(%rax)
movl $0x3, %esi
callq 0x30d90
jmp 0x4f34b
movq -0xf0(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x4f521
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x38, %esi
callq 0x43a0
jmp 0x4f652
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x38, %esi
callq 0x43a0
jmp 0x4f652
cmpl $0x2, -0x48(%rbp)
jne 0x4f466
movl $0x38, %edi
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
movq -0x38(%rbp), %rax
movl 0x42c(%rax), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl -0x44(%rbp), %r9d
movl 0x424(%rax), %esi
movq 0x8(%rax), %r11
movl 0x434(%rax), %ebx
movzbl 0x422(%rax), %r15d
movzbl -0x49(%rbp), %r10d
movzbl -0x4a(%rbp), %r14d
andl $0x1, %r15d
movq %rsp, %rax
movl %r15d, 0x30(%rax)
andl $0x1, %r14d
movl %r14d, 0x28(%rax)
movl %ebx, 0x20(%rax)
movq %r11, 0x10(%rax)
andl $0x1, %r10d
movl %r10d, 0x8(%rax)
movl %esi, (%rax)
movl $0x0, 0x18(%rax)
movl $0x1, %esi
callq 0x30d90
jmp 0x4f431
movq -0xf8(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x4f51f
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x38, %esi
callq 0x43a0
jmp 0x4f652
movl $0x38, %edi
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movl -0x48(%rbp), %esi
movq -0x38(%rbp), %rax
movl 0x42c(%rax), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl -0x44(%rbp), %r9d
movl 0x424(%rax), %r10d
movq 0x8(%rax), %rbx
movl 0x434(%rax), %r14d
movzbl 0x422(%rax), %r12d
movzbl -0x49(%rbp), %r11d
movzbl -0x4a(%rbp), %r15d
andl $0x1, %r12d
movq %rsp, %rax
movl %r12d, 0x30(%rax)
andl $0x1, %r15d
movl %r15d, 0x28(%rax)
movl %r14d, 0x20(%rax)
movq %rbx, 0x10(%rax)
andl $0x1, %r11d
movl %r11d, 0x8(%rax)
movl %r10d, (%rax)
movl $0x0, 0x18(%rax)
callq 0x30d90
jmp 0x4f4ed
movq -0x100(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x4f51f
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x38, %esi
callq 0x43a0
jmp 0x4f652
jmp 0x4f521
jmp 0x4f5dc
movl $0x38, %edi
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movl -0x48(%rbp), %esi
movq -0x38(%rbp), %rax
movl 0x42c(%rax), %edx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
movl -0x44(%rbp), %r9d
movl 0x424(%rax), %r10d
movq 0x8(%rax), %rbx
movl 0x434(%rax), %r14d
movzbl 0x422(%rax), %r12d
movzbl -0x49(%rbp), %r11d
movzbl -0x4a(%rbp), %r15d
andl $0x1, %r12d
movq %rsp, %rax
movl %r12d, 0x30(%rax)
andl $0x1, %r15d
movl %r15d, 0x28(%rax)
movl %r14d, 0x20(%rax)
movq %rbx, 0x10(%rax)
andl $0x1, %r11d
movl %r11d, 0x8(%rax)
movl %r10d, (%rax)
movl $0x1, 0x18(%rax)
callq 0x30d90
jmp 0x4f5ad
movq -0x108(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x4f5dc
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x38, %esi
callq 0x43a0
jmp 0x4f652
movq -0x98(%rbp), %rax
movq 0x218(%rax), %rdi
movl -0x3c(%rbp), %esi
movq -0x88(%rbp), %rdx
callq 0x1cdd0
cmpl $0x1, -0x48(%rbp)
je 0x4f605
cmpl $0x2, -0x48(%rbp)
jne 0x4f623
movq -0x98(%rbp), %rdi
addq $0x238, %rdi            # imm = 0x238
movq -0x38(%rbp), %rsi
addq $0x42c, %rsi            # imm = 0x42C
callq 0x19ee0
jmp 0x4f625
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x4f232
movb $0x1, -0x21(%rbp)
jmp 0x4f63d
movb $0x0, -0x21(%rbp)
movb -0x21(%rbp), %al
andb $0x1, %al
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x4630
nopl (%rax,%rax)