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

	do{
		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 = vets.find(id_buscado);
					
		if(result != vets.end()){
			cout << "ID existe!" << endl;
			vets.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. */
			veterinario.open("veterinarios.txt");
			for(auto it = vets.begin(); it != vets.end(); it++){
				veterinario << (*it).second;
			}
			veterinario.close();
					
		}
		else{
			cout << "Funcionario não cadastrado!" << endl;
		}
		cout << "Deseja remover outro? s/n" << endl;
		getline(cin, op);
	}while(op == "s");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x8(%rbp)
movb $0x6e, -0xa(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3300
leaq -0x50(%rbp), %rdi
callq 0x3300
movl $0x0, -0x5c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x33b0
jmp 0x3ab5a
jmp 0x3ab5c
jmp 0x3ab5e
movq 0x16453(%rip), %rdi     # 0x50fb8
leaq 0x76bb(%rip), %rsi      # 0x42227
callq 0x3240
movq %rax, -0x438(%rbp)
jmp 0x3ab7a
movq -0x438(%rbp), %rdi
movq 0x16418(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3ab8f
cmpl $0x0, -0x5c(%rbp)
jne 0x3abdc
movq 0x1643c(%rip), %rdi     # 0x50fd8
callq 0x33f0
jmp 0x3aba3
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3abdc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x3af60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x3af54
movq 0x163f5(%rip), %rdi     # 0x50fd8
leaq -0x30(%rbp), %rsi
callq 0x3070
jmp 0x3abee
movl $0x0, -0x270(%rbp)
movl -0x270(%rbp), %eax
movl %eax, -0x43c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x31a0
movq %rax, %rcx
movl -0x43c(%rbp), %eax
cmpl %ecx, %eax
jge 0x3ac5c
movslq -0x270(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x3430
movq %rax, -0x448(%rbp)
jmp 0x3ac33
movq -0x448(%rbp), %rax
movb (%rax), %al
movb %al, -0x9(%rbp)
movsbl -0x9(%rbp), %edi
callq 0x3220
movl %eax, -0x58(%rbp)
movl -0x270(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x270(%rbp)
jmp 0x3abf8
cmpl $0x0, -0x58(%rbp)
jne 0x3acb5
movq 0x1634f(%rip), %rdi     # 0x50fb8
leaq 0x7799(%rip), %rsi      # 0x42409
callq 0x3240
movq %rax, -0x450(%rbp)
jmp 0x3ac7e
movq -0x450(%rbp), %rdi
movq 0x16314(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, -0x458(%rbp)
jmp 0x3ac9a
movq -0x458(%rbp), %rdi
movq 0x162f8(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3acaf
movb $0x6e, -0xa(%rbp)
jmp 0x3ad2b
movl $0x10, %edi
movl $0x8, %esi
callq 0x13c90
movl %eax, -0x45c(%rbp)
jmp 0x3accc
movl -0x45c(%rbp), %edx
leaq -0x3f8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3370
jmp 0x3ace4
leaq -0x3f8(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x3170
jmp 0x3acf6
movb $0x73, -0xa(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
jmp 0x3ad2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
jmp 0x3af54
jmp 0x3ad2d
movsbl -0xa(%rbp), %eax
cmpl $0x6e, %eax
je 0x3ab5e
movq -0x8(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x37990
movq %rax, -0x468(%rbp)
jmp 0x3ad50
movq -0x468(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1f740
movq %rax, -0x408(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x408(%rbp), %rsi
callq 0x1f710
testb $0x1, %al
jne 0x3ad8a
jmp 0x3ae8d
movq 0x16227(%rip), %rdi     # 0x50fb8
leaq 0x74a5(%rip), %rsi      # 0x4223d
callq 0x3240
movq %rax, -0x470(%rbp)
jmp 0x3ada6
movq -0x470(%rbp), %rdi
movq 0x161ec(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3adbb
movq -0x8(%rbp), %rdi
movq -0x400(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x410(%rbp), %rsi
callq 0x3b5e0
movq %rax, -0x478(%rbp)
jmp 0x3ade2
movq -0x478(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq 0x6b59(%rip), %rsi      # 0x41950
leaq -0x260(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x3ae0a
movq -0x8(%rbp), %rdi
callq 0x1f6e0
movq %rax, -0x420(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1f740
movq %rax, -0x428(%rbp)
leaq -0x420(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0x1f710
testb $0x1, %al
jne 0x3ae43
jmp 0x3ae7d
leaq -0x420(%rbp), %rdi
callq 0x1f770
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x260(%rbp), %rdi
callq 0x12a50
jmp 0x3ae64
jmp 0x3ae66
leaq -0x420(%rbp), %rdi
xorl %esi, %esi
callq 0x1f790
movq %rax, -0x430(%rbp)
jmp 0x3ae1a
leaq -0x260(%rbp), %rdi
callq 0x3310
jmp 0x3ae8b
jmp 0x3aec0
movq 0x16124(%rip), %rdi     # 0x50fb8
leaq 0x761a(%rip), %rsi      # 0x424b5
callq 0x3240
movq %rax, -0x480(%rbp)
jmp 0x3aea9
movq -0x480(%rbp), %rdi
movq 0x160e9(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3aebe
jmp 0x3aec0
movq 0x160f1(%rip), %rdi     # 0x50fb8
leaq 0x758c(%rip), %rsi      # 0x4245a
callq 0x3240
movq %rax, -0x488(%rbp)
jmp 0x3aedc
movq -0x488(%rbp), %rdi
movq 0x160b6(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3aef1
movq 0x160e0(%rip), %rdi     # 0x50fd8
leaq -0x50(%rbp), %rsi
callq 0x3070
jmp 0x3af03
jmp 0x3af05
leaq 0x66a5(%rip), %rsi      # 0x415b1
leaq -0x50(%rbp), %rdi
callq 0x144b0
movb %al, -0x489(%rbp)
jmp 0x3af1d
movb -0x489(%rbp), %al
testb $0x1, %al
jne 0x3ab5c
jmp 0x3af2d
leaq -0x260(%rbp), %rdi
callq 0x3340
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
leaq -0x260(%rbp), %rdi
callq 0x3340
leaq -0x50(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
movq -0x268(%rbp), %rdi
callq 0x33d0
nop