// File: /workspace/github_cpp_makefile_star2_O3/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 0x8a57(%rip), %r15      # 0x11fd0
movq %r15, %rdi
callq 0x31a0
movq %rax, %r12
leaq 0x390a(%rip), %rsi      # 0xce95
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 0x3915(%rip), %rsi      # 0xcedf
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 0x38fa(%rip), %rsi      # 0xcf19
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 0x29e2(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
leaq 0xc(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq 0x8976(%rip), %r13      # 0x11fe0
testl %eax, %eax
jle 0x9681
movl %eax, %eax
movq 0x58(%r14), %rcx
subq 0x50(%r14), %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
jae 0x96c8
movq %r13, %rdi
movq %r12, %rsi
callq 0x30d0
movl 0xc(%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
movl 0xc(%rsp), %eax
jmp 0x966a
movq %r14, %rdi
callq 0x91d4
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq 0x88eb(%rip), %rdi      # 0x11fd0
callq 0x31a0
movq %rax, %r15
leaq 0x3837(%rip), %rsi      # 0xcf2b
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 0x3839(%rip), %rsi      # 0xcf6b
movl $0x5, %edx
movq %rax, %rdi
callq 0x31a0
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0x3200
movq %rax, %r15
leaq 0x381c(%rip), %rsi      # 0xcf71
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 0x28ac(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
movl $0x0, 0x8(%rsp)
movq 0x68(%r14), %rax
cmpq %rax, 0x70(%r14)
je 0x97a0
movq %rax, 0x70(%r14)
leaq 0x68(%r14), %rax
movq %rax, 0x10(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0x9806
xorl %r12d, %r12d
movq 0x8826(%rip), %r13      # 0x11fe0
leaq 0x8(%rsp), %rbp
leaq 0x4(%rsp), %r15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x30d0
movl 0x8(%rsp), %eax
decl %eax
movl %eax, 0x4(%rsp)
movq 0x70(%r14), %rsi
cmpq 0x78(%r14), %rsi
je 0x97ef
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x70(%r14)
jmp 0x97fc
movq 0x10(%rsp), %rdi
movq %r15, %rdx
callq 0xbbc8
incl %r12d
cmpl 0xc(%rsp), %r12d
jl 0x97c4
movq %r14, %rdi
callq 0xa7f8
testq %rbx, %rbx
je 0xa7e9
leaq 0x3884(%rip), %rsi      # 0xd0a2
movl $0x13, %edx
movq 0x87a6(%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 0x87f4
movq 0xa8(%r14), %rsi
movq 0xb0(%r14), %rdx
movq %r15, %rdi
callq 0x31a0
movq %rax, %r15
leaq 0x3708(%rip), %rsi      # 0xcf89
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 0x36f4(%rip), %rsi      # 0xcfb3
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 0x36c9(%rip), %rsi      # 0xcfd7
movl $0x12, %edx
movq %rax, %rdi
callq 0x31a0
movl 0x80(%rbx), %esi
movq %r15, %rdi
callq 0x3200
leaq 0x26f9(%rip), %rsi      # 0xc029
movl $0x3, %edx
movq %rax, %rdi
callq 0x31a0
leaq 0x8(%rsp), %r15
movl $0x0, (%r15)
xorl %eax, %eax
movq 0x868e(%rip), %r12      # 0x11fe0
testl %eax, %eax
jle 0x995e
cmpl 0x80(%rbx), %eax
jle 0x996f
movq %r12, %rdi
movq %r15, %rsi
callq 0x30d0
movl 0x8(%rsp), %eax
jmp 0x9952
movq 0x68(%r14), %rax
xorl %ebp, %ebp
movl $0x0, %r13d
cmpq %rax, 0x70(%r14)
je 0x99b2
xorl %r15d, %r15d
xorl %r13d, %r13d
movslq (%rax,%r15,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7b80
addl %eax, %r13d
incq %r15
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0x9987
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0x99eb
xorl %r15d, %r15d
xorl %ebp, %ebp
movslq (%rax,%r15,4), %rax
movq 0x50(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7b84
addl %eax, %ebp
incq %r15
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0x99c1
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movl %eax, %r12d
addl %eax, %ebp
movq 0x85cc(%rip), %r15      # 0x11fd0
leaq 0x35df(%rip), %rsi      # 0xcfea
movl $0x13, %edx
movq %r15, %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 0x35a7(%rip), %rsi      # 0xcffe
movl $0x14, %edx
movq %rax, %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 0x3570(%rip), %rsi      # 0xd013
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 %r13d, %r15d
subl %ebp, %r15d
cmpl %r12d, %r15d
jle 0x9bf6
movslq 0x8(%rsp), %rsi
shlq $0x3, %rsi
addq 0x88(%rbx), %rsi
movq 0x90(%rbx), %rdx
cmpq %rdx, %rsi
je 0x9b4c
leaq -0x8(%rsi), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x90(%rbx), %rdx
movq 0x847d(%rip), %r15      # 0x11fd0
addq $-0x8, %rdx
movq %rdx, 0x90(%rbx)
decl 0x80(%rbx)
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
cmpq %rdi, %rdx
je 0x9c91
movslq (%rdi), %rcx
movq 0x50(%rbx), %r8
movq 0x58(%rbx), %rax
leaq (%r8,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rax, %rsi
je 0x9ba8
leaq (%r8,%rcx,8), %rdi
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%rbx), %rax
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x8, %rax
movq %rax, 0x58(%rbx)
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9bd0
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9bc5
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x9be9
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%rbx)
jmp 0x9b6c
cmpl %ebp, %r13d
jle 0x9d82
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
cmpq %rdi, %rdx
je 0x9f41
movslq (%rdi), %rcx
movq 0x50(%rbx), %r8
movq 0x58(%rbx), %rax
leaq (%r8,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rax, %rsi
je 0x9c43
leaq (%r8,%rcx,8), %rdi
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%rbx), %rax
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x8, %rax
movq %rax, 0x58(%rbx)
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9c6b
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9c60
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x9c84
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%rbx)
jmp 0x9c07
leaq 0x338f(%rip), %rsi      # 0xd027
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 0x338c(%rip), %rsi      # 0xd062
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 0x3369(%rip), %rsi      # 0xd06c
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 0x335b(%rip), %rsi      # 0xd09c
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 0x87f4
jmp 0xa702
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rdx
jne 0x9eb7
cmpq %rdi, %rdx
movq 0x8236(%rip), %r12      # 0x11fd0
je 0x9e25
movslq (%rdi), %rcx
movq 0x50(%r14), %r8
movq 0x58(%r14), %rax
leaq (%r8,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rax, %rsi
je 0x9dd3
leaq (%r8,%rcx,8), %rdi
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%r14), %rax
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rdx
addq $-0x8, %rax
movq %rax, 0x58(%r14)
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9dfb
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9df0
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x9e14
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%r14)
cmpq %rdi, %rdx
jne 0x9da0
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
cmpq %rdi, %rdx
je 0xa1d6
movslq (%rdi), %rcx
movq 0x50(%rbx), %r8
movq 0x58(%rbx), %rax
leaq (%r8,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rax, %rsi
je 0x9e69
leaq (%r8,%rcx,8), %rdi
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%rbx), %rax
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x8, %rax
movq %rax, 0x58(%rbx)
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9e91
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9e86
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x9eaa
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%rbx), %rdi
movq 0x70(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%rbx)
jmp 0x9e2d
cmpq %rdi, %rdx
je 0xa2a2
movslq (%rdi), %rcx
movq 0x50(%r14), %r8
movq 0x58(%r14), %rax
leaq (%r8,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rax, %rsi
je 0x9ef3
leaq (%r8,%rcx,8), %rdi
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%r14), %rax
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rdx
addq $-0x8, %rax
movq %rax, 0x58(%r14)
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9f1b
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9f10
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0x9f34
subq %rsi, %rdx
callq 0x31e0
movq 0x68(%r14), %rdi
movq 0x70(%r14), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%r14)
jmp 0x9eb7
movl $0x0, 0x4(%rsp)
testl %r15d, %r15d
jle 0xa039
leaq 0x4(%rsp), %r12
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b8c
movq 0x50(%r14), %rcx
movq 0x68(%r14), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
testb %al, %al
jne 0xa026
callq 0x7b80
addl %eax, 0x4(%rsp)
movq 0x68(%r14), %rdi
movslq (%rdi), %rax
movq 0x50(%r14), %rcx
movq 0x58(%r14), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x9fbb
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x58(%r14), %rdx
movq 0x68(%r14), %rdi
addq $-0x8, %rdx
movq %rdx, 0x58(%r14)
movq 0x70(%r14), %rdx
movq %rdx, %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq $0x2, %rax
jb 0x9feb
movl $0x1, %ecx
decl (%rdi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x9fdc
movq 0x70(%r14), %rdx
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0xa000
subq %rsi, %rdx
callq 0x31e0
movq 0x70(%r14), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%r14)
movq 0x50(%r14), %rax
movq 0x58(%r14), %rcx
subq %rax, %rcx
cmpq $-0x8, %rcx
je 0xa039
cmpl %r15d, 0x4(%rsp)
jl 0x9f5b
jmp 0xa039
movq %r12, %rsi
callq 0x7b98
cmpl %r15d, 0x4(%rsp)
jl 0x9f57
movq 0x68(%r14), %rax
cmpq %rax, 0x70(%r14)
je 0xa087
xorl %r15d, %r15d
movslq (%rax,%r15,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7bc4
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r15,4), %rcx
movq (%rax,%rcx,8), %rdi
movb $0x1, 0x2c(%rdi)
callq 0x7bde
incq %r15
movq 0x68(%r14), %rax
movq 0x70(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0xa046
leaq 0x3028(%rip), %rsi      # 0xd0b6
movl $0x3a, %edx
movq 0x7f36(%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 0x301d(%rip), %rsi      # 0xd0f1
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 0x2ffa(%rip), %rsi      # 0xd10c
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 0x2fe2(%rip), %rsi      # 0xd132
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 0x2fd6(%rip), %rsi      # 0xd164
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 0x3008(%rip), %rsi      # 0xd1d4
movl $0x63, %edx
jmp 0xa499
leaq 0x2ed9(%rip), %rsi      # 0xd0b6
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 0x2ed5(%rip), %rsi      # 0xd0f1
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 0x2fde(%rip), %rsi      # 0xd238
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 0x2fc7(%rip), %rsi      # 0xd25f
movl $0x3f, %edx
jmp 0xa45b
movl $0x0, 0x4(%rsp)
subl %r13d, %ebp
jle 0xa38d
leaq 0x4(%rsp), %r12
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b8c
movq 0x50(%rbx), %rcx
movq 0x68(%rbx), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
testb %al, %al
je 0xa2ec
movq %r12, %rsi
callq 0x7b98
jmp 0xa383
callq 0x7b80
addl %eax, 0x4(%rsp)
movq 0x68(%rbx), %rdi
movslq (%rdi), %rax
movq 0x50(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa325
leaq (%rcx,%rax,8), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x58(%rbx), %rdx
movq 0x68(%rbx), %rdi
addq $-0x8, %rdx
movq %rdx, 0x58(%rbx)
movq 0x70(%rbx), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
cmpq $0x2, %rcx
jb 0xa355
movl $0x1, %eax
decl (%rdi,%rax,4)
incq %rax
cmpq %rax, %rcx
jne 0xa346
movq 0x70(%rbx), %rax
leaq 0x4(%rdi), %rsi
cmpq %rax, %rsi
je 0xa371
subq %rsi, %rax
movq %rax, %rdx
callq 0x31e0
movq 0x58(%rbx), %rdx
movq 0x70(%rbx), %rax
addq $-0x4, %rax
movq %rax, 0x70(%rbx)
subq 0x50(%rbx), %rdx
cmpq $-0x8, %rdx
je 0xa38d
cmpl %ebp, 0x4(%rsp)
jl 0xa2b8
leaq 0x2d22(%rip), %rsi      # 0xd0b6
movl $0x3a, %edx
movq 0x7c30(%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 0x2d17(%rip), %rsi      # 0xd0f1
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 0x2ec7(%rip), %rsi      # 0xd2df
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 0x2eaf(%rip), %rsi      # 0xd305
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 0x2e0b(%rip), %rsi      # 0xd29f
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 0x2ea6(%rip), %rsi      # 0xd375
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 0xa605
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq (%rax,%r12,4), %rax
movq 0x50(%r14), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7c28
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b88
testl %eax, %eax
je 0xa54e
movq 0x70(%r14), %rdx
incl %r15d
jmp 0xa5ea
movq 0x50(%r14), %rax
movq 0x68(%r14), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7c2c
movq 0x68(%r14), %rax
movslq (%rax,%r12,4), %rcx
movq 0x50(%r14), %rdi
movq 0x58(%r14), %rdx
leaq (%rdi,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa594
leaq (%rdi,%rcx,8), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x58(%r14), %rdx
movq 0x68(%r14), %rax
addq $-0x8, %rdx
movq %rdx, 0x58(%r14)
movq 0x70(%r14), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x2, %rcx
leal 0x1(%r15), %esi
movslq %esi, %rsi
cmpq %rsi, %rcx
jbe 0xa5c5
decl (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0xa5b6
movq 0x70(%r14), %rdx
leaq (%rax,%r12,4), %rsi
addq $0x4, %rsi
cmpq %rdx, %rsi
je 0xa5e2
leaq (%rax,%r12,4), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x70(%r14), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%r14)
movslq %r15d, %r12
movq 0x10(%rsp), %rax
movq (%rax), %rax
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
ja 0xa518
movq 0x68(%rbx), %rax
cmpq %rax, 0x70(%rbx)
je 0xa702
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq (%rax,%r12,4), %rax
movq 0x50(%rbx), %rcx
movq (%rcx,%rax,8), %rdi
callq 0x7c28
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7b88
testl %eax, %eax
je 0xa64f
movq 0x70(%rbx), %rdx
incl %r15d
jmp 0xa6eb
movq 0x50(%rbx), %rax
movq 0x68(%rbx), %rcx
movslq (%rcx,%r12,4), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x7c2c
movq 0x68(%rbx), %rax
movslq (%rax,%r12,4), %rcx
movq 0x50(%rbx), %rdi
movq 0x58(%rbx), %rdx
leaq (%rdi,%rcx,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0xa695
leaq (%rdi,%rcx,8), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x58(%rbx), %rdx
movq 0x68(%rbx), %rax
addq $-0x8, %rdx
movq %rdx, 0x58(%rbx)
movq 0x70(%rbx), %rdx
movq %rdx, %rcx
subq %rax, %rcx
sarq $0x2, %rcx
leal 0x1(%r15), %esi
movslq %esi, %rsi
cmpq %rsi, %rcx
jbe 0xa6c6
decl (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0xa6b7
movq 0x70(%rbx), %rdx
leaq (%rax,%r12,4), %rsi
addq $0x4, %rsi
cmpq %rdx, %rsi
je 0xa6e3
leaq (%rax,%r12,4), %rdi
subq %rsi, %rdx
callq 0x31e0
movq 0x70(%rbx), %rdx
addq $-0x4, %rdx
movq %rdx, 0x70(%rbx)
movslq %r15d, %r12
movq 0x68(%rbx), %rax
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
ja 0xa619
movq 0x78c7(%rip), %r15      # 0x11fd0
leaq 0x2c94(%rip), %r12      # 0xd3a4
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 0x2c6b(%rip), %rsi      # 0xd3ab
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 0xa7f8
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 0x2c08(%rip), %rsi      # 0xd3b5
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 0xa7f8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq