// File: chinmayachaudhry[P]Branch-Predictor/main.cpp
// Function: main
int main(int argc, char *argv[])
{
	string trace_file;
	ll predictor_index_bits, ghr_bits, btb_index_bits, btb_assoc;
	ll chooser_table_index_bits, bimodal_index_bits, gshare_index_bits, history_index_bits;

	ll address;
	int predictor_type;
	char actual_branch;		
	char *fname = (char *)malloc(100);

	if(strcmp(argv[1], "bimodal") == 0)
		predictor_type = 0;
	else if(strcmp(argv[1], "gshare") == 0)
		predictor_type = 1;
	else if(strcmp(argv[1], "hybrid") == 0)
		predictor_type = 2;
	else if(strcmp(argv[1], "yehpatt") == 0)
		predictor_type = 3;
	ifstream fin;

	bimodal *b;
	gshare *g;
	hybrid *h;
	yehpatt *y;
	btb *branch_buffer;
	switch(predictor_type)
	{
		case 0:
			predictor_index_bits = atol(argv[2]);
			btb_index_bits = atol(argv[3]);
			btb_assoc = atol(argv[4]);
			//cout << "index: " << btb_index_bits << " assoc: " << btb_assoc << endl;
			strcpy(fname, argv[5]);
			if(btb_index_bits == 0)
				branch_buffer = NULL;
			else
				branch_buffer = new btb(btb_index_bits, btb_assoc);
			b = new bimodal(predictor_index_bits, branch_buffer);
			break;
//			b->display_table();
//			cout << "BIMODAL";
	
		case 1:
			predictor_index_bits = atol(argv[2]);
			ghr_bits = atol(argv[3]);
			btb_index_bits = atol(argv[4]);
			btb_assoc = atol(argv[5]);
			//cout << "index: " << btb_index_bits << " assoc: " << btb_assoc << endl;
			strcpy(fname, argv[6]);
			if(btb_index_bits == 0)
				branch_buffer = NULL;
			else
				branch_buffer = new btb(btb_index_bits, btb_assoc);
			g = new gshare(predictor_index_bits, ghr_bits, branch_buffer);
			break;
//			b->display_table();
//			cout << "BIMODAL";
		
		case 2:
			chooser_table_index_bits = atol(argv[2]);
			gshare_index_bits = atol(argv[3]);
			ghr_bits = atol(argv[4]);
			bimodal_index_bits = atol(argv[5]);
			btb_index_bits = atol(argv[6]);
			btb_assoc = atol(argv[7]);
			//cout << "index: " << btb_index_bits << " assoc: " << btb_assoc << endl;
			strcpy(fname, argv[8]);
			if(btb_index_bits == 0)
				branch_buffer = NULL;
			else
				branch_buffer = new btb(btb_index_bits, btb_assoc);
			h = new hybrid(bimodal_index_bits, gshare_index_bits, ghr_bits, chooser_table_index_bits, branch_buffer);
			break;
//			b->display_table();
//			cout << "BIMODAL";
		
		case 3:
			history_index_bits = atol(argv[2]);
			predictor_index_bits = atol(argv[3]);
			btb_index_bits = atol(argv[4]);
			btb_assoc = atol(argv[5]);
			//cout << "index: " << btb_index_bits << " assoc: " << btb_assoc << endl;
			strcpy(fname, argv[6]);
			if(btb_index_bits == 0)
				branch_buffer = NULL;
			else
				branch_buffer = new btb(btb_index_bits, btb_assoc);
			y = new yehpatt(history_index_bits, predictor_index_bits, branch_buffer);
			break;

	}

	fin.open(fname);
	static int branches = 0;
	switch(predictor_type)
	{
		case 0:
			while(fin >> hex >> address >> actual_branch)
			{
				branches++;
				if(btb_index_bits != 0 && btb_assoc != 0)
				{
					branch_buffer->access(address, actual_branch);
					if(branch_buffer->get_btb_Hit() == true)		
						b->access(address, actual_branch);	
				}	
				else
					b->access(address, actual_branch);	
			}
			fin.close();
			break;

		case 1:
			while(fin >> hex >> address >> actual_branch)
			{
				branches++;
				if(btb_index_bits != 0 && btb_assoc != 0)
				{
					branch_buffer->access(address, actual_branch);
					if(branch_buffer->get_btb_Hit() == true)		
						g->access(address, actual_branch);	
				}	
				else
					g->access(address, actual_branch);	
			}
			fin.close();
			break;

		case 2:
			while(fin >> hex >> address >> actual_branch)
			{
				branches++;
				if(btb_index_bits != 0 && btb_assoc != 0)
				{
					branch_buffer->access(address, actual_branch);
					if(branch_buffer->get_btb_Hit() == true)		
						h->access(address, actual_branch);	
				}	
				else
					h->access(address, actual_branch);	
			}
			fin.close();
			break;
		
		case 3:
			while(fin >> hex >> address >> actual_branch)
			{
				branches++;
				if(btb_index_bits != 0 && btb_assoc != 0)
				{
					branch_buffer->access(address, actual_branch);
					if(branch_buffer->get_btb_Hit() == true)		
						y->access(address, actual_branch);	
				}	
				else
					y->access(address, actual_branch);	
			}
			fin.close();
			break;
	}

	
	cout << "Command Line:" << endl;
	switch(predictor_type)
	{
		case 0:	
			cout << "./sim_bp bimodal " << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << endl;
			b->display_table();
			b->print_stats();
			break;

		case 1:	
			cout << "./sim_bp gshare " << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << " " << argv[6] << endl;
			g->display_table();
			g->print_stats();
			break;	
		
		case 2:	
			cout << "./sim_bp hybrid " << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << " " << argv[6] << " " << argv[7] << " " << argv[8] << endl;
			h->display_table();
			h->print_stats();
			break;	
		
		case 3:	
			cout << "./sim_bp yehpatt " << argv[2] << " " << argv[3] << " " << argv[4] << " " << argv[5] << " " << argv[6] << endl;
			y->display_table();
			y->print_stats();
			break;	
	}
	
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x22c0
movl $0x64, %edi
callq 0x22a0
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x69a2(%rip), %rsi      # 0x9034
callq 0x22d0
cmpl $0x0, %eax
jne 0x26a5
movl $0x0, -0x7c(%rbp)
jmp 0x270f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x6988(%rip), %rsi      # 0x903c
callq 0x22d0
cmpl $0x0, %eax
jne 0x26c7
movl $0x1, -0x7c(%rbp)
jmp 0x270d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x696d(%rip), %rsi      # 0x9043
callq 0x22d0
cmpl $0x0, %eax
jne 0x26e9
movl $0x2, -0x7c(%rbp)
jmp 0x270b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x6952(%rip), %rsi      # 0x904a
callq 0x22d0
cmpl $0x0, %eax
jne 0x2709
movl $0x3, -0x7c(%rbp)
jmp 0x270b
jmp 0x270d
jmp 0x270f
leaq -0x290(%rbp), %rdi
callq 0x2230
jmp 0x271d
movl -0x7c(%rbp), %eax
movq %rax, -0x2d0(%rbp)
subq $0x3, %rax
ja 0x2c68
movq -0x2d0(%rbp), %rax
leaq 0x68c5(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x3734
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2260
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2260
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2260
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x21a0
cmpq $0x0, -0x48(%rbp)
jne 0x27ba
movq $0x0, -0x2c8(%rbp)
jmp 0x2832
movl $0x40, %edi
callq 0x21c0
movq %rax, -0x2d8(%rbp)
jmp 0x27cd
movq -0x2d8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x3900
jmp 0x27e3
movq -0x2d8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x2832
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0x3728
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x40, %esi
callq 0x21d0
jmp 0x3728
movl $0x60, %edi
callq 0x21c0
movq %rax, -0x2e0(%rbp)
jmp 0x2845
movq -0x2e0(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x2c8(%rbp), %rdx
callq 0x4a30
jmp 0x285e
movq -0x2e0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
jmp 0x2c68
movq -0x2e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x60, %esi
callq 0x21d0
jmp 0x3728
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2260
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2260
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2260
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2260
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x21a0
cmpq $0x0, -0x48(%rbp)
jne 0x2905
movq $0x0, -0x2c8(%rbp)
jmp 0x2966
movl $0x40, %edi
callq 0x21c0
movq %rax, -0x2e8(%rbp)
jmp 0x2918
movq -0x2e8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x3900
jmp 0x292e
movq -0x2e8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x2966
movq -0x2e8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x40, %esi
callq 0x21d0
jmp 0x3728
movl $0x88, %edi
callq 0x21c0
movq %rax, -0x2f0(%rbp)
jmp 0x2979
movq -0x2f0(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x2c8(%rbp), %rcx
callq 0x6060
jmp 0x2996
movq -0x2f0(%rbp), %rax
movq %rax, -0x2b0(%rbp)
jmp 0x2c68
movq -0x2f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x88, %esi
callq 0x21d0
jmp 0x3728
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2260
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2260
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2260
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2260
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2260
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x2260
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x21a0
cmpq $0x0, -0x48(%rbp)
jne 0x2a5f
movq $0x0, -0x2c8(%rbp)
jmp 0x2ac0
movl $0x40, %edi
callq 0x21c0
movq %rax, -0x2f8(%rbp)
jmp 0x2a72
movq -0x2f8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x3900
jmp 0x2a88
movq -0x2f8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x2ac0
movq -0x2f8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x40, %esi
callq 0x21d0
jmp 0x3728
movl $0x78, %edi
callq 0x21c0
movq %rax, -0x300(%rbp)
jmp 0x2ad3
movq -0x300(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x2c8(%rbp), %r9
callq 0x6a70
jmp 0x2af8
movq -0x300(%rbp), %rax
movq %rax, -0x2b8(%rbp)
jmp 0x2c68
movq -0x300(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x78, %esi
callq 0x21d0
jmp 0x3728
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2260
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2260
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2260
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2260
movq %rax, -0x50(%rbp)
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x21a0
cmpq $0x0, -0x48(%rbp)
jne 0x2b9f
movq $0x0, -0x2c8(%rbp)
jmp 0x2c00
movl $0x40, %edi
callq 0x21c0
movq %rax, -0x308(%rbp)
jmp 0x2bb2
movq -0x308(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x3900
jmp 0x2bc8
movq -0x308(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x2c00
movq -0x308(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x40, %esi
callq 0x21d0
jmp 0x3728
movl $0x98, %edi
callq 0x21c0
movq %rax, -0x310(%rbp)
jmp 0x2c13
movq -0x310(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x2c8(%rbp), %rcx
callq 0x7520
jmp 0x2c30
movq -0x310(%rbp), %rax
movq %rax, -0x2c0(%rbp)
jmp 0x2c68
movq -0x310(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
movl $0x98, %esi
callq 0x21d0
jmp 0x3728
movq -0x88(%rbp), %rsi
leaq -0x290(%rbp), %rdi
movl $0x8, %edx
callq 0x2120
jmp 0x2c82
movl -0x7c(%rbp), %eax
movq %rax, -0x318(%rbp)
subq $0x3, %rax
ja 0x3122
movq -0x318(%rbp), %rax
leaq 0x6370(%rip), %rcx      # 0x9014
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x2caf
leaq 0xa9a(%rip), %rsi       # 0x3750
leaq -0x290(%rbp), %rdi
callq 0x2350
movq %rax, -0x320(%rbp)
jmp 0x2ccb
movq -0x320(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2250
movq %rax, -0x328(%rbp)
jmp 0x2ce4
movq -0x328(%rbp), %rdi
leaq -0x7d(%rbp), %rsi
callq 0x2290
movq %rax, -0x330(%rbp)
jmp 0x2cfd
movq -0x330(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2280
movb %al, -0x331(%rbp)
jmp 0x2d1b
movb -0x331(%rbp), %al
testb $0x1, %al
jne 0x2d2a
jmp 0x2db8
movl 0xa4d8(%rip), %eax      # 0xd208
addl $0x1, %eax
movl %eax, 0xa4cf(%rip)      # 0xd208
cmpq $0x0, -0x48(%rbp)
je 0x2d9b
cmpq $0x0, -0x50(%rbp)
je 0x2d9b
movq -0x2c8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x3af0
jmp 0x2d5d
movq -0x2c8(%rbp), %rdi
callq 0x3780
movb %al, -0x332(%rbp)
jmp 0x2d71
movb -0x332(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2d99
movq -0x2a8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x4cd0
jmp 0x2d97
jmp 0x2d99
jmp 0x2db3
movq -0x2a8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x4cd0
jmp 0x2db1
jmp 0x2db3
jmp 0x2caf
leaq -0x290(%rbp), %rdi
callq 0x2060
jmp 0x2dc6
jmp 0x3122
jmp 0x2dcd
leaq 0x97c(%rip), %rsi       # 0x3750
leaq -0x290(%rbp), %rdi
callq 0x2350
movq %rax, -0x340(%rbp)
jmp 0x2de9
movq -0x340(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2250
movq %rax, -0x348(%rbp)
jmp 0x2e02
movq -0x348(%rbp), %rdi
leaq -0x7d(%rbp), %rsi
callq 0x2290
movq %rax, -0x350(%rbp)
jmp 0x2e1b
movq -0x350(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2280
movb %al, -0x351(%rbp)
jmp 0x2e39
movb -0x351(%rbp), %al
testb $0x1, %al
jne 0x2e48
jmp 0x2ed6
movl 0xa3ba(%rip), %eax      # 0xd208
addl $0x1, %eax
movl %eax, 0xa3b1(%rip)      # 0xd208
cmpq $0x0, -0x48(%rbp)
je 0x2eb9
cmpq $0x0, -0x50(%rbp)
je 0x2eb9
movq -0x2c8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x3af0
jmp 0x2e7b
movq -0x2c8(%rbp), %rdi
callq 0x3780
movb %al, -0x352(%rbp)
jmp 0x2e8f
movb -0x352(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2eb7
movq -0x2b0(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x63f0
jmp 0x2eb5
jmp 0x2eb7
jmp 0x2ed1
movq -0x2b0(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x63f0
jmp 0x2ecf
jmp 0x2ed1
jmp 0x2dcd
leaq -0x290(%rbp), %rdi
callq 0x2060
jmp 0x2ee4
jmp 0x3122
jmp 0x2eeb
leaq 0x85e(%rip), %rsi       # 0x3750
leaq -0x290(%rbp), %rdi
callq 0x2350
movq %rax, -0x360(%rbp)
jmp 0x2f07
movq -0x360(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2250
movq %rax, -0x368(%rbp)
jmp 0x2f20
movq -0x368(%rbp), %rdi
leaq -0x7d(%rbp), %rsi
callq 0x2290
movq %rax, -0x370(%rbp)
jmp 0x2f39
movq -0x370(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2280
movb %al, -0x371(%rbp)
jmp 0x2f57
movb -0x371(%rbp), %al
testb $0x1, %al
jne 0x2f66
jmp 0x2ff4
movl 0xa29c(%rip), %eax      # 0xd208
addl $0x1, %eax
movl %eax, 0xa293(%rip)      # 0xd208
cmpq $0x0, -0x48(%rbp)
je 0x2fd7
cmpq $0x0, -0x50(%rbp)
je 0x2fd7
movq -0x2c8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x3af0
jmp 0x2f99
movq -0x2c8(%rbp), %rdi
callq 0x3780
movb %al, -0x372(%rbp)
jmp 0x2fad
movb -0x372(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x2fd5
movq -0x2b8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x6ed0
jmp 0x2fd3
jmp 0x2fd5
jmp 0x2fef
movq -0x2b8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x6ed0
jmp 0x2fed
jmp 0x2fef
jmp 0x2eeb
leaq -0x290(%rbp), %rdi
callq 0x2060
jmp 0x3002
jmp 0x3122
jmp 0x3009
leaq 0x740(%rip), %rsi       # 0x3750
leaq -0x290(%rbp), %rdi
callq 0x2350
movq %rax, -0x380(%rbp)
jmp 0x3025
movq -0x380(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2250
movq %rax, -0x388(%rbp)
jmp 0x303e
movq -0x388(%rbp), %rdi
leaq -0x7d(%rbp), %rsi
callq 0x2290
movq %rax, -0x390(%rbp)
jmp 0x3057
movq -0x390(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2280
movb %al, -0x391(%rbp)
jmp 0x3075
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x3084
jmp 0x3112
movl 0xa17e(%rip), %eax      # 0xd208
addl $0x1, %eax
movl %eax, 0xa175(%rip)      # 0xd208
cmpq $0x0, -0x48(%rbp)
je 0x30f5
cmpq $0x0, -0x50(%rbp)
je 0x30f5
movq -0x2c8(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x3af0
jmp 0x30b7
movq -0x2c8(%rbp), %rdi
callq 0x3780
movb %al, -0x392(%rbp)
jmp 0x30cb
movb -0x392(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x30f3
movq -0x2c0(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x7920
jmp 0x30f1
jmp 0x30f3
jmp 0x310d
movq -0x2c0(%rbp), %rdi
movq -0x78(%rbp), %rsi
movsbl -0x7d(%rbp), %edx
callq 0x7920
jmp 0x310b
jmp 0x310d
jmp 0x3009
leaq -0x290(%rbp), %rdi
callq 0x2060
jmp 0x3120
jmp 0x3122
movq 0x9eaf(%rip), %rdi      # 0xcfd8
leaq 0x5f22(%rip), %rsi      # 0x9052
callq 0x21b0
movq %rax, -0x3a0(%rbp)
jmp 0x313e
movq -0x3a0(%rbp), %rdi
movq 0x9e7c(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x3153
movl -0x7c(%rbp), %eax
movq %rax, -0x3a8(%rbp)
subq $0x3, %rax
ja 0x3700
movq -0x3a8(%rbp), %rax
leaq 0x5eaf(%rip), %rcx      # 0x9024
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x9e53(%rip), %rdi      # 0xcfd8
leaq 0x5ed4(%rip), %rsi      # 0x9060
callq 0x21b0
movq %rax, -0x3b0(%rbp)
jmp 0x319a
movq -0x3b0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21b0
movq %rax, -0x3b8(%rbp)
jmp 0x31b7
movq -0x3b8(%rbp), %rdi
leaq 0x5f2b(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x3c0(%rbp)
jmp 0x31d3
movq -0x3c0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x21b0
movq %rax, -0x3c8(%rbp)
jmp 0x31f0
movq -0x3c8(%rbp), %rdi
leaq 0x5ef2(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x3d0(%rbp)
jmp 0x320c
movq -0x3d0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x21b0
movq %rax, -0x3d8(%rbp)
jmp 0x3229
movq -0x3d8(%rbp), %rdi
leaq 0x5eb9(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x3e0(%rbp)
jmp 0x3245
movq -0x3e0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x21b0
movq %rax, -0x3e8(%rbp)
jmp 0x3262
movq -0x3e8(%rbp), %rdi
movq 0x9d58(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x3277
movq -0x2a8(%rbp), %rdi
callq 0x4d30
jmp 0x3285
movq -0x2a8(%rbp), %rdi
callq 0x4e90
jmp 0x3293
jmp 0x3700
movq 0x9d39(%rip), %rdi      # 0xcfd8
leaq 0x5dcc(%rip), %rsi      # 0x9072
callq 0x21b0
movq %rax, -0x3f0(%rbp)
jmp 0x32b4
movq -0x3f0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21b0
movq %rax, -0x3f8(%rbp)
jmp 0x32d1
movq -0x3f8(%rbp), %rdi
leaq 0x5e11(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x400(%rbp)
jmp 0x32ed
movq -0x400(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x21b0
movq %rax, -0x408(%rbp)
jmp 0x330a
movq -0x408(%rbp), %rdi
leaq 0x5dd8(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x410(%rbp)
jmp 0x3326
movq -0x410(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x21b0
movq %rax, -0x418(%rbp)
jmp 0x3343
movq -0x418(%rbp), %rdi
leaq 0x5d9f(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x420(%rbp)
jmp 0x335f
movq -0x420(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x21b0
movq %rax, -0x428(%rbp)
jmp 0x337c
movq -0x428(%rbp), %rdi
leaq 0x5d66(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x430(%rbp)
jmp 0x3398
movq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x21b0
movq %rax, -0x438(%rbp)
jmp 0x33b5
movq -0x438(%rbp), %rdi
movq 0x9c05(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x33ca
movq -0x2b0(%rbp), %rdi
callq 0x6450
jmp 0x33d8
movq -0x2b0(%rbp), %rdi
callq 0x6670
jmp 0x33e6
jmp 0x3700
movq 0x9be6(%rip), %rdi      # 0xcfd8
leaq 0x5c8a(%rip), %rsi      # 0x9083
callq 0x21b0
movq %rax, -0x440(%rbp)
jmp 0x3407
movq -0x440(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21b0
movq %rax, -0x448(%rbp)
jmp 0x3424
movq -0x448(%rbp), %rdi
leaq 0x5cbe(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x450(%rbp)
jmp 0x3440
movq -0x450(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x21b0
movq %rax, -0x458(%rbp)
jmp 0x345d
movq -0x458(%rbp), %rdi
leaq 0x5c85(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x460(%rbp)
jmp 0x3479
movq -0x460(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x21b0
movq %rax, -0x468(%rbp)
jmp 0x3496
movq -0x468(%rbp), %rdi
leaq 0x5c4c(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x470(%rbp)
jmp 0x34b2
movq -0x470(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x21b0
movq %rax, -0x478(%rbp)
jmp 0x34cf
movq -0x478(%rbp), %rdi
leaq 0x5c13(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x480(%rbp)
jmp 0x34eb
movq -0x480(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x21b0
movq %rax, -0x488(%rbp)
jmp 0x3508
movq -0x488(%rbp), %rdi
leaq 0x5bda(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x490(%rbp)
jmp 0x3524
movq -0x490(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x21b0
movq %rax, -0x498(%rbp)
jmp 0x3541
movq -0x498(%rbp), %rdi
leaq 0x5ba1(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x4a0(%rbp)
jmp 0x355d
movq -0x4a0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
callq 0x21b0
movq %rax, -0x4a8(%rbp)
jmp 0x357a
movq -0x4a8(%rbp), %rdi
movq 0x9a40(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x358f
movq -0x2b8(%rbp), %rdi
callq 0x6fc0
jmp 0x359d
movq -0x2b8(%rbp), %rdi
callq 0x7130
jmp 0x35ab
jmp 0x3700
movq 0x9a21(%rip), %rdi      # 0xcfd8
leaq 0x5ad6(%rip), %rsi      # 0x9094
callq 0x21b0
movq %rax, -0x4b0(%rbp)
jmp 0x35cc
movq -0x4b0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x21b0
movq %rax, -0x4b8(%rbp)
jmp 0x35e9
movq -0x4b8(%rbp), %rdi
leaq 0x5af9(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x4c0(%rbp)
jmp 0x3605
movq -0x4c0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x21b0
movq %rax, -0x4c8(%rbp)
jmp 0x3622
movq -0x4c8(%rbp), %rdi
leaq 0x5ac0(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x4d0(%rbp)
jmp 0x363e
movq -0x4d0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x21b0
movq %rax, -0x4d8(%rbp)
jmp 0x365b
movq -0x4d8(%rbp), %rdi
leaq 0x5a87(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x4e0(%rbp)
jmp 0x3677
movq -0x4e0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x21b0
movq %rax, -0x4e8(%rbp)
jmp 0x3694
movq -0x4e8(%rbp), %rdi
leaq 0x5a4e(%rip), %rsi      # 0x90f0
callq 0x21b0
movq %rax, -0x4f0(%rbp)
jmp 0x36b0
movq -0x4f0(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x21b0
movq %rax, -0x4f8(%rbp)
jmp 0x36cd
movq -0x4f8(%rbp), %rdi
movq 0x98ed(%rip), %rsi      # 0xcfc8
callq 0x21e0
jmp 0x36e2
movq -0x2c0(%rbp), %rdi
callq 0x7970
jmp 0x36f0
movq -0x2c0(%rbp), %rdi
callq 0x7d20
jmp 0x36fe
jmp 0x3700
movl $0x1, -0x4(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x2070
leaq -0x30(%rbp), %rdi
callq 0x2110
movl -0x4(%rbp), %eax
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq
leaq -0x290(%rbp), %rdi
callq 0x2070
leaq -0x30(%rbp), %rdi
callq 0x2110
movq -0x298(%rbp), %rdi
callq 0x2380
nopl (%rax)