// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
movq %rdi, %rbx
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x278(%rbp), %rdi
callq 0x3360
movq %rbx, -0x30(%rbp)
leaq 0x8(%rbx), %r12
movb $0x1, %bl
movq 0x12ff9(%rip), %r15     # 0x47fd0
movq 0x13002(%rip), %r13     # 0x47fe0
movl $0x15, %edx
movq %r15, %rdi
leaq 0x627a(%rip), %rsi      # 0x3b267
callq 0x3250
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
testb $0x1, %bl
je 0x35026
movq %r13, %rdi
callq 0x33a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %edx
movq %r13, %rdi
leaq -0x58(%rbp), %rsi
callq 0x33c0
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0x35069
decl %eax
movq -0x58(%rbp), %rcx
movsbl (%rcx,%rax), %eax
addl $-0x30, %eax
xorl %r14d, %r14d
cmpl $0xa, %eax
setb %r14b
testl %r14d, %r14d
je 0x351a1
leaq -0x400(%rbp), %rbx
movq %rbx, %rdi
leaq -0x58(%rbp), %rsi
movl $0x18, %edx
callq 0x3310
movq %rbx, %rdi
leaq -0x34(%rbp), %rsi
callq 0x3120
movq %rbx, %rdi
movq 0x12f10(%rip), %rsi     # 0x47fb0
callq 0x3160
leaq -0x380(%rbp), %rdi
callq 0x30d0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
testq %rcx, %rcx
je 0x350e8
movl -0x34(%rbp), %eax
movq %r12, %rbx
xorl %edx, %edx
cmpl %eax, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rbx
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x350c4
cmpq %r12, %rbx
je 0x350e8
cmpl 0x20(%rbx), %eax
jge 0x35210
movl $0x1c, %edx
movq %r15, %rdi
leaq 0x63fe(%rip), %rsi      # 0x3b4f5
callq 0x3250
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movl $0x19, %edx
movq %r15, %rdi
leaq 0x6368(%rip), %rsi      # 0x3b49a
callq 0x3250
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r15, %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, %edx
movq %r13, %rdi
leaq -0x78(%rbp), %rsi
callq 0x33c0
leaq -0x78(%rbp), %rdi
leaq 0x5464(%rip), %rsi      # 0x3a5f1
callq 0x30c0
xorl %ebx, %ebx
testl %eax, %eax
je 0x34fde
jmp 0x352ad
movl $0x38, %edx
movq %r15, %rdi
leaq 0x6299(%rip), %rsi      # 0x3b449
callq 0x3250
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r15, %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
xorl %ebx, %ebx
movq %rax, %rdi
callq 0x3130
xorl %r14d, %r14d
jmp 0x34fde
movl $0xa, %edx
movq %r15, %rdi
leaq 0x605e(%rip), %rsi      # 0x3b27d
callq 0x3250
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x35932
leaq -0x278(%rbp), %rdi
leaq 0x572b(%rip), %rsi      # 0x3a990
movl $0x10, %edx
callq 0x3050
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rbx
cmpq %r12, %rbx
je 0x3529c
leaq 0x28(%rbx), %rsi
leaq -0x278(%rbp), %rdi
callq 0xf835
movq %rbx, %rdi
callq 0x3140
movq %rax, %rbx
cmpq %r12, %rax
jne 0x3527c
leaq -0x278(%rbp), %rdi
callq 0x32a0
jmp 0x35123
movq 0x12d14(%rip), %rax     # 0x47fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x270(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x278(%rbp,%rcx)
callq 0x3190
leaq -0x180(%rbp), %rdi
callq 0x30d0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x352f5
callq 0x31d0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x35307
callq 0x31d0
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x35357
jmp 0x35348
movq %rax, %rbx
movq 0x12c86(%rip), %rsi     # 0x47fb0
leaq -0x400(%rbp), %rdi
callq 0x3160
leaq -0x380(%rbp), %rdi
callq 0x30d0
jmp 0x3534b
jmp 0x35348
jmp 0x35348
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
callq 0x32e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x35369
callq 0x31d0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3537b
callq 0x31d0
movq %rbx, %rdi
callq 0x3380