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

	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 = tratadores.find(id_buscado);
					
		if(result != tratadores.end()){
			cout << "ID existe!" << endl;
			tratadores.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. */
			tratador.open("tratadores.txt");
			for(auto it = tratadores.begin(); it != tratadores.end(); it++){
				tratador << (*it).second;
			}
			tratador.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 0x3afba
jmp 0x3afbc
jmp 0x3afbe
movq 0x15ff3(%rip), %rdi     # 0x50fb8
leaq 0x725b(%rip), %rsi      # 0x42227
callq 0x3240
movq %rax, -0x438(%rbp)
jmp 0x3afda
movq -0x438(%rbp), %rdi
movq 0x15fb8(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3afef
cmpl $0x0, -0x5c(%rbp)
jne 0x3b03c
movq 0x15fdc(%rip), %rdi     # 0x50fd8
callq 0x33f0
jmp 0x3b003
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x3b03c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x3b3c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x3b3b4
movq 0x15f95(%rip), %rdi     # 0x50fd8
leaq -0x30(%rbp), %rsi
callq 0x3070
jmp 0x3b04e
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 0x3b0bc
movslq -0x270(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x3430
movq %rax, -0x448(%rbp)
jmp 0x3b093
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 0x3b058
cmpl $0x0, -0x58(%rbp)
jne 0x3b115
movq 0x15eef(%rip), %rdi     # 0x50fb8
leaq 0x7339(%rip), %rsi      # 0x42409
callq 0x3240
movq %rax, -0x450(%rbp)
jmp 0x3b0de
movq -0x450(%rbp), %rdi
movq 0x15eb4(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, -0x458(%rbp)
jmp 0x3b0fa
movq -0x458(%rbp), %rdi
movq 0x15e98(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3b10f
movb $0x6e, -0xa(%rbp)
jmp 0x3b18b
movl $0x10, %edi
movl $0x8, %esi
callq 0x13c90
movl %eax, -0x45c(%rbp)
jmp 0x3b12c
movl -0x45c(%rbp), %edx
leaq -0x3f8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3370
jmp 0x3b144
leaq -0x3f8(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x3170
jmp 0x3b156
movb $0x73, -0xa(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
jmp 0x3b18b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x31b0
jmp 0x3b3b4
jmp 0x3b18d
movsbl -0xa(%rbp), %eax
cmpl $0x6e, %eax
je 0x3afbe
movq -0x8(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x37a10
movq %rax, -0x468(%rbp)
jmp 0x3b1b0
movq -0x468(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1f910
movq %rax, -0x408(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x408(%rbp), %rsi
callq 0x1f8e0
testb $0x1, %al
jne 0x3b1ea
jmp 0x3b2ed
movq 0x15dc7(%rip), %rdi     # 0x50fb8
leaq 0x7045(%rip), %rsi      # 0x4223d
callq 0x3240
movq %rax, -0x470(%rbp)
jmp 0x3b206
movq -0x470(%rbp), %rdi
movq 0x15d8c(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3b21b
movq -0x8(%rbp), %rdi
movq -0x400(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x410(%rbp), %rsi
callq 0x3b620
movq %rax, -0x478(%rbp)
jmp 0x3b242
movq -0x478(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq 0x67b1(%rip), %rsi      # 0x41a08
leaq -0x260(%rbp), %rdi
movl $0x10, %edx
callq 0x3050
jmp 0x3b26a
movq -0x8(%rbp), %rdi
callq 0x1f8b0
movq %rax, -0x420(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1f910
movq %rax, -0x428(%rbp)
leaq -0x420(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0x1f8e0
testb $0x1, %al
jne 0x3b2a3
jmp 0x3b2dd
leaq -0x420(%rbp), %rdi
callq 0x1f940
movq %rax, %rsi
addq $0x8, %rsi
leaq -0x260(%rbp), %rdi
callq 0x13170
jmp 0x3b2c4
jmp 0x3b2c6
leaq -0x420(%rbp), %rdi
xorl %esi, %esi
callq 0x1f960
movq %rax, -0x430(%rbp)
jmp 0x3b27a
leaq -0x260(%rbp), %rdi
callq 0x3310
jmp 0x3b2eb
jmp 0x3b320
movq 0x15cc4(%rip), %rdi     # 0x50fb8
leaq 0x71ba(%rip), %rsi      # 0x424b5
callq 0x3240
movq %rax, -0x480(%rbp)
jmp 0x3b309
movq -0x480(%rbp), %rdi
movq 0x15c89(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3b31e
jmp 0x3b320
movq 0x15c91(%rip), %rdi     # 0x50fb8
leaq 0x712c(%rip), %rsi      # 0x4245a
callq 0x3240
movq %rax, -0x488(%rbp)
jmp 0x3b33c
movq -0x488(%rbp), %rdi
movq 0x15c56(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3b351
movq 0x15c80(%rip), %rdi     # 0x50fd8
leaq -0x50(%rbp), %rsi
callq 0x3070
jmp 0x3b363
jmp 0x3b365
leaq 0x6245(%rip), %rsi      # 0x415b1
leaq -0x50(%rbp), %rdi
callq 0x144b0
movb %al, -0x489(%rbp)
jmp 0x3b37d
movb -0x489(%rbp), %al
testb $0x1, %al
jne 0x3afbc
jmp 0x3b38d
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