// File: /workspace/github_cpp_makefile_star2_O1/AngelPn[P]L5R-card_game/src/Player.cpp
// Function: Player::battlePhase(Player*)
void Player::battlePhase(Player *p){
	//All of the cards in Army are untapped because of the startingPhase
	cout<< this->name<< ", choose the number of untapped Personalities in Army to defense/battle: "<< endl<<
		"The number of existing untapped Personalities in Army is "<< army.size()<< endl<<
		"Type a number (1-"<< army.size()<< "): ";
	int c= 0;
	while(c< 1 || c> army.size()){
		cin>> c;
		cout<< c<< endl;
	}

	//Built up the arena
	printArmy();
	cout<< this->name<< ", choose which of the Personalities in Army you want in Arena: "<< endl<<
		"Type "<< c<< " different numbers: (1-"<< army.size()<< "): ";
	int n= 0;
	arena.clear(); //Clear the previous arena
	for(int i=0; i< c; i++){
		cin>> n;
		arena.push_back(n -1); //vector of army's indexes that keeps track of personalities in arena
	}
	printArena();

	if(p!= NULL){ //If the player has chosen battle

		cout<< "Enemy's provinces: "<< endl;
		p->printProvinces();
		cout<< this->name<< ", choose the enemy's province to attack: "<< endl<<
			"The number of enemy's provinces is "<< p->numberOfProvinces<< endl<<
			"Type a number: (1-"<< p->numberOfProvinces<< "): ";
		n= 0;
		while(n< 1 || n> p->numberOfProvinces)
			cin>> n;

		//Calculate the total points of attacker and defender
		int points_attacker= 0, points_defender= 0;

		for(int i= 0; i< arena.size(); i++)
			points_attacker+= army[arena[i]]->get_attack();

		for(int i= 0; i< p->arena.size(); i++)
			points_defender+= p->army[p->arena[i]]->get_defense();

		int province_defense= p->holdings[0]->get_initialDefense(); //Get the province defense points from StrongHold
		points_defender+= province_defense;

		cout<< "Attacker's points= "<< points_attacker<< endl<<
			"Province's defense= "<< province_defense<< endl<<
			"Defender's points= "<< points_defender<< endl<< endl;

		if(points_attacker - points_defender > province_defense){ //Attacker won the battle, province is destroyed
			p->provinces.erase(p->provinces.begin()+ n-1); //Destroy defender's province
			p->numberOfProvinces--; //Decrement defender's total number of provinces
			//Defender loses all of the defensive personalities
			for(int i=0; i< p->arena.size(); i++){
				p->army.erase(p->army.begin()+ p->arena[i]); //Destroy the Personality
				p->decrease_arena(i);
				p->arena.erase(p->arena.begin()+ i); //Erase the Personality from Arena
				i--;
			}
			//Print a message
			cout<< "Attacker's points - Defender's points > Province's defense"<< endl<<
				"Attacker "<< this->name<< " won the battle. Enemy's province is destroyed!"<< endl<<
				"Print Enemy's provinces: "<< endl;
			p->printProvinces();
		}
		else{ //Province is not destroyed
			if(points_attacker > points_defender){
				//Defender loses all of the defensive personalities
				for(int i=0; i< p->arena.size(); i++){
					p->army.erase(p->army.begin()+ p->arena[i]); //Destroy the Personality
					p->decrease_arena(i);
					p->arena.erase(p->arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}

				//Attacker loses followers or personalities from arena's army that attack>= points_attacker- points_defender
				int lost_points= 0, k= 0;
				while(lost_points < (points_attacker - points_defender)){

					if(army[arena[k]]->hasFollowers()){ //If the Personality has followers
						army[arena[k]]->destroyFollower(&lost_points);
						continue;
					}
					else{
						lost_points+= army[arena[k]]->get_attack();
						army.erase(army.begin()+ arena[k]); //delete the Personality
						decrease_arena(k);
						arena.erase(arena.begin()+ k);
						k--;
					}

					if(k == army.size()) break;
					k++;
				}

				//Tap every Personality and Followers that have survived
				for(int i= 0; i< arena.size(); i++){
					army[arena[i]]->tap_followers();
					army[arena[i]]->tap();
					//Items of Personality lose one durability
					army[arena[i]]->decrement_durability();
				}
				//Print a message
				cout<< "Attacker's points - Defender's points < Province's defense"<< endl<<
					"Province is not destroyed!"<< endl<<
					"Attacker's points > Defender's points"<< endl<<
					"Defender loses all of the defensive Personalities"<< endl<<
					"Attacker loses followers or personalities from Arena's army that attack>= attacker's points - defender's points"<< endl<<
					"Tapped every Personality and Followers that have survived. Items of Personality lose one durability"<< endl;
			}
			else if(points_attacker == points_defender){
				//Attacker loses all of the attacking personalities and followers
				for(int i=0; i< arena.size(); i++){
					army.erase(army.begin()+ arena[i]); //Destroy the Personality
					decrease_arena(i);
					arena.erase(arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}

				//Defender loses all of the defensive personalities and followers
				for(int i=0; i< p->arena.size(); i++){
					p->army.erase(p->army.begin()+ p->arena[i]); //Destroy the Personality
					p->decrease_arena(i);
					p->arena.erase(p->arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}

				//Print a message
				cout<< "Attacker's points - Defender's points < Province's defense"<< endl<<
					"Province is not destroyed!"<< endl<<
					"Attacker's points == Defender's points"<< endl<<
					"Defender loses all of the defensive Personalities and Followers"<< endl<<
					"Attacker loses all of the attacking Personalities and Followers"<< endl;
			}
			else{
				//Attacker loses all of the attacking personalities and followers
				for(int i=0; i< arena.size(); i++){
					army.erase(army.begin()+ arena[i]); //Destroy the Personality
					decrease_arena(i);
					arena.erase(arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}

				//Defender loses followers or personalities from arena's army that attack>= points_attacker- points_defender
				int lost_points= 0, k= 0;
				while(lost_points < (points_defender - points_attacker)){

					if(p->army[p->arena[k]]->hasFollowers()){ //If the Personality has followers
						p->army[p->arena[k]]->destroyFollower(&lost_points);
						continue;
					}
					else{
						lost_points+= p->army[p->arena[k]]->get_attack();
						p->army.erase(p->army.begin()+ p->arena[k]); //destroy the Personality
						p->decrease_arena(k);
						p->arena.erase(p->arena.begin()+ k);
						k--;
					}

					if(k == p->army.size()) break;
					k++;
				}
				//Print a message
				cout<< "Attacker's points - Defender's points < Province's defense"<< endl<<
					"Province is not destroyed!"<< endl<<
					"Attacker's points < Defender's points"<< endl<<
					"Defender loses followers or personalities from arena's army that attack>= defender's points - attacker's points"<< endl<<
					"Attacker loses all of the attacking Personalities and Followers"<< endl;
			}
			cout<< "Surviving Personalities lose a point of honour"<< endl;
			//Surviving Personalities lose a point of honour
			for(int i= 0; i< arena.size(); i++){
				army[arena[i]]->decrement_honour();
				if(army[arena[i]]->get_honour() == 0){ //Perfom suicide
					army[arena[i]]->performSeppuku();
					army.erase(army.begin()+ arena[i]); //Destroy the Personality
					decrease_arena(i);
					arena.erase(arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}
			}
			for(int i= 0; i< p->arena.size(); i++){
				p->army[p->arena[i]]->decrement_honour();
				if(p->army[p->arena[i]]->get_honour() == 0){ //Perfom suicide
					p->army[p->arena[i]]->performSeppuku();
					p->army.erase(p->army.begin()+ p->arena[i]); //Destroy the Personality
					p->decrease_arena(i);
					p->arena.erase(p->arena.begin()+ i); //Erase the Personality from Arena
					i--;
				}
			}
		}
		cout<< "Print "<< this->name<< "'s Arena:"<< endl;
		printArena();
		cout<< "Print "<< p->name<< "'s Arena: "<< endl;
		p->printArena();
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0xa8(%rdi), %rsi
movq 0xb0(%rdi), %rdx
movq 0x8adb(%rip), %r15      # 0x11fd0
movq %r15, %rdi
callq 0x31a0
movq %rax, %r12
leaq 0x39a2(%rip), %rsi      # 0xcea9
movl $0x49, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r12
leaq 0x39ad(%rip), %rsi      # 0xcef3
movl $0x39, %edx
movq %rax, %rdi
callq 0x31a0
movq 0x58(%r14), %rsi
subq 0x50(%r14), %rsi
sarq $0x3, %rsi
movq %r12, %rdi
callq 0x30e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r12
leaq 0x3992(%rip), %rsi      # 0xcf2d
movl $0x11, %edx
movq %rax, %rdi
callq 0x31a0
movq 0x58(%r14), %rsi
subq 0x50(%r14), %rsi
sarq $0x3, %rsi
movq %r12, %rdi
callq 0x30e0
leaq 0x2a66(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
leaq 0x14(%rsp), %r12
movl $0x0, (%r12)
movq 0x89fc(%rip), %r13      # 0x11fe0
movslq 0x14(%rsp), %rax
testq %rax, %rax
jle 0x95ff
movq 0x58(%r14), %rcx
subq 0x50(%r14), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
jae 0x9642
movq %r13, %rdi
movq %r12, %rsi
callq 0x30d0
movl 0x14(%rsp), %esi
movq %r15, %rdi
callq 0x3200
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
jmp 0x95e4
movq %r14, %rdi
callq 0x9150
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq 0x8971(%rip), %rdi      # 0x11fd0
callq 0x31a0
movq %rax, %r15
leaq 0x38d1(%rip), %rsi      # 0xcf3f
movl $0x3f, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x38d3(%rip), %rsi      # 0xcf7f
movl $0x5, %edx
movq %rax, %rdi
callq 0x31a0
movl 0x14(%rsp), %esi
movq %r15, %rdi
callq 0x3200
movq %rax, %r15
leaq 0x38b6(%rip), %rsi      # 0xcf85
movl $0x17, %edx
movq %rax, %rdi
callq 0x31a0
movq 0x58(%r14), %rsi
subq 0x50(%r14), %rsi
sarq $0x3, %rsi
movq %r15, %rdi
callq 0x30e0
leaq 0x2932(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
movl $0x0, 0x10(%rsp)
movq 0x68(%r14), %rax
cmpq %rax, 0x70(%r14)
je 0x971a
movq %rax, 0x70(%r14)
cmpl $0x0, 0x14(%rsp)
jle 0x9776
leaq 0x68(%r14), %r12
xorl %r15d, %r15d
movq 0x88b1(%rip), %r13      # 0x11fe0
leaq 0x10(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x30d0
movl 0x10(%rsp), %eax
decl %eax
movl %eax, 0xc(%rsp)
movq 0x70(%r14), %rsi
cmpq 0x78(%r14), %rsi
je 0x975f
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%r14)
jmp 0x976c
movq %r12, %rdi
leaq 0xc(%rsp), %rdx
callq 0xbac8
incl %r15d
cmpl 0x14(%rsp), %r15d
jl 0x9734
movq %r14, %rdi
callq 0xa6b6
testq %rbx, %rbx
je 0xa6a6
leaq 0x3928(%rip), %rsi      # 0xd0b6
movl $0x13, %edx
movq 0x8836(%rip), %r15      # 0x11fd0
movq %r15, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rbx, %rdi
callq 0x8790
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq %r15, %rdi
callq 0x31a0
movq %rax, %r15
leaq 0x37ac(%rip), %rsi      # 0xcf9d
movl $0x29, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3798(%rip), %rsi      # 0xcfc7
movl $0x23, %edx
movq %rax, %rdi
callq 0x31a0
movl 0x80(%rbx), %esi
movq %r15, %rdi
callq 0x3200
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x376d(%rip), %rsi      # 0xcfeb
movl $0x12, %edx
movq %rax, %rdi
callq 0x31a0
movl 0x80(%rbx), %esi
movq %r15, %rdi
callq 0x3200
leaq 0x2789(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
leaq 0x10(%rsp), %r15
movl $0x0, (%r15)
movq 0x8720(%rip), %r12      # 0x11fe0
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0x98d0
cmpl 0x80(%rbx), %eax
jle 0x98dd
movq %r12, %rdi
movq %r15, %rsi
callq 0x30d0
jmp 0x98c0
movq 0x68(%r14), %rax
xorl %ebp, %ebp
movl $0x0, %r12d
cmpq %rax, 0x70(%r14)
je 0x9920
xorl %r15d, %r15d
xorl %r12d, %r12d
movslq (%rax,%r15,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7b20
addl %eax, %r12d
incq %r15
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0x98f5
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0x9959
xorl %r15d, %r15d
xorl %ebp, %ebp
movslq (%rax,%r15,4), %rax
movq 0x50(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7b24
addl %eax, %ebp
incq %r15
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0x992f
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %r13d
addl %eax, %ebp
movq 0x865e(%rip), %r15      # 0x11fd0
leaq 0x3685(%rip), %rsi      # 0xcffe
movl $0x13, %edx
movq %r15, %rdi
callq 0x31a0
movq %r15, %rdi
movl %r12d, %esi
callq 0x3200
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x364d(%rip), %rsi      # 0xd012
movl $0x14, %edx
movq %rax, %rdi
callq 0x31a0
movq %r15, %rdi
movl %r13d, %esi
callq 0x3200
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3616(%rip), %rsi      # 0xd027
movl $0x13, %edx
movq %rax, %rdi
callq 0x31a0
movq %r15, %rdi
movl %ebp, %esi
callq 0x3200
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movl %r12d, %r15d
subl %ebp, %r15d
cmpl %r13d, %r15d
jle 0x9c3b
movslq 0x10(%rsp), %rsi
shlq $0x3, %rsi
addq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
cmpq %rdx, %rsi
je 0x9ab3
leaq -0x8(%rsi), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x90(%rbx)
decl 0x80(%rbx)
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
movq 0x8500(%rip), %r15      # 0x11fd0
je 0x9b4a
movslq (%rax), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9af6
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%rbx)
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9b20
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9b15
leaq 0x4(%rdi), %rsi
movq 0x70(%rbx), %rdx
cmpq %rdx, %rsi
je 0x9b35
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
addq $-0x4, %rcx
movq %rcx, 0x70(%rbx)
cmpq %rax, %rcx
jne 0x9ad2
leaq 0x34ea(%rip), %rsi      # 0xd03b
movl $0x3a, %edx
movq %r15, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x34e7(%rip), %rsi      # 0xd076
movl $0x9, %edx
movq %rax, %rdi
callq 0x31a0
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq %r15, %rdi
callq 0x31a0
movq %rax, %r15
leaq 0x34c4(%rip), %rsi      # 0xd080
movl $0x2f, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x34b6(%rip), %rsi      # 0xd0b0
movl $0x19, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rbx, %rdi
callq 0x8790
jmp 0xa5bf
cmpl %ebp, %r12d
jle 0x9f3b
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0x9cc6
movslq (%rax), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9c72
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%rbx)
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9c9c
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9c91
leaq 0x4(%rdi), %rsi
movq 0x70(%rbx), %rdx
cmpq %rdx, %rsi
je 0x9cb1
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
addq $-0x4, %rcx
movq %rcx, 0x70(%rbx)
cmpq %rax, %rcx
jne 0x9c4e
movl $0x0, 0xc(%rsp)
testl %r15d, %r15d
jle 0x9d9e
leaq 0xc(%rsp), %r12
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b2c
movq 0x50(%r14), %rcx
movq 0x68(%r14), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
testb %al, %al
je 0x9d10
movq %r12, %rsi
callq 0x7b38
jmp 0x9d93
callq 0x7b20
addl %eax, 0xc(%rsp)
movq 0x68(%r14), %rax
movslq (%rax), %rax
movq 0x50(%r14), %rcx
movq 0x58(%r14), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9d41
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%r14)
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9d6b
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9d60
leaq 0x4(%rdi), %rsi
movq 0x70(%r14), %rdx
cmpq %rdx, %rsi
je 0x9d80
subq %rsi, %rdx
callq 0x31e0
addq $-0x4, 0x70(%r14)
movq 0x58(%r14), %rax
subq 0x50(%r14), %rax
cmpq $-0x8, %rax
je 0x9d9e
cmpl %r15d, 0xc(%rsp)
jl 0x9cdc
movq 0x68(%r14), %rax
cmpq %rax, 0x70(%r14)
je 0x9dec
xorl %r15d, %r15d
movslq (%rax,%r15,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7b64
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r15,4), %rcx
movq (%rax,%rcx,8), %rdi
movb $0x1, 0x2c(%rdi)
callq 0x7b7e
incq %r15
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0x9dab
leaq 0x32d7(%rip), %rsi      # 0xd0ca
movl $0x3a, %edx
movq 0x81d1(%rip), %r12      # 0x11fd0
movq %r12, %rdi
callq 0x31a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x32cc(%rip), %rsi      # 0xd105
movl $0x1a, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x32a9(%rip), %rsi      # 0xd120
movl $0x25, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3291(%rip), %rsi      # 0xd146
movl $0x31, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3285(%rip), %rsi      # 0xd178
movl $0x6f, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x32b7(%rip), %rsi      # 0xd1e8
movl $0x63, %edx
jmp 0xa378
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
jne 0xa11b
cmpq %rax, %rcx
movq 0x807d(%rip), %r12      # 0x11fd0
je 0x9fcd
movslq (%rax), %rax
movq 0x50(%r14), %rcx
movq 0x58(%r14), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9f79
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%r14)
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9fa3
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9f98
leaq 0x4(%rdi), %rsi
movq 0x70(%r14), %rdx
cmpq %rdx, %rsi
je 0x9fb8
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
addq $-0x4, %rcx
movq %rcx, 0x70(%r14)
cmpq %rax, %rcx
jne 0x9f55
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0xa04f
movslq (%rax), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9ffb
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%rbx)
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0xa025
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xa01a
leaq 0x4(%rdi), %rsi
movq 0x70(%rbx), %rdx
cmpq %rdx, %rsi
je 0xa03a
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
addq $-0x4, %rcx
movq %rcx, 0x70(%rbx)
cmpq %rax, %rcx
jne 0x9fd7
leaq 0x3074(%rip), %rsi      # 0xd0ca
movl $0x3a, %edx
movq %r12, %rdi
callq 0x31a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3070(%rip), %rsi      # 0xd105
movl $0x1a, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3179(%rip), %rsi      # 0xd24c
movl $0x26, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x3162(%rip), %rsi      # 0xd273
movl $0x3f, %edx
jmp 0xa33a
cmpq %rax, %rcx
je 0xa195
movslq (%rax), %rax
movq 0x50(%r14), %rcx
movq 0x58(%r14), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa144
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%r14)
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0xa16e
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xa163
leaq 0x4(%rdi), %rsi
movq 0x70(%r14), %rdx
cmpq %rdx, %rsi
je 0xa183
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
addq $-0x4, %rcx
movq %rcx, 0x70(%r14)
jmp 0xa11b
movl $0x0, 0xc(%rsp)
subl %r12d, %ebp
jle 0xa26c
leaq 0xc(%rsp), %r12
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b2c
movq 0x50(%rbx), %rcx
movq 0x68(%rbx), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
testb %al, %al
je 0xa1df
movq %r12, %rsi
callq 0x7b38
jmp 0xa262
callq 0x7b20
addl %eax, 0xc(%rsp)
movq 0x68(%rbx), %rax
movslq (%rax), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa210
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%rbx)
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0xa23a
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0xa22f
leaq 0x4(%rdi), %rsi
movq 0x70(%rbx), %rdx
cmpq %rdx, %rsi
je 0xa24f
subq %rsi, %rdx
callq 0x31e0
addq $-0x4, 0x70(%rbx)
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
cmpq $-0x8, %rax
je 0xa26c
cmpl %ebp, 0xc(%rsp)
jl 0xa1ab
leaq 0x2e57(%rip), %rsi      # 0xd0ca
movl $0x3a, %edx
movq 0x7d51(%rip), %r12      # 0x11fd0
movq %r12, %rdi
callq 0x31a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x2e4c(%rip), %rsi      # 0xd105
movl $0x1a, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x2ffc(%rip), %rsi      # 0xd2f3
movl $0x25, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x2fe4(%rip), %rsi      # 0xd319
movl $0x6f, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rax, %r15
leaq 0x2f40(%rip), %rsi      # 0xd2b3
movl $0x3f, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
leaq 0x2fdb(%rip), %rsi      # 0xd389
movl $0x2e, %edx
movq %r12, %rdi
callq 0x31a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq 0x68(%r14), %rax
cmpq %rax, 0x70(%r14)
je 0xa4d1
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq (%rax,%r12,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7bc8
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b28
testl %eax, %eax
jne 0xa4b3
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7bcc
movq 0x68(%r14), %rax
movslq (%rax,%r12,4), %rax
movq 0x50(%r14), %rcx
movq 0x58(%r14), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa463
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%r14)
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
leal 0x1(%r15), %edx
movslq %edx, %rdx
cmpq %rdx, %rcx
jbe 0xa48e
decl (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0xa483
leaq (%rax,%r12,4), %rsi
addq $0x4, %rsi
movq 0x70(%r14), %rdx
cmpq %rdx, %rsi
je 0xa4ab
leaq (%rax,%r12,4), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x4, 0x70(%r14)
decl %r15d
incl %r15d
movslq %r15d, %r12
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
ja 0xa3f7
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0xa5bf
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq (%rax,%r12,4), %rax
movq 0x50(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7bc8
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b28
testl %eax, %eax
jne 0xa5a1
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7bcc
movq 0x68(%rbx), %rax
movslq (%rax,%r12,4), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa551
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x8, 0x58(%rbx)
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
leal 0x1(%r15), %edx
movslq %edx, %rdx
cmpq %rdx, %rcx
jbe 0xa57c
decl (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0xa571
leaq (%rax,%r12,4), %rsi
addq $0x4, %rsi
movq 0x70(%rbx), %rdx
cmpq %rdx, %rsi
je 0xa599
leaq (%rax,%r12,4), %rdi
subq %rsi, %rdx
callq 0x31e0
addq $-0x4, 0x70(%rbx)
decl %r15d
incl %r15d
movslq %r15d, %r12
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
ja 0xa4e5
movq 0x7a0a(%rip), %r15      # 0x11fd0
leaq 0x2deb(%rip), %r12      # 0xd3b8
movl $0x6, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x31a0
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq %r15, %rdi
callq 0x31a0
movq %rax, %r13
leaq 0x2dc2(%rip), %rsi      # 0xd3bf
movl $0x9, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %r14, %rdi
callq 0xa6b6
movl $0x6, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x31a0
movq 0xa8(%rbx), %rsi
movq 0xb0(%rbx), %rdx
movq %r15, %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x2d5f(%rip), %rsi      # 0xd3c9
movl $0xa, %edx
movq %rax, %rdi
callq 0x31a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3160
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x30f0
movq %rbx, %rdi
callq 0xa6b6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop