// File: /workspace/github_cpp_makefile_star2_O1/nataly-enne[P]pet-fera/pet_fera_remover.cpp
// Function: remover(std::map<int, MAMIFERO_NATIVO, std::less<int>, std::allocator<std::pair<int const, MAMIFERO_NATIVO>>>&, std::map<int, MAMIFERO_EXOTICO, std::less<int>, std::allocator<std::pair<int const, MAMIFERO_EXOTICO>>>&)
void remover(map <int, MAMIFERO_NATIVO> &mamiferos_nat, map <int, MAMIFERO_EXOTICO> &mamiferos_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 = mamiferos_nat.find(id_buscado);
					
				if(result != mamiferos_nat.end()){
					cout << "ID existe!" << endl;
					mamiferos_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("mamiferos_nat.txt");
					for(auto it = mamiferos_nat.begin(); it != mamiferos_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 = mamiferos_ex.find(id_buscado);
					
				if(result != mamiferos_ex.end()){
					cout << "ID existe!" << endl;
					mamiferos_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("mamiferos_ex.txt");
					for(auto it = mamiferos_ex.begin(); it != mamiferos_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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5d8, %rsp            # imm = 0x5D8
movq %rsi, -0x50(%rbp)
movq %rdi, -0x48(%rbp)
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x470(%rbp), %rdi
callq 0x3360
leaq -0x270(%rbp), %rdi
callq 0x3360
movq -0x50(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
movq 0x14581(%rip), %r13     # 0x47fd0
movq 0x1458a(%rip), %r12     # 0x47fe0
movl $0x2f, %edx
movq %r13, %rdi
leaq 0x77d2(%rip), %rsi      # 0x3b237
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
leaq -0x2b(%rbp), %rsi
callq 0x3280
movzbl -0x2b(%rbp), %eax
cmpl $0x65, %eax
je 0x33db1
cmpl $0x6e, %eax
je 0x33b79
movl $0x25, %edx
movq %r13, %rdi
leaq 0x774e(%rip), %rsi      # 0x3b211
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x10, %edx
movq %r13, %rdi
leaq 0x6af1(%rip), %rsi      # 0x3a618
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x3280
cmpb $0x73, -0x2a(%rbp)
je 0x33ff9
cmpb $0x73, -0x29(%rbp)
je 0x33a56
jmp 0x33ff9
movl $0x15, %edx
movq %r13, %rdi
leaq 0x76df(%rip), %rsi      # 0x3b267
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
testl %r14d, %r14d
jne 0x33bc8
movl $0x1, %r14d
movq %r12, %rdi
callq 0x33a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %edx
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
callq 0x33c0
movq -0x68(%rbp), %rax
testl %eax, %eax
jle 0x33c0b
decl %eax
movq -0x70(%rbp), %rcx
movsbl (%rcx,%rax), %eax
addl $-0x30, %eax
xorl %r15d, %r15d
cmpl $0xa, %eax
setb %r15b
testl %r15d, %r15d
je 0x33c51
leaq -0x5f8(%rbp), %rbx
movq %rbx, %rdi
leaq -0x70(%rbp), %rsi
movl $0x18, %edx
callq 0x3310
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x3120
movq %rbx, %rdi
movq 0x14372(%rip), %rsi     # 0x47fb0
callq 0x3160
leaq -0x578(%rbp), %rdi
callq 0x30d0
jmp 0x33cb7
movl $0x38, %edx
movq %r13, %rdi
leaq 0x77e9(%rip), %rsi      # 0x3b449
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
testl %r15d, %r15d
je 0x33b79
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x38(%rbp), %rax
testq %rcx, %rcx
je 0x33cef
movl -0x30(%rbp), %edx
movq -0x38(%rbp), %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x33cd8
movq -0x38(%rbp), %rdx
movq %rdx, %rbx
cmpq %rdx, %rax
je 0x33d08
movl -0x30(%rbp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %rdx, %rax
movq %rax, %rbx
cmpq %rdx, %rbx
je 0x33f70
movl $0xa, %edx
movq %r13, %rdi
leaq 0x755d(%rip), %rsi      # 0x3b27d
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x3590c
leaq -0x470(%rbp), %rdi
leaq 0x7292(%rip), %rsi      # 0x3aff9
movl $0x10, %edx
callq 0x3050
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rbx
cmpq -0x38(%rbp), %rbx
je 0x33da0
leaq 0x28(%rbx), %rsi
leaq -0x470(%rbp), %rdi
callq 0xad94
movq %rbx, %rdi
callq 0x3140
movq %rax, %rbx
cmpq -0x38(%rbp), %rax
jne 0x33d7f
leaq -0x470(%rbp), %rdi
callq 0x32a0
jmp 0x33fac
movl $0x15, %edx
movq %r13, %rdi
leaq 0x74a7(%rip), %rsi      # 0x3b267
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x3120
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x40(%rbp), %rax
testq %rcx, %rcx
je 0x33e28
movl -0x30(%rbp), %edx
movq -0x40(%rbp), %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x33e11
movq -0x40(%rbp), %rdx
movq %rdx, %rbx
cmpq %rdx, %rax
je 0x33e41
movl -0x30(%rbp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %rdx, %rax
movq %rax, %rbx
cmpq %rdx, %rbx
je 0x33ee7
movl $0xa, %edx
movq %r13, %rdi
leaq 0x7424(%rip), %rsi      # 0x3b27d
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0x35942
leaq -0x270(%rbp), %rdi
leaq 0x716b(%rip), %rsi      # 0x3b00b
movl $0x10, %edx
callq 0x3050
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rbx
cmpq -0x40(%rbp), %rbx
je 0x33ed9
leaq 0x28(%rbx), %rsi
leaq -0x270(%rbp), %rdi
callq 0xb3e7
movq %rbx, %rdi
callq 0x3140
movq %rax, %rbx
cmpq -0x40(%rbp), %rax
jne 0x33eb8
leaq -0x270(%rbp), %rdi
callq 0x32a0
jmp 0x33f23
movl $0x17, %edx
movq %r13, %rdi
leaq 0x758c(%rip), %rsi      # 0x3b482
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x19, %edx
movq %r13, %rdi
leaq 0x7568(%rip), %rsi      # 0x3b49a
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3280
jmp 0x33b6a
movl $0x17, %edx
movq %r13, %rdi
leaq 0x7503(%rip), %rsi      # 0x3b482
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x19, %edx
movq %r13, %rdi
leaq 0x74df(%rip), %rsi      # 0x3b49a
callq 0x3250
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq %r12, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3280
jmp 0x33b6a
movq 0x13fc8(%rip), %rax     # 0x47fc8
movq (%rax), %rbx
movq 0x18(%rax), %r14
leaq -0x268(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x270(%rbp,%rax)
callq 0x3190
movl $0xf8, %r15d
leaq -0x270(%rbp), %rdi
addq %r15, %rdi
callq 0x30d0
leaq -0x468(%rbp), %rdi
movq %rbx, -0x8(%rdi)
movq -0x18(%rbx), %rax
movq %r14, -0x470(%rbp,%rax)
callq 0x3190
leaq -0x470(%rbp), %rdi
addq %r15, %rdi
callq 0x30d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x34075
callq 0x31d0
addq $0x5d8, %rsp            # imm = 0x5D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x340d2
movq %rax, %rbx
jmp 0x340de
jmp 0x340c3
jmp 0x340c3
jmp 0x340c3
jmp 0x340c3
jmp 0x340c3
jmp 0x340c3
movq %rax, %rbx
movq 0x13f09(%rip), %rsi     # 0x47fb0
leaq -0x5f8(%rbp), %rdi
callq 0x3160
leaq -0x578(%rbp), %rdi
callq 0x30d0
jmp 0x340c6
jmp 0x340c3
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
callq 0x32e0
leaq -0x470(%rbp), %rdi
callq 0x32e0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x340f0
callq 0x31d0
movq %rbx, %rdi
callq 0x3380