// File: nataly-enne[P]pet-fera/pet_fera_remover.cpp
// Function: remover(std::map<int, AVE_NATIVO, std::less<int>, std::allocator<std::pair<int const, AVE_NATIVO>>>&, std::map<int, AVE_EXOTICO, std::less<int>, std::allocator<std::pair<int const, AVE_EXOTICO>>>&)
void remover(map <int, AVE_NATIVO> &aves_nat, map <int, AVE_EXOTICO> &aves_ex){
	char op, opcao, resp, c, sucesso = 'n';
	string id_buscado_string;
	int id_buscado, verificacao, cont = 0;
	ofstream nativos;
	ofstream exoticos;
			

	do{
		cout << "É nativo ou exotico? \n n - NATIVO\n e - EXOTICO" << endl;
		cin >> opcao;
		if(opcao != 'n' && opcao != 'e'){
			cout << "Opção inválida!! Tente novamente!\n" << endl;
			cout << endl;
			cout << "Deseja sair? s/n" << endl;
			cin >> resp;
			if(resp == 's'){
				break;
			}	
		}
		else{ 
			if(opcao == 'n'){
				do{
					cout << "Insira o ID buscado: " << endl;
					if(!cont){
						cin.ignore();
						cont++;
					}
					getline(cin, id_buscado_string);
					for(int i=0; i<(int)id_buscado_string.size(); i++){
						c = id_buscado_string[i];
						verificacao = isdigit(c);
					}
					if(!verificacao){
						cout << "ERRO: apenas numeros inteiros positivos são permitidos!"<< endl << endl;
						sucesso = 'n';
					}else{
						stringstream ss(id_buscado_string);
						ss >> id_buscado;
						sucesso = 's';
					}
				}while(sucesso == 'n');

				auto result = aves_nat.find(id_buscado);
					
				if(result != aves_nat.end()){
					cout << "ID existe!" << endl;
					aves_nat.erase(result);

					/* A condição do map não ser vazio para escrever no arquivo foi removido, para que mesmo quando o map estiver vazio escreva no arquivo
					senão, quando o arquivo só tiver uma linha e o usuário for apagar essa linha, mesmo assim o arquivo permacerá com essa linha. */
					nativos.open("aves_nat.txt");
					for(auto it = aves_nat.begin(); it != aves_nat.end(); it++){
						nativos << (*it).second;
					}
						nativos.close();
					//sucesso = 's';
				}
				else{
					cout << "Animal não cadastrado!" << endl;
				}
				cout << "Deseja remover outro? s/n" << endl;
				cin >> op;

			}
			else{
				cout << "Insira o ID buscado: " << endl;
				cin >> id_buscado;

				auto result = aves_ex.find(id_buscado);
					
				if(result != aves_ex.end()){
					cout << "ID existe!" << endl;
					aves_ex.erase(result);

					/* A condição do map não ser vazio para escrever no arquivo foi removido, para que mesmo quando o map estiver vazio escreva no arquivo
					senão, quando o arquivo só tiver uma linha e o usuário for apagar essa linha, mesmo assim o arquivo permacerá com essa linha. */
					exoticos.open("aves_ex.txt");
					for(auto it = aves_ex.begin(); it != aves_ex.end(); it++){
						exoticos << (*it).second;
					}
					exoticos.close();
					// sucesso = 's';
				}
				else{
					cout << "Animal não cadastrado!" << endl;
				}
				cout << "Deseja remover outro? s/n" << endl;
				cin >> op;
			}
		} // Primeiro else.
	}while(op == 's');
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x700, %rsp            # imm = 0x700
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x6e, -0x15(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3300
movl $0x0, -0x44(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x33b0
jmp 0x3a2c5
leaq -0x458(%rbp), %rdi
callq 0x33b0
jmp 0x3a2d3
jmp 0x3a2d5
movq 0x16cdc(%rip), %rdi     # 0x50fb8
leaq 0x7f14(%rip), %rsi      # 0x421f7
callq 0x3240
movq %rax, -0x660(%rbp)
jmp 0x3a2f1
movq -0x660(%rbp), %rdi
movq 0x16ca1(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a306
movq 0x16ccb(%rip), %rdi     # 0x50fd8
leaq -0x12(%rbp), %rsi
callq 0x32e0
jmp 0x3a318
movsbl -0x12(%rbp), %eax
cmpl $0x6e, %eax
je 0x3a413
movsbl -0x12(%rbp), %eax
cmpl $0x65, %eax
je 0x3a413
movq 0x16c7f(%rip), %rdi     # 0x50fb8
leaq 0x7e91(%rip), %rsi      # 0x421d1
callq 0x3240
movq %rax, -0x668(%rbp)
jmp 0x3a34e
movq -0x668(%rbp), %rdi
movq 0x16c44(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a363
movq 0x16c4e(%rip), %rdi     # 0x50fb8
movq 0x16c2f(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a378
movq 0x16c39(%rip), %rdi     # 0x50fb8
leaq 0x7252(%rip), %rsi      # 0x415d8
callq 0x3240
movq %rax, -0x670(%rbp)
jmp 0x3a394
movq -0x670(%rbp), %rdi
movq 0x16bfe(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a3a9
movq 0x16c28(%rip), %rdi     # 0x50fd8
leaq -0x13(%rbp), %rsi
callq 0x32e0
jmp 0x3a3bb
movsbl -0x13(%rbp), %eax
cmpl $0x73, %eax
jne 0x3a40e
jmp 0x3a9bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x3a9fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x3a9f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
jmp 0x3a9e5
jmp 0x3a9ac
movsbl -0x12(%rbp), %eax
cmpl $0x6e, %eax
jne 0x3a79c
jmp 0x3a422
movq 0x16b8f(%rip), %rdi     # 0x50fb8
leaq 0x7df7(%rip), %rsi      # 0x42227
callq 0x3240
movq %rax, -0x678(%rbp)
jmp 0x3a43e
movq -0x678(%rbp), %rdi
movq 0x16b54(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a453
cmpl $0x0, -0x44(%rbp)
jne 0x3a470
movq 0x16b78(%rip), %rdi     # 0x50fd8
callq 0x33f0
jmp 0x3a467
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq 0x16b61(%rip), %rdi     # 0x50fd8
leaq -0x38(%rbp), %rsi
callq 0x3070
jmp 0x3a482
movl $0x0, -0x45c(%rbp)
movl -0x45c(%rbp), %eax
movl %eax, -0x67c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movl -0x67c(%rbp), %eax
cmpl %ecx, %eax
jge 0x3a4f0
movslq -0x45c(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x3430
movq %rax, -0x688(%rbp)
jmp 0x3a4c7
movq -0x688(%rbp), %rax
movb (%rax), %al
movb %al, -0x14(%rbp)
movsbl -0x14(%rbp), %edi
callq 0x3220
movl %eax, -0x40(%rbp)
movl -0x45c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x45c(%rbp)
jmp 0x3a48c
cmpl $0x0, -0x40(%rbp)
jne 0x3a549
movq 0x16abb(%rip), %rdi     # 0x50fb8
leaq 0x7f05(%rip), %rsi      # 0x42409
callq 0x3240
movq %rax, -0x690(%rbp)
jmp 0x3a512
movq -0x690(%rbp), %rdi
movq 0x16a80(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, -0x698(%rbp)
jmp 0x3a52e
movq -0x698(%rbp), %rdi
movq 0x16a64(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a543
movb $0x6e, -0x15(%rbp)
jmp 0x3a5bf
movl $0x10, %edi
movl $0x8, %esi
callq 0x13c90
movl %eax, -0x69c(%rbp)
jmp 0x3a560
movl -0x69c(%rbp), %edx
leaq -0x5e8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3370
jmp 0x3a578
leaq -0x5e8(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x3170
jmp 0x3a58a
movb $0x73, -0x15(%rbp)
leaq -0x5e8(%rbp), %rdi
callq 0x31b0
jmp 0x3a5bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x250(%rbp)
movl %eax, -0x254(%rbp)
leaq -0x5e8(%rbp), %rdi
callq 0x31b0
jmp 0x3a9e5
jmp 0x3a5c1
movsbl -0x15(%rbp), %eax
cmpl $0x6e, %eax
je 0x3a422
movq -0x8(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x37890
movq %rax, -0x6a8(%rbp)
jmp 0x3a5e4
movq -0x6a8(%rbp), %rax
movq %rax, -0x5f0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x14310
movq %rax, -0x5f8(%rbp)
leaq -0x5f0(%rbp), %rdi
leaq -0x5f8(%rbp), %rsi
callq 0x142e0
testb $0x1, %al
jne 0x3a61e
jmp 0x3a721
movq 0x16993(%rip), %rdi     # 0x50fb8
leaq 0x7c11(%rip), %rsi      # 0x4223d
callq 0x3240
movq %rax, -0x6b0(%rbp)
jmp 0x3a63a
movq -0x6b0(%rbp), %rdi
movq 0x16958(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a64f
movq -0x8(%rbp), %rdi
movq -0x5f0(%rbp), %rax
movq %rax, -0x600(%rbp)
movq -0x600(%rbp), %rsi
callq 0x3b560
movq %rax, -0x6b8(%rbp)
jmp 0x3a676
movq -0x6b8(%rbp), %rax
movq %rax, -0x608(%rbp)
leaq 0x7ac8(%rip), %rsi      # 0x42153
leaq -0x248(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x3a69e
movq -0x8(%rbp), %rdi
callq 0x142b0
movq %rax, -0x610(%rbp)
movq -0x8(%rbp), %rdi
callq 0x14310
movq %rax, -0x618(%rbp)
leaq -0x610(%rbp), %rdi
leaq -0x618(%rbp), %rsi
callq 0x142e0
testb $0x1, %al
jne 0x3a6d7
jmp 0x3a711
leaq -0x610(%rbp), %rdi
callq 0x20180
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x248(%rbp), %rdi
callq 0x11790
jmp 0x3a6f8
jmp 0x3a6fa
leaq -0x610(%rbp), %rdi
xorl %esi, %esi
callq 0x14370
movq %rax, -0x620(%rbp)
jmp 0x3a6ae
leaq -0x248(%rbp), %rdi
callq 0x3310
jmp 0x3a71f
jmp 0x3a754
movq 0x16890(%rip), %rdi     # 0x50fb8
leaq 0x7d13(%rip), %rsi      # 0x42442
callq 0x3240
movq %rax, -0x6c0(%rbp)
jmp 0x3a73d
movq -0x6c0(%rbp), %rdi
movq 0x16855(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a752
jmp 0x3a754
movq 0x1685d(%rip), %rdi     # 0x50fb8
leaq 0x7cf8(%rip), %rsi      # 0x4245a
callq 0x3240
movq %rax, -0x6c8(%rbp)
jmp 0x3a770
movq -0x6c8(%rbp), %rdi
movq 0x16822(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a785
movq 0x1684c(%rip), %rdi     # 0x50fd8
leaq -0x11(%rbp), %rsi
callq 0x32e0
jmp 0x3a797
jmp 0x3a9aa
movq 0x16815(%rip), %rdi     # 0x50fb8
leaq 0x7a7d(%rip), %rsi      # 0x42227
callq 0x3240
movq %rax, -0x6d0(%rbp)
jmp 0x3a7b8
movq -0x6d0(%rbp), %rdi
movq 0x167da(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a7cd
movq 0x16804(%rip), %rdi     # 0x50fd8
leaq -0x3c(%rbp), %rsi
callq 0x3170
jmp 0x3a7df
movq -0x10(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x37910
movq %rax, -0x6d8(%rbp)
jmp 0x3a7f5
movq -0x6d8(%rbp), %rax
movq %rax, -0x628(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14410
movq %rax, -0x630(%rbp)
leaq -0x628(%rbp), %rdi
leaq -0x630(%rbp), %rsi
callq 0x143e0
testb $0x1, %al
jne 0x3a82f
jmp 0x3a932
movq 0x16782(%rip), %rdi     # 0x50fb8
leaq 0x7a00(%rip), %rsi      # 0x4223d
callq 0x3240
movq %rax, -0x6e0(%rbp)
jmp 0x3a84b
movq -0x6e0(%rbp), %rdi
movq 0x16747(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a860
movq -0x10(%rbp), %rdi
movq -0x628(%rbp), %rax
movq %rax, -0x638(%rbp)
movq -0x638(%rbp), %rsi
callq 0x3b5a0
movq %rax, -0x6e8(%rbp)
jmp 0x3a887
movq -0x6e8(%rbp), %rax
movq %rax, -0x640(%rbp)
leaq 0x78c4(%rip), %rsi      # 0x42160
leaq -0x458(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x3a8af
movq -0x10(%rbp), %rdi
callq 0x143b0
movq %rax, -0x648(%rbp)
movq -0x10(%rbp), %rdi
callq 0x14410
movq %rax, -0x650(%rbp)
leaq -0x648(%rbp), %rdi
leaq -0x650(%rbp), %rsi
callq 0x143e0
testb $0x1, %al
jne 0x3a8e8
jmp 0x3a922
leaq -0x648(%rbp), %rdi
callq 0x201c0
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x458(%rbp), %rdi
callq 0x11d60
jmp 0x3a909
jmp 0x3a90b
leaq -0x648(%rbp), %rdi
xorl %esi, %esi
callq 0x14470
movq %rax, -0x658(%rbp)
jmp 0x3a8bf
leaq -0x458(%rbp), %rdi
callq 0x3310
jmp 0x3a930
jmp 0x3a965
movq 0x1667f(%rip), %rdi     # 0x50fb8
leaq 0x7b02(%rip), %rsi      # 0x42442
callq 0x3240
movq %rax, -0x6f0(%rbp)
jmp 0x3a94e
movq -0x6f0(%rbp), %rdi
movq 0x16644(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a963
jmp 0x3a965
movq 0x1664c(%rip), %rdi     # 0x50fb8
leaq 0x7ae7(%rip), %rsi      # 0x4245a
callq 0x3240
movq %rax, -0x6f8(%rbp)
jmp 0x3a981
movq -0x6f8(%rbp), %rdi
movq 0x16611(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3a996
movq 0x1663b(%rip), %rdi     # 0x50fd8
leaq -0x11(%rbp), %rsi
callq 0x32e0
jmp 0x3a9a8
jmp 0x3a9aa
jmp 0x3a9ac
jmp 0x3a9ae
movsbl -0x11(%rbp), %eax
cmpl $0x73, %eax
je 0x3a2d5
leaq -0x458(%rbp), %rdi
callq 0x3340
leaq -0x248(%rbp), %rdi
callq 0x3340
leaq -0x38(%rbp), %rdi
callq 0x3180
addq $0x700, %rsp            # imm = 0x700
popq %rbp
retq
leaq -0x458(%rbp), %rdi
callq 0x3340
leaq -0x248(%rbp), %rdi
callq 0x3340
leaq -0x38(%rbp), %rdi
callq 0x3180
movq -0x250(%rbp), %rdi
callq 0x33d0
nopw %cs:(%rax,%rax)