// File: /workspace/github_cpp_makefile_star2_O1/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, -0x38(%rbp)
addq $0x8, %rbx
movb $0x1, %r14b
movq 0x12f10(%rip), %r15     # 0x47fd0
leaq -0x278(%rbp), %r12
movl $0x15, %edx
movq %r15, %rdi
leaq 0x6191(%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, %r14b
je 0x35114
movq 0x12ed1(%rip), %rdi     # 0x47fe0
callq 0x33a0
movq 0x12ec5(%rip), %rcx     # 0x47fe0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %edx
movq 0x12ea7(%rip), %rdi     # 0x47fe0
leaq -0x58(%rbp), %rsi
callq 0x33c0
movq -0x50(%rbp), %rax
testl %eax, %eax
jle 0x35161
decl %eax
movq -0x58(%rbp), %rcx
movsbl (%rcx,%rax), %eax
addl $-0x30, %eax
xorl %r13d, %r13d
cmpl $0xa, %eax
setb %r13b
testl %r13d, %r13d
je 0x351a7
leaq -0x400(%rbp), %r14
movq %r14, %rdi
leaq -0x58(%rbp), %rsi
movl $0x18, %edx
callq 0x3310
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3120
movq %r14, %rdi
movq 0x12e1c(%rip), %rsi     # 0x47fb0
callq 0x3160
leaq -0x380(%rbp), %rdi
callq 0x30d0
jmp 0x3520c
movl $0x38, %edx
movq %r15, %rdi
leaq 0x6293(%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, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3130
xorl %r14d, %r14d
testl %r13d, %r13d
je 0x350c7
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rbx, %rax
testq %rcx, %rcx
je 0x35245
movl -0x2c(%rbp), %edx
movq %rbx, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x3522e
movq %rbx, %r14
cmpq %rbx, %rax
je 0x3525a
movl -0x2c(%rbp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %rbx, %rax
movq %rax, %r14
cmpq %rbx, %r14
je 0x352f1
movl $0xa, %edx
movq %r15, %rdi
leaq 0x600b(%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 -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x35a50
movq %r12, %rdi
leaq 0x56dc(%rip), %rsi      # 0x3a990
movl $0x10, %edx
callq 0x3050
movq -0x38(%rbp), %rax
movq 0x18(%rax), %r14
cmpq %rbx, %r14
je 0x352e7
leaq 0x28(%r14), %rsi
movq %r12, %rdi
callq 0xf831
movq %r14, %rdi
callq 0x3140
movq %rax, %r14
cmpq %rbx, %rax
jne 0x352cb
movq %r12, %rdi
callq 0x32a0
jmp 0x3532c
movl $0x1c, %edx
movq %r15, %rdi
leaq 0x61f5(%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 0x615f(%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 0x12c72(%rip), %rcx     # 0x47fe0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x31f0
movsbl %al, %edx
movq 0x12c54(%rip), %rdi     # 0x47fe0
leaq -0x78(%rbp), %rsi
callq 0x33c0
leaq -0x78(%rbp), %rdi
leaq 0x5251(%rip), %rsi      # 0x3a5f1
callq 0x30c0
xorl %r14d, %r14d
testl %eax, %eax
je 0x350c7
movq 0x12c11(%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 0x353f8
callq 0x31d0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3540a
callq 0x31d0
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3545a
jmp 0x3544b
movq %rax, %rbx
movq 0x12b83(%rip), %rsi     # 0x47fb0
leaq -0x400(%rbp), %rdi
callq 0x3160
leaq -0x380(%rbp), %rdi
callq 0x30d0
jmp 0x3544e
jmp 0x3544b
jmp 0x3544b
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
callq 0x32e0
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x3546c
callq 0x31d0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3547e
callq 0x31d0
movq %rbx, %rdi
callq 0x3380