// File: dramninjasUMD[P]BOBSim/BOB.cpp
// Function: BOBSim::BOB::BOB()
BOB::BOB() : priorityPort(0),
	readCounter(0),
	writeCounter(0),
	committedWrites(0),
	clockCycleAdjustmentCounter(0),
	writeIssuedCB(NULL),
	rankBitWidth(log2(NUM_RANKS)),
	bankBitWidth(log2(NUM_BANKS)),
	rowBitWidth(log2(NUM_ROWS)),
	colBitWidth(log2(NUM_COLS)),
	busOffsetBitWidth(log2(BUS_ALIGNMENT_SIZE)),
	channelBitWidth(log2(NUM_CHANNELS)),
	cacheOffset(log2(CACHE_LINE_SIZE))
{
	/*
	  HACK!!! - QEMU does not support the huge memory sizes BOB can simulate.
	  Removing bits from the row address will have the least impact on function
	*/
	uint qemuMemoryBitWidth = log2_64(QEMU_MEMORY_SIZE);
	uint bitDifference = (busOffsetBitWidth + colBitWidth + rowBitWidth + channelBitWidth + rankBitWidth + bankBitWidth) - qemuMemoryBitWidth;
	rowBitWidth = rowBitWidth - bitDifference;
	//end hack


#ifdef LOG_OUTPUT
	string output_filename("BOBsim");
	if (getenv("SIM_DESC"))
		output_filename += getenv("SIM_DESC");
	output_filename += VARIANT_SUFFIX;
	output_filename += ".log";
	logOutput.open(output_filename.c_str());
#endif
	DEBUG("!!!!!!! QEMU_MEMORY_SIZE :"<<QEMU_MEMORY_SIZE<<" qemuMemoryBitWidth : "<<qemuMemoryBitWidth<<"   newRowBitWidth : "<<rowBitWidth<<"\n");
	DEBUG("busoff:"<<busOffsetBitWidth<<" col:"<<colBitWidth<<" row:"<<rowBitWidth<<" rank:"<<rankBitWidth<<" bank:"<<bankBitWidth<<" chan:"<<channelBitWidth);

	currentClockCycle = 0;

	//Compute ratios of various clock frequencies 
	if(fmod(CPU_CLK_PERIOD,LINK_BUS_CLK_PERIOD)>0.00001)
	{		
		ERROR("== ERROR - Link bus clock period ("<<LINK_BUS_CLK_PERIOD<<") must be a factor of CPU clock period ("<<CPU_CLK_PERIOD<<")");
		ERROR("==         fmod="<<fmod(CPU_CLK_PERIOD,LINK_BUS_CLK_PERIOD));
		abort(); 
	}

	LINK_CPU_CLK_RATIO = (CPU_CLK_PERIOD / LINK_BUS_CLK_PERIOD);
	cout<<"Channel to CPU ratio : "<<LINK_CPU_CLK_RATIO<<endl;
	DRAM_CPU_CLK_RATIO = tCK / CPU_CLK_PERIOD;
	cout<<"DRAM to CPU ratio : "<<DRAM_CPU_CLK_RATIO<<endl;
	DRAM_CPU_CLK_ADJUSTMENT = tCK / fmod(tCK,CPU_CLK_PERIOD);
	cout<<"DRAM_CPU_CLK_ADJUSTMENT : "<<DRAM_CPU_CLK_ADJUSTMENT<<endl;

	//Ensure that parameters have been set correclty
	if(NUM_CHANNELS / CHANNELS_PER_LINK_BUS != NUM_LINK_BUSES)
	{
		ERROR("== ERROR - Mismatch in NUM_CHANNELS and NUM_LINK_BUSES");
		exit(0);
	}

	if(DEBUG_BOB) DEBUG("== Channel-CPU clk ratio : "<<LINK_CPU_CLK_RATIO<<"  DRAM-CPU clk ratio : "<<DRAM_CPU_CLK_RATIO);

	//Make port objects
	for(unsigned i=0; i<NUM_PORTS; i++)
	{
		ports.push_back(Port(i));
	}

	//Initialize fields for bookkeeping
	inFlightRequestLinkCountdowns = vector<unsigned>(NUM_LINK_BUSES,0);
	inFlightResponseLinkCountdowns = vector<unsigned>(NUM_LINK_BUSES,0);

	inFlightRequestLink = vector<Transaction *> (NUM_LINK_BUSES, (Transaction*)(NULL));
	inFlightResponseLink = vector<Transaction *> (NUM_LINK_BUSES, (Transaction*)NULL);

	serDesBufferRequest = vector<Transaction *> (NUM_LINK_BUSES, (Transaction*)NULL);
	serDesBufferResponse = vector<Transaction *> (NUM_LINK_BUSES, (Transaction*)NULL);

	responseLinkRoundRobin = vector<unsigned> (NUM_LINK_BUSES,0);

	channelCounters = vector<unsigned>(NUM_CHANNELS,0);
	channelCountersLifetime = vector<uint64_t>(NUM_CHANNELS,0);

	portInputBufferAvg = vector<uint> (NUM_PORTS, 0);
	portOutputBufferAvg = vector<uint> (NUM_PORTS, 0);

	requestLinkIdle = vector<unsigned> (NUM_LINK_BUSES,0);
	responseLinkIdle = vector<unsigned> (NUM_LINK_BUSES,0);

	cmdQFull = vector<uint>(NUM_CHANNELS,0);

	//Define callback function
	Callback<BOB, void, BusPacket*, unsigned> *reportCallback = new Callback<BOB, void, BusPacket*, unsigned>(this, &BOB::ReportCallback);

	//Create channels
	channels.reserve(NUM_CHANNELS);
	for(unsigned i=0; i<NUM_CHANNELS; i++)
	{
		channels.push_back(new DRAMChannel(i,reportCallback));
	}

	//Used for round-robin
	priorityLinkBus = vector<unsigned>(NUM_PORTS,0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6e0, %rsp            # imm = 0x6E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
callq 0xb5a0
movq -0x2a8(%rbp), %rdi
leaq 0x33f9b(%rip), %rax     # 0x37a68
movq %rax, (%rdi)
addq $0x10, %rdi
movq %rdi, -0x338(%rbp)
callq 0xb5c0
movq -0x2a8(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0x330(%rbp)
callq 0xb5e0
movq -0x2a8(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x328(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0x320(%rbp)
callq 0xb620
movq -0x2a8(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0x318(%rbp)
callq 0xb640
movq -0x2a8(%rbp), %rdi
addq $0x88, %rdi
movq %rdi, -0x310(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0xa0, %rdi
movq %rdi, -0x308(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0xb8, %rdi
movq %rdi, -0x300(%rbp)
callq 0xb640
movq -0x2a8(%rbp), %rdi
addq $0xd0, %rdi
movq %rdi, -0x2f8(%rbp)
callq 0xb640
movq -0x2a8(%rbp), %rdi
addq $0xe8, %rdi
movq %rdi, -0x2f0(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq %rdi, -0x2e8(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movq %rdi, -0x2e0(%rbp)
callq 0xb640
movq -0x2a8(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
movq %rdi, -0x2d8(%rbp)
callq 0xb640
movq -0x2a8(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
movq %rdi, -0x2d0(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x160, %rdi            # imm = 0x160
movq %rdi, -0x2c8(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
movq %rdi, -0x2c0(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
movl $0x0, 0x190(%rdi)
addq $0x198, %rdi            # imm = 0x198
movq %rdi, -0x2b8(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movq %rdi, -0x2b0(%rbp)
callq 0xb600
movq -0x2a8(%rbp), %rax
movl $0x0, 0x1c8(%rax)
movl $0x0, 0x1cc(%rax)
movl $0x0, 0x1d0(%rax)
movq $0x0, 0x1d8(%rax)
addq $0x1e0, %rax            # imm = 0x1E0
movq %rax, -0x2a0(%rbp)
movl 0x34535(%rip), %edi     # 0x38210
callq 0xb660
movl %eax, -0x294(%rbp)
jmp 0x3ce8
movq -0x2a8(%rbp), %rax
movq -0x2a0(%rbp), %rcx
movl -0x294(%rbp), %edx
movl %edx, (%rcx)
addq $0x1e4, %rax            # imm = 0x1E4
movq %rax, -0x348(%rbp)
movl 0x34503(%rip), %edi     # 0x38214
callq 0xb660
movl %eax, -0x33c(%rbp)
jmp 0x3d1e
movq -0x2a8(%rbp), %rax
movq -0x348(%rbp), %rcx
movl -0x33c(%rbp), %edx
movl %edx, (%rcx)
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x358(%rbp)
movl 0x344d1(%rip), %edi     # 0x38218
callq 0xb660
movl %eax, -0x34c(%rbp)
jmp 0x3d54
movq -0x2a8(%rbp), %rax
movq -0x358(%rbp), %rcx
movl -0x34c(%rbp), %edx
movl %edx, (%rcx)
addq $0x1ec, %rax            # imm = 0x1EC
movq %rax, -0x368(%rbp)
movl 0x344a3(%rip), %edi     # 0x38220
callq 0xb660
movl %eax, -0x35c(%rbp)
jmp 0x3d8a
movq -0x2a8(%rbp), %rax
movq -0x368(%rbp), %rcx
movl -0x35c(%rbp), %edx
movl %edx, (%rcx)
addq $0x1f0, %rax            # imm = 0x1F0
movq %rax, -0x378(%rbp)
movl 0x34475(%rip), %edi     # 0x38228
callq 0xb660
movl %eax, -0x36c(%rbp)
jmp 0x3dc0
movq -0x2a8(%rbp), %rax
movq -0x378(%rbp), %rcx
movl -0x36c(%rbp), %edx
movl %edx, (%rcx)
addq $0x1f4, %rax            # imm = 0x1F4
movq %rax, -0x388(%rbp)
movl 0x34443(%rip), %edi     # 0x3822c
callq 0xb660
movl %eax, -0x37c(%rbp)
jmp 0x3df6
movq -0x2a8(%rbp), %rax
movq -0x388(%rbp), %rcx
movl -0x37c(%rbp), %edx
movl %edx, (%rcx)
addq $0x1f8, %rax            # imm = 0x1F8
movq %rax, -0x398(%rbp)
movl 0x34411(%rip), %edi     # 0x38230
callq 0xb660
movl %eax, -0x38c(%rbp)
jmp 0x3e2c
movq -0x2a8(%rbp), %rax
movq -0x398(%rbp), %rcx
movl -0x38c(%rbp), %edx
movl %edx, (%rcx)
movl $0x0, 0x1fc(%rax)
leaq 0x346dd(%rip), %rax     # 0x38530
movq (%rax), %rdi
callq 0xb6c0
movl %eax, -0x39c(%rbp)
jmp 0x3e63
movq -0x2a8(%rbp), %rax
movl -0x39c(%rbp), %ecx
movl %ecx, -0x18(%rbp)
movl 0x1f0(%rax), %ecx
addl 0x1ec(%rax), %ecx
addl 0x1e8(%rax), %ecx
addl 0x1f4(%rax), %ecx
addl 0x1e0(%rax), %ecx
addl 0x1e4(%rax), %ecx
subl -0x18(%rbp), %ecx
movl %ecx, -0x1c(%rbp)
movl 0x1e8(%rax), %ecx
subl -0x1c(%rbp), %ecx
movl %ecx, 0x1e8(%rax)
leaq 0x344c1(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x3fad
movq 0x34105(%rip), %rdi     # 0x37fc8
leaq 0x261d6(%rip), %rsi     # 0x2a0a0
callq 0x31c0
movq %rax, -0x3a8(%rbp)
jmp 0x3ed8
movq -0x3a8(%rbp), %rdi
leaq 0x3464a(%rip), %rax     # 0x38530
movq (%rax), %rsi
callq 0x3070
movq %rax, -0x3b0(%rbp)
jmp 0x3ef7
movq -0x3b0(%rbp), %rdi
leaq 0x261b6(%rip), %rsi     # 0x2a0bb
callq 0x31c0
movq %rax, -0x3b8(%rbp)
jmp 0x3f13
movq -0x3b8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x32d0
movq %rax, -0x3c0(%rbp)
jmp 0x3f2b
movq -0x3c0(%rbp), %rdi
leaq 0x26199(%rip), %rsi     # 0x2a0d2
callq 0x31c0
movq %rax, -0x3c8(%rbp)
jmp 0x3f47
movq -0x3c8(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1e8(%rax), %esi
callq 0x32d0
movq %rax, -0x3d0(%rbp)
jmp 0x3f69
movq -0x3d0(%rbp), %rdi
leaq 0x269cd(%rip), %rsi     # 0x2a944
callq 0x31c0
movq %rax, -0x3d8(%rbp)
jmp 0x3f85
movq -0x3d8(%rbp), %rdi
movq 0x34015(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x3f9a
jmp 0x3fad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
jmp 0x51e7
leaq 0x343c0(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x4148
movq 0x34004(%rip), %rdi     # 0x37fc8
leaq 0x2611c(%rip), %rsi     # 0x2a0e7
callq 0x31c0
movq %rax, -0x3e0(%rbp)
jmp 0x3fd9
movq -0x3e0(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1f0(%rax), %esi
callq 0x32d0
movq %rax, -0x3e8(%rbp)
jmp 0x3ffb
movq -0x3e8(%rbp), %rdi
leaq 0x260e6(%rip), %rsi     # 0x2a0ef
callq 0x31c0
movq %rax, -0x3f0(%rbp)
jmp 0x4017
movq -0x3f0(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1ec(%rax), %esi
callq 0x32d0
movq %rax, -0x3f8(%rbp)
jmp 0x4039
movq -0x3f8(%rbp), %rdi
leaq 0x260ae(%rip), %rsi     # 0x2a0f5
callq 0x31c0
movq %rax, -0x400(%rbp)
jmp 0x4055
movq -0x400(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1e8(%rax), %esi
callq 0x32d0
movq %rax, -0x408(%rbp)
jmp 0x4077
movq -0x408(%rbp), %rdi
leaq 0x26076(%rip), %rsi     # 0x2a0fb
callq 0x31c0
movq %rax, -0x410(%rbp)
jmp 0x4093
movq -0x410(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1e0(%rax), %esi
callq 0x32d0
movq %rax, -0x418(%rbp)
jmp 0x40b5
movq -0x418(%rbp), %rdi
leaq 0x2603f(%rip), %rsi     # 0x2a102
callq 0x31c0
movq %rax, -0x420(%rbp)
jmp 0x40d1
movq -0x420(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1e4(%rax), %esi
callq 0x32d0
movq %rax, -0x428(%rbp)
jmp 0x40f3
movq -0x428(%rbp), %rdi
leaq 0x26008(%rip), %rsi     # 0x2a109
callq 0x31c0
movq %rax, -0x430(%rbp)
jmp 0x410f
movq -0x430(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl 0x1f4(%rax), %esi
callq 0x32d0
movq %rax, -0x438(%rbp)
jmp 0x4131
movq -0x438(%rbp), %rdi
movq 0x33e69(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x4146
jmp 0x4148
movq -0x2a8(%rbp), %rax
movq $0x0, 0x8(%rax)
movss 0x340d5(%rip), %xmm0    # 0x38234
movss 0x340d1(%rip), %xmm1    # 0x38238
callq 0xb720
movss %xmm0, -0x43c(%rbp)
jmp 0x4176
movss -0x43c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x25e7e(%rip), %xmm1    # 0x2a008
ucomisd %xmm1, %xmm0
jbe 0x43bd
movq 0x33e55(%rip), %rdi     # 0x37ff0
leaq 0x25f6e(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, -0x448(%rbp)
jmp 0x41b0
movq -0x448(%rbp), %rdi
leaq 0x25f5b(%rip), %rsi     # 0x2a119
callq 0x31c0
movq %rax, -0x450(%rbp)
jmp 0x41cc
movq -0x450(%rbp), %rdi
leaq 0x25edf(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, -0x458(%rbp)
jmp 0x41e8
movq -0x458(%rbp), %rdi
movl $0x58, %esi
callq 0x3380
movq %rax, -0x460(%rbp)
jmp 0x4202
movq -0x460(%rbp), %rdi
leaq 0x25f11(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, -0x468(%rbp)
jmp 0x421e
movq -0x468(%rbp), %rdi
leaq 0x25efa(%rip), %rsi     # 0x2a126
callq 0x31c0
movq %rax, -0x470(%rbp)
jmp 0x423a
movq -0x470(%rbp), %rdi
movss 0x33fef(%rip), %xmm0    # 0x38238
callq 0x3140
movq %rax, -0x478(%rbp)
jmp 0x4257
movq -0x478(%rbp), %rdi
leaq 0x25ee4(%rip), %rsi     # 0x2a149
callq 0x31c0
movq %rax, -0x480(%rbp)
jmp 0x4273
movq -0x480(%rbp), %rdi
movss 0x33fb2(%rip), %xmm0    # 0x38234
callq 0x3140
movq %rax, -0x488(%rbp)
jmp 0x4290
movq -0x488(%rbp), %rdi
leaq 0x26534(%rip), %rsi     # 0x2a7d2
callq 0x31c0
movq %rax, -0x490(%rbp)
jmp 0x42ac
movq -0x490(%rbp), %rdi
movq 0x33cee(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x42c1
movq 0x33d28(%rip), %rdi     # 0x37ff0
leaq 0x25e41(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, -0x498(%rbp)
jmp 0x42dd
movq -0x498(%rbp), %rdi
leaq 0x25e2e(%rip), %rsi     # 0x2a119
callq 0x31c0
movq %rax, -0x4a0(%rbp)
jmp 0x42f9
movq -0x4a0(%rbp), %rdi
leaq 0x25db2(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, -0x4a8(%rbp)
jmp 0x4315
movq -0x4a8(%rbp), %rdi
movl $0x59, %esi
callq 0x3380
movq %rax, -0x4b0(%rbp)
jmp 0x432f
movq -0x4b0(%rbp), %rdi
leaq 0x25de4(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, -0x4b8(%rbp)
jmp 0x434b
movq -0x4b8(%rbp), %rdi
leaq 0x25e19(%rip), %rsi     # 0x2a172
callq 0x31c0
movq %rax, -0x4c0(%rbp)
jmp 0x4367
movss 0x33ec5(%rip), %xmm0    # 0x38234
movss 0x33ec1(%rip), %xmm1    # 0x38238
callq 0xb720
movss %xmm0, -0x4c4(%rbp)
jmp 0x4386
movss -0x4c4(%rbp), %xmm0
movq -0x4c0(%rbp), %rdi
callq 0x3140
movq %rax, -0x4d0(%rbp)
jmp 0x43a3
movq -0x4d0(%rbp), %rdi
movq 0x33bf7(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x43b8
callq 0x30f0
movss 0x33e6f(%rip), %xmm0    # 0x38234
movss 0x33e6b(%rip), %xmm1    # 0x38238
divss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movl %eax, 0x3413c(%rip)     # 0x38518
movq 0x33be5(%rip), %rdi     # 0x37fc8
leaq 0x25d99(%rip), %rsi     # 0x2a183
callq 0x31c0
movq %rax, -0x4d8(%rbp)
jmp 0x43f8
movq -0x4d8(%rbp), %rdi
movl 0x34113(%rip), %esi     # 0x38518
callq 0x32d0
movq %rax, -0x4e0(%rbp)
jmp 0x4413
movq -0x4e0(%rbp), %rdi
movq 0x33b87(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x4428
movss 0x33e0c(%rip), %xmm0    # 0x3823c
movss 0x33dfc(%rip), %xmm1    # 0x38234
divss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movl %eax, 0x340d5(%rip)     # 0x3851c
movq 0x33b7a(%rip), %rdi     # 0x37fc8
leaq 0x25d46(%rip), %rsi     # 0x2a19b
callq 0x31c0
movq %rax, -0x4e8(%rbp)
jmp 0x4463
movq -0x4e8(%rbp), %rdi
movl 0x340ac(%rip), %esi     # 0x3851c
callq 0x32d0
movq %rax, -0x4f0(%rbp)
jmp 0x447e
movq -0x4f0(%rbp), %rdi
movq 0x33b1c(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x4493
movss 0x33da1(%rip), %xmm0    # 0x3823c
movss %xmm0, -0x4f8(%rbp)
movss 0x33d89(%rip), %xmm1    # 0x38234
callq 0xb720
movss %xmm0, -0x4f4(%rbp)
jmp 0x44ba
movss -0x4f4(%rbp), %xmm1
movss -0x4f8(%rbp), %xmm0
divss %xmm1, %xmm0
cvttss2si %xmm0, %rax
movl %eax, 0x34047(%rip)     # 0x38520
movq 0x33ae8(%rip), %rdi     # 0x37fc8
leaq 0x25cc9(%rip), %rsi     # 0x2a1b0
callq 0x31c0
movq %rax, -0x500(%rbp)
jmp 0x44f5
movq -0x500(%rbp), %rdi
movl 0x3401e(%rip), %esi     # 0x38520
callq 0x32d0
movq %rax, -0x508(%rbp)
jmp 0x4510
movq -0x508(%rbp), %rdi
movq 0x33a8a(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x4525
movl 0x33d01(%rip), %eax     # 0x3822c
xorl %edx, %edx
divl 0x33d0d(%rip)           # 0x38240
cmpl 0x33d0b(%rip), %eax     # 0x38244
je 0x4601
movq 0x33aaa(%rip), %rdi     # 0x37ff0
leaq 0x25bc3(%rip), %rsi     # 0x2a110
callq 0x31c0
movq %rax, -0x510(%rbp)
jmp 0x455b
movq -0x510(%rbp), %rdi
leaq 0x25bb0(%rip), %rsi     # 0x2a119
callq 0x31c0
movq %rax, -0x518(%rbp)
jmp 0x4577
movq -0x518(%rbp), %rdi
leaq 0x25b34(%rip), %rsi     # 0x2a0b9
callq 0x31c0
movq %rax, -0x520(%rbp)
jmp 0x4593
movq -0x520(%rbp), %rdi
movl $0x67, %esi
callq 0x3380
movq %rax, -0x528(%rbp)
jmp 0x45ad
movq -0x528(%rbp), %rdi
leaq 0x25b66(%rip), %rsi     # 0x2a121
callq 0x31c0
movq %rax, -0x530(%rbp)
jmp 0x45c9
movq -0x530(%rbp), %rdi
leaq 0x25bf4(%rip), %rsi     # 0x2a1cb
callq 0x31c0
movq %rax, -0x538(%rbp)
jmp 0x45e5
movq -0x538(%rbp), %rdi
movq 0x339b5(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x45fa
xorl %edi, %edi
callq 0x3270
testb $0x1, 0x33f1c(%rip)     # 0x38524
je 0x46a5
leaq 0x33d5f(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x46a3
movq 0x339a3(%rip), %rdi     # 0x37fc8
leaq 0x25bd6(%rip), %rsi     # 0x2a202
callq 0x31c0
movq %rax, -0x540(%rbp)
jmp 0x463a
movq -0x540(%rbp), %rdi
movl 0x33ed1(%rip), %esi     # 0x38518
callq 0x32d0
movq %rax, -0x548(%rbp)
jmp 0x4655
movq -0x548(%rbp), %rdi
leaq 0x25bbb(%rip), %rsi     # 0x2a21e
callq 0x31c0
movq %rax, -0x550(%rbp)
jmp 0x4671
movq -0x550(%rbp), %rdi
movl 0x33e9e(%rip), %esi     # 0x3851c
callq 0x32d0
movq %rax, -0x558(%rbp)
jmp 0x468c
movq -0x558(%rbp), %rdi
movq 0x3390e(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x46a1
jmp 0x46a3
jmp 0x46a5
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
leaq 0x33cba(%rip), %rcx     # 0x38370
cmpl (%rcx), %eax
jae 0x471a
movq -0x2a8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x560(%rbp)
movl -0x20(%rbp), %esi
leaq -0x60(%rbp), %rdi
callq 0x1ffd0
jmp 0x46da
movq -0x560(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xb750
jmp 0x46ec
leaq -0x60(%rbp), %rdi
callq 0xb780
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x46ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xb780
jmp 0x51e7
movl 0x33b24(%rip), %eax     # 0x38244
movq %rax, -0x570(%rbp)
movl $0x0, -0x7c(%rbp)
leaq -0x7d(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0xb7b0
movq -0x570(%rbp), %rsi
movq -0x568(%rbp), %rcx
leaq -0x78(%rbp), %rdi
leaq -0x7c(%rbp), %rdx
callq 0xb7d0
jmp 0x475b
movq -0x2a8(%rbp), %rdi
addq $0xe8, %rdi
leaq -0x78(%rbp), %rsi
movq %rsi, -0x588(%rbp)
callq 0xb850
movq -0x588(%rbp), %rdi
callq 0xb880
leaq -0x7d(%rbp), %rdi
callq 0xb8e0
movl 0x33ab0(%rip), %eax     # 0x38244
movq %rax, -0x580(%rbp)
movl $0x0, -0x9c(%rbp)
leaq -0x9d(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0xb7b0
movq -0x580(%rbp), %rsi
movq -0x578(%rbp), %rcx
leaq -0x98(%rbp), %rdi
leaq -0x9c(%rbp), %rdx
callq 0xb7d0
jmp 0x47db
movq -0x2a8(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
leaq -0x98(%rbp), %rsi
movq %rsi, -0x5a0(%rbp)
callq 0xb850
movq -0x5a0(%rbp), %rdi
callq 0xb880
leaq -0x9d(%rbp), %rdi
callq 0xb8e0
movl 0x33a2a(%rip), %eax     # 0x38244
movq %rax, -0x598(%rbp)
movq $0x0, -0xc0(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0xb900
movq -0x598(%rbp), %rsi
movq -0x590(%rbp), %rcx
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0xb920
jmp 0x4862
movq -0x2a8(%rbp), %rdi
addq $0xd0, %rdi
leaq -0xb8(%rbp), %rsi
movq %rsi, -0x5b8(%rbp)
callq 0xb9a0
movq -0x5b8(%rbp), %rdi
callq 0xb9d0
leaq -0xc1(%rbp), %rdi
callq 0xba30
movl 0x339a3(%rip), %eax     # 0x38244
movq %rax, -0x5b0(%rbp)
movq $0x0, -0xe8(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0xb900
movq -0x5b0(%rbp), %rsi
movq -0x5a8(%rbp), %rcx
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
callq 0xb920
jmp 0x48e9
movq -0x2a8(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x5d0(%rbp)
callq 0xb9a0
movq -0x5d0(%rbp), %rdi
callq 0xb9d0
leaq -0xe9(%rbp), %rdi
callq 0xba30
movl 0x3391c(%rip), %eax     # 0x38244
movq %rax, -0x5c8(%rbp)
movq $0x0, -0x110(%rbp)
leaq -0x111(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0xb900
movq -0x5c8(%rbp), %rsi
movq -0x5c0(%rbp), %rcx
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rdx
callq 0xb920
jmp 0x4970
movq -0x2a8(%rbp), %rdi
addq $0xb8, %rdi
leaq -0x108(%rbp), %rsi
movq %rsi, -0x5e8(%rbp)
callq 0xb9a0
movq -0x5e8(%rbp), %rdi
callq 0xb9d0
leaq -0x111(%rbp), %rdi
callq 0xba30
movl 0x33895(%rip), %eax     # 0x38244
movq %rax, -0x5e0(%rbp)
movq $0x0, -0x138(%rbp)
leaq -0x139(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0xb900
movq -0x5e0(%rbp), %rsi
movq -0x5d8(%rbp), %rcx
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rdx
callq 0xb920
jmp 0x49f7
movq -0x2a8(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
leaq -0x130(%rbp), %rsi
movq %rsi, -0x600(%rbp)
callq 0xb9a0
movq -0x600(%rbp), %rdi
callq 0xb9d0
leaq -0x139(%rbp), %rdi
callq 0xba30
movl 0x3380e(%rip), %eax     # 0x38244
movq %rax, -0x5f8(%rbp)
movl $0x0, -0x15c(%rbp)
leaq -0x15d(%rbp), %rdi
movq %rdi, -0x5f0(%rbp)
callq 0xb7b0
movq -0x5f8(%rbp), %rsi
movq -0x5f0(%rbp), %rcx
leaq -0x158(%rbp), %rdi
leaq -0x15c(%rbp), %rdx
callq 0xb7d0
jmp 0x4a7d
movq -0x2a8(%rbp), %rdi
addq $0x178, %rdi            # imm = 0x178
leaq -0x158(%rbp), %rsi
movq %rsi, -0x618(%rbp)
callq 0xb850
movq -0x618(%rbp), %rdi
callq 0xb880
leaq -0x15d(%rbp), %rdi
callq 0xb8e0
movl 0x33770(%rip), %eax     # 0x3822c
movq %rax, -0x610(%rbp)
movl $0x0, -0x17c(%rbp)
leaq -0x17d(%rbp), %rdi
movq %rdi, -0x608(%rbp)
callq 0xb7b0
movq -0x610(%rbp), %rsi
movq -0x608(%rbp), %rcx
leaq -0x178(%rbp), %rdi
leaq -0x17c(%rbp), %rdx
callq 0xb7d0
jmp 0x4b03
movq -0x2a8(%rbp), %rdi
addq $0x40, %rdi
leaq -0x178(%rbp), %rsi
movq %rsi, -0x630(%rbp)
callq 0xb850
movq -0x630(%rbp), %rdi
callq 0xb880
leaq -0x17d(%rbp), %rdi
callq 0xb8e0
movl 0x336ed(%rip), %eax     # 0x3822c
movq %rax, -0x628(%rbp)
movq $0x0, -0x1a0(%rbp)
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x620(%rbp)
callq 0xba50
movq -0x628(%rbp), %rsi
movq -0x620(%rbp), %rcx
leaq -0x198(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
callq 0xba70
jmp 0x4b87
movq -0x2a8(%rbp), %rdi
addq $0x58, %rdi
leaq -0x198(%rbp), %rsi
movq %rsi, -0x648(%rbp)
callq 0xbaf0
movq -0x648(%rbp), %rdi
callq 0xbb20
leaq -0x1a1(%rbp), %rdi
callq 0xbb80
leaq 0x337ac(%rip), %rax     # 0x38370
movl (%rax), %eax
movq %rax, -0x640(%rbp)
movl $0x0, -0x1c4(%rbp)
leaq -0x1c5(%rbp), %rdi
movq %rdi, -0x638(%rbp)
callq 0xb7b0
movq -0x640(%rbp), %rsi
movq -0x638(%rbp), %rcx
leaq -0x1c0(%rbp), %rdi
leaq -0x1c4(%rbp), %rdx
callq 0xb7d0
jmp 0x4c0d
movq -0x2a8(%rbp), %rdi
addq $0x88, %rdi
leaq -0x1c0(%rbp), %rsi
movq %rsi, -0x660(%rbp)
callq 0xb850
movq -0x660(%rbp), %rdi
callq 0xb880
leaq -0x1c5(%rbp), %rdi
callq 0xb8e0
leaq 0x33723(%rip), %rax     # 0x38370
movl (%rax), %eax
movq %rax, -0x658(%rbp)
movl $0x0, -0x1e4(%rbp)
leaq -0x1e5(%rbp), %rdi
movq %rdi, -0x650(%rbp)
callq 0xb7b0
movq -0x658(%rbp), %rsi
movq -0x650(%rbp), %rcx
leaq -0x1e0(%rbp), %rdi
leaq -0x1e4(%rbp), %rdx
callq 0xb7d0
jmp 0x4c96
movq -0x2a8(%rbp), %rdi
addq $0xa0, %rdi
leaq -0x1e0(%rbp), %rsi
movq %rsi, -0x678(%rbp)
callq 0xb850
movq -0x678(%rbp), %rdi
callq 0xb880
leaq -0x1e5(%rbp), %rdi
callq 0xb8e0
movl 0x3356f(%rip), %eax     # 0x38244
movq %rax, -0x670(%rbp)
movl $0x0, -0x204(%rbp)
leaq -0x205(%rbp), %rdi
movq %rdi, -0x668(%rbp)
callq 0xb7b0
movq -0x670(%rbp), %rsi
movq -0x668(%rbp), %rcx
leaq -0x200(%rbp), %rdi
leaq -0x204(%rbp), %rdx
callq 0xb7d0
jmp 0x4d1c
movq -0x2a8(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
leaq -0x200(%rbp), %rsi
movq %rsi, -0x690(%rbp)
callq 0xb850
movq -0x690(%rbp), %rdi
callq 0xb880
leaq -0x205(%rbp), %rdi
callq 0xb8e0
movl 0x334e9(%rip), %eax     # 0x38244
movq %rax, -0x688(%rbp)
movl $0x0, -0x224(%rbp)
leaq -0x225(%rbp), %rdi
movq %rdi, -0x680(%rbp)
callq 0xb7b0
movq -0x688(%rbp), %rsi
movq -0x680(%rbp), %rcx
leaq -0x220(%rbp), %rdi
leaq -0x224(%rbp), %rdx
callq 0xb7d0
jmp 0x4da2
movq -0x2a8(%rbp), %rdi
addq $0x160, %rdi            # imm = 0x160
leaq -0x220(%rbp), %rsi
movq %rsi, -0x6a8(%rbp)
callq 0xb850
movq -0x6a8(%rbp), %rdi
callq 0xb880
leaq -0x225(%rbp), %rdi
callq 0xb8e0
movl 0x3344b(%rip), %eax     # 0x3822c
movq %rax, -0x6a0(%rbp)
movl $0x0, -0x244(%rbp)
leaq -0x245(%rbp), %rdi
movq %rdi, -0x698(%rbp)
callq 0xb7b0
movq -0x6a0(%rbp), %rsi
movq -0x698(%rbp), %rcx
leaq -0x240(%rbp), %rdi
leaq -0x244(%rbp), %rdx
callq 0xb7d0
jmp 0x4e28
movq -0x2a8(%rbp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
leaq -0x240(%rbp), %rsi
movq %rsi, -0x6b8(%rbp)
callq 0xb850
movq -0x6b8(%rbp), %rdi
callq 0xb880
leaq -0x245(%rbp), %rdi
callq 0xb8e0
movl $0x20, %edi
callq 0x31d0
movq %rax, -0x6b0(%rbp)
jmp 0x4e74
movq -0x2a8(%rbp), %rsi
movq -0x6b0(%rbp), %rdi
leaq 0x447(%rip), %rax       # 0x52d0
movq %rax, -0x260(%rbp)
movq $0x0, -0x258(%rbp)
movq -0x260(%rbp), %rdx
movq -0x258(%rbp), %rcx
callq 0xbba0
jmp 0x4eb0
movq -0x2a8(%rbp), %rdi
movq -0x6b0(%rbp), %rax
movq %rax, -0x250(%rbp)
addq $0x28, %rdi
movl 0x3335d(%rip), %eax     # 0x3822c
movl %eax, %esi
callq 0xbc10
jmp 0x4ed8
movl $0x0, -0x264(%rbp)
movl -0x264(%rbp), %eax
cmpl 0x3333e(%rip), %eax     # 0x3822c
jae 0x5144
movq -0x2a8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x6c8(%rbp)
movl $0x280, %edi            # imm = 0x280
callq 0x31d0
movq %rax, -0x6c0(%rbp)
jmp 0x4f19
movq -0x6c0(%rbp), %rdi
movl -0x264(%rbp), %esi
movq -0x250(%rbp), %rdx
callq 0x194e0
jmp 0x4f34
movq -0x6c8(%rbp), %rdi
movq -0x6c0(%rbp), %rax
movq %rax, -0x270(%rbp)
leaq -0x270(%rbp), %rsi
callq 0xbd10
jmp 0x4f57
jmp 0x4f59
movl -0x264(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x264(%rbp)
jmp 0x4ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x7d(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x9d(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0xc1(%rbp), %rdi
callq 0xba30
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0xe9(%rbp), %rdi
callq 0xba30
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x111(%rbp), %rdi
callq 0xba30
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x139(%rbp), %rdi
callq 0xba30
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x15d(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x17d(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x1a1(%rbp), %rdi
callq 0xbb80
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x1c5(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x1e5(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x205(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x225(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x245(%rbp), %rdi
callq 0xb8e0
jmp 0x51e7
movq -0x6b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x20, %esi
callq 0x31f0
jmp 0x51e7
movq -0x6c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0x280, %esi            # imm = 0x280
callq 0x31f0
jmp 0x51e7
leaq 0x33225(%rip), %rax     # 0x38370
movl (%rax), %eax
movq %rax, -0x6d8(%rbp)
movl $0x0, -0x28c(%rbp)
leaq -0x28d(%rbp), %rdi
movq %rdi, -0x6d0(%rbp)
callq 0xb7b0
movq -0x6d8(%rbp), %rsi
movq -0x6d0(%rbp), %rcx
leaq -0x288(%rbp), %rdi
leaq -0x28c(%rbp), %rdx
callq 0xb7d0
jmp 0x5194
movq -0x2a8(%rbp), %rdi
addq $0x198, %rdi            # imm = 0x198
leaq -0x288(%rbp), %rsi
callq 0xb850
leaq -0x288(%rbp), %rdi
callq 0xb880
leaq -0x28d(%rbp), %rdi
callq 0xb8e0
addq $0x6e0, %rsp            # imm = 0x6E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
leaq -0x28d(%rbp), %rdi
callq 0xb8e0
movq -0x2b0(%rbp), %rdi
callq 0xb880
movq -0x2b8(%rbp), %rdi
callq 0xb880
movq -0x2c0(%rbp), %rdi
callq 0xb880
movq -0x2c8(%rbp), %rdi
callq 0xb880
movq -0x2d0(%rbp), %rdi
callq 0xb880
movq -0x2d8(%rbp), %rdi
callq 0xb9d0
movq -0x2e0(%rbp), %rdi
callq 0xb9d0
movq -0x2e8(%rbp), %rdi
callq 0xb880
movq -0x2f0(%rbp), %rdi
callq 0xb880
movq -0x2f8(%rbp), %rdi
callq 0xb9d0
movq -0x300(%rbp), %rdi
callq 0xb9d0
movq -0x308(%rbp), %rdi
callq 0xb880
movq -0x310(%rbp), %rdi
callq 0xb880
movq -0x318(%rbp), %rdi
callq 0xb9d0
movq -0x320(%rbp), %rdi
callq 0xbb20
movq -0x328(%rbp), %rdi
callq 0xb880
movq -0x330(%rbp), %rdi
callq 0xbd40
movq -0x338(%rbp), %rdi
callq 0xbda0
movq -0x10(%rbp), %rdi
callq 0x33a0
nopl (%rax,%rax)