// File: /workspace/github_cpp_makefile_star2_O2/nataly-enne[P]pet-fera/pet_fera_cadastrar.cpp
// Function: cadastrar(std::map<int, VETERINARIO, std::less<int>, std::allocator<std::pair<int const, VETERINARIO>>>&)
void cadastrar(map <int, VETERINARIO> &vets){ 
	int id, idade;
	unsigned int old_size;
	long int cpf;
	string nome, especialidade, crmv, tipo_sang, id_string, cpf_string, idade_string, tipo_sang_string, fator_rh_string;
	char fator_rh, continuar, sucesso;
	bool check;
	old_size = vets.size();
	ofstream veterinarios;
	
	do{
		// Recebe o ID e verifica se é valido.
		do{
			cout << "Digite o id:" << endl;
			cin >> id_string;
			if(!verifica_ID(vets, id_string, sucesso)){
				cout << "O ID deve conter apenas inteiros ou ID já cadastrado!" << endl << endl;
			}
			else{
				stringstream ss(id_string); // Converte string para int.
				ss >> id;
			}

		}while(sucesso == 'n');

		// Recebe o nome e verifica se é valido.
		do{	
			cout << "Digite o nome:" << endl;
			cin.ignore();
			getline(cin, nome);
			if(!verifica_nome(nome, sucesso)){
				cout << "ERRO: só pode ser inserido letra ou espaço!" << endl << endl;
			}
		}while(sucesso == 'n');

		// Recebe o CPF e verifica se é valido.
		do{
			cout << "Digite o CPF: " << endl;
			getline(cin, cpf_string);
			if(!verifica_CPF(cpf_string, sucesso)){
				cout << "CPF deve conter apenas numeros" << endl << endl;
			}
			else{
				cpf = stoll(cpf_string); //Transforma a string em long int.
				check = check_CPF(vets, cpf); // Checa se o CPF existe.
				if(check){
					cout << "CPF já cadastrado!" << endl;
					sucesso = 'n';
				}
			}
		}while(sucesso == 'n');

		// Recebe a idade e verifica se é valida.
		do{
			cout << "Digite a idade: " << endl;
			getline(cin, idade_string);
			if(!verifica_idade(idade_string, sucesso)){
				cout << "Idade deve conter apenas inteiros positivos!" << endl << endl;
			}
			else{
				stringstream ss(idade_string);
				ss >> idade;
			}
		}while(sucesso == 'n');

		// Recebe o tipo sanguineo e verifica se é valido.
		do{
			cout << "Insira o tipo sanguineo: " << endl;
			getline(cin, tipo_sang_string);
			if(!verifica_tipo_sang(tipo_sang_string, sucesso)){
				cout << "ERRO: O tipo sanguineo deve ser: A, B, AB ou O!" << endl << endl;
			}
			else{
				tipo_sang = tipo_sang_string;
			}
		}while(sucesso == 'n');

		// Recebe o fator RH e verifica se é valido.
		do{
			cout << "Insira o fator RH: " << endl;
			getline(cin, fator_rh_string);
			if(!verifica_fator(fator_rh_string, sucesso)){
				cout << "ERRO: O fator RH deve ser: + ou -" << endl << endl;
			}
			else{
				fator_rh = (char)fator_rh_string[0];
			}
		}while(sucesso == 'n');

		// Recebe a especialidade e verifica se é valida.
		do{
			cout << "Digite a especialidade: " << endl;
			getline(cin, especialidade);
			if(!verifica_especialidade(especialidade, sucesso)){
				cout << "ERRO: A especialidade deve conter apenas letras!" << endl << endl;
			}
			else{
				transform(especialidade.begin(), especialidade.end(), especialidade.begin(), ::tolower);
				especialidade = especialidade;
			}
		}while(sucesso == 'n');

		
		
		do{
			cout << "Digite o crmv: "<< endl;
			getline(cin, crmv);
			if(!verifica_CRMV(vets, crmv, sucesso)){
				cout << "ERRO: Crmv deve conter pelo menos um '-' " << endl << endl;
			}
			else{
				transform(crmv.begin(), crmv.end(), crmv.begin(), ::tolower);
				crmv = crmv;
			}
		}while(sucesso == 'n');

		// Armazenando os valores recebidos pelo usuário no map.
		vets.insert(pair <int, VETERINARIO> (id,VETERINARIO(id, nome, cpf, idade, tipo_sang, fator_rh, especialidade, crmv)));
		
		cout << "Deseja cadastrar um novo funcionario? s/n" << endl;
		cin >> continuar;
	}while(continuar == 's');

	if (vets.size() == old_size){ 
		cout << "Falha no cadastro do funcionario!" << endl;
	}
	else{
		if(!vets.empty()){
			veterinarios.open("veterinarios.txt");
			for(auto it = vets.begin(); it != vets.end(); it++){
				veterinarios << (*it).second;
			}
			veterinarios.close();
		}
		cout << "Cadastro efetuado com sucesso!!" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6b8, %rsp            # imm = 0x6B8
leaq -0x140(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movq %rdi, %r12
xorl %eax, %eax
leaq -0x78(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
leaq -0x58(%rbp), %rsi
movq %rsi, -0x10(%rsi)
andq $0x0, -0x8(%rsi)
movb %al, (%rcx)
movb %al, (%rdx)
leaq -0x160(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq -0x120(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %al, (%rsi)
movb %al, (%rcx)
leaq -0x100(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x10(%rsi)
andq $0x0, -0x8(%rsi)
movb %al, (%rdx)
movb %al, (%rcx)
leaq -0xc0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq -0xa0(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %al, (%rsi)
movb %al, (%rcx)
movb %al, (%rdx)
movl 0x28(%rdi), %eax
movq %rax, -0x90(%rbp)
leaq -0x6e0(%rbp), %rdi
callq 0x3350
movq 0x255c2(%rip), %r15     # 0x30fc8
movq 0x255d3(%rip), %r13     # 0x30fe0
movq %r12, -0x40(%rbp)
movq %r15, %rdi
leaq 0x17ce4(%rip), %rsi     # 0x236ff
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0x130(%rbp), %rsi
callq 0x3260
leaq -0x2b0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3290
movq %r12, %rdi
leaq -0x2b0(%rbp), %r14
movq %r14, %rsi
leaq -0x29(%rbp), %rdx
callq 0x2108e
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xba9d
leaq -0x4e0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x130(%rbp), %rsi
pushq $0x18
popq %rdx
callq 0x3300
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x3150
movq %rbx, %rdi
callq 0x3170
jmp 0xbabc
movq %r15, %rdi
leaq 0x17c65(%rip), %rsi     # 0x2370c
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xba11
movq %r15, %rdi
leaq 0x17c73(%rip), %rsi     # 0x23743
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
callq 0x3380
movq %r13, %rdi
leaq -0x150(%rbp), %rsi
callq 0x3060
leaq -0x150(%rbp), %rdi
leaq -0x29(%rbp), %rsi
callq 0x21b16
testb %al, %al
jne 0xbb27
movq %r15, %rdi
leaq 0x17c40(%rip), %rsi     # 0x23752
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xbac6
movq %r15, %rdi
leaq 0x17c49(%rip), %rsi     # 0x23780
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0x110(%rbp), %rsi
callq 0x3060
leaq -0x290(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3290
leaq -0x290(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rsi
callq 0x21cb0
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xbbcc
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x11df6
movq %rax, -0x48(%rbp)
movq %r12, %rdi
movq -0x48(%rbp), %rsi
callq 0x20dac
testb %al, %al
je 0xbbeb
movq %r15, %rdi
leaq 0x17bf8(%rip), %rsi     # 0x237ae
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movb $0x6e, -0x29(%rbp)
jmp 0xbb2d
movq %r15, %rdi
leaq 0x17bb9(%rip), %rsi     # 0x2378f
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xbb2d
movq %r15, %rdi
leaq 0x17bc3(%rip), %rsi     # 0x237c2
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3060
leaq -0x270(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3290
leaq -0x270(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rsi
callq 0x21d14
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xbc7e
leaq -0x4e0(%rbp), %rbx
movq %rbx, %rdi
leaq -0xf0(%rbp), %rsi
pushq $0x18
popq %rdx
callq 0x3300
movq %rbx, %rdi
leaq -0x38(%rbp), %rsi
callq 0x3150
movq %rbx, %rdi
callq 0x3170
jmp 0xbc9d
movq %r15, %rdi
leaq 0x17b4b(%rip), %rsi     # 0x237d3
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xbbf5
movq %r15, %rdi
leaq 0x17b4f(%rip), %rsi     # 0x23800
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3060
leaq -0xd0(%rbp), %rdi
leaq -0x29(%rbp), %rsi
callq 0x21ddc
testb %al, %al
je 0xbcf6
leaq -0x170(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3120
jmp 0xbd15
movq %r15, %rdi
leaq 0x17b1a(%rip), %rsi     # 0x2381a
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xbca7
movq %r15, %rdi
leaq 0x17b25(%rip), %rsi     # 0x2384a
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3060
leaq -0x250(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3290
leaq -0x250(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rsi
callq 0x21ee3
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xbd83
movq -0xb0(%rbp), %rax
movb (%rax), %al
movb %al, -0x2a(%rbp)
jmp 0xbda2
movq %r15, %rdi
leaq 0x17ad1(%rip), %rsi     # 0x2385e
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
cmpb $0x6e, -0x29(%rbp)
je 0xbd1b
movq %r15, %rdi
leaq 0x17aca(%rip), %rsi     # 0x23880
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0x88(%rbp), %rsi
callq 0x3060
leaq -0x230(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3290
leaq -0x230(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rsi
callq 0x21f3a
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xbe2c
movq -0x88(%rbp), %rbx
movq -0x80(%rbp), %r12
xorl %r14d, %r14d
cmpq %r14, %r12
je 0xbe4d
movsbl (%rbx,%r14), %edi
callq 0x32c0
movb %al, (%rbx,%r14)
incq %r14
jmp 0xbe14
movq %r15, %rdi
leaq 0x17a63(%rip), %rsi     # 0x23899
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0xbe60
leaq -0x88(%rbp), %rdi
movq %rdi, %rsi
callq 0x3120
movq -0x40(%rbp), %r12
cmpb $0x6e, -0x29(%rbp)
je 0xbdac
movq %r15, %rdi
leaq 0x17a56(%rip), %rsi     # 0x238ca
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0x68(%rbp), %rsi
callq 0x3060
leaq -0x210(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3290
movq %r12, %rdi
leaq -0x210(%rbp), %r14
movq %r14, %rsi
leaq -0x29(%rbp), %rdx
callq 0x21ffd
movl %eax, %ebx
movq %r14, %rdi
callq 0x3100
testb %bl, %bl
je 0xbee4
movq -0x68(%rbp), %rbx
movq -0x60(%rbp), %r12
xorl %r14d, %r14d
cmpq %r14, %r12
je 0xbf05
movsbl (%rbx,%r14), %edi
callq 0x32c0
movb %al, (%rbx,%r14)
incq %r14
jmp 0xbecc
movq %r15, %rdi
leaq 0x179ec(%rip), %rsi     # 0x238da
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0xbf15
leaq -0x68(%rbp), %rdi
movq %rdi, %rsi
callq 0x3120
movq -0x40(%rbp), %r12
cmpb $0x6e, -0x29(%rbp)
je 0xbe6a
movl -0x30(%rbp), %r14d
leaq -0x1d0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x3290
movl -0x38(%rbp), %eax
movl %eax, -0x34(%rbp)
leaq -0x1b0(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x3290
leaq -0x190(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3290
leaq -0x1f0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x68(%rbp), %rsi
callq 0x3290
subq $0x8, %rsp
movsbl -0x2a(%rbp), %eax
leaq -0x358(%rbp), %rdi
movl %r14d, %esi
leaq -0x1d0(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl -0x34(%rbp), %r8d
leaq -0x1b0(%rbp), %r9
pushq %rbx
leaq -0x190(%rbp), %r10
pushq %r10
pushq %rax
callq 0xaac4
addq $0x20, %rsp
movl -0x30(%rbp), %eax
movl %eax, -0x4e0(%rbp)
leaq -0x4d8(%rbp), %r14
movq %r14, %rdi
leaq -0x358(%rbp), %rbx
movq %rbx, %rsi
callq 0x11f02
movq %r12, %rdi
leaq -0x4e0(%rbp), %rsi
callq 0x125da
movq %r14, %rdi
callq 0x42b4
movq %rbx, %rdi
callq 0x42b4
leaq -0x1f0(%rbp), %rdi
callq 0x3100
leaq -0x190(%rbp), %rdi
callq 0x3100
leaq -0x1b0(%rbp), %rdi
callq 0x3100
leaq -0x1d0(%rbp), %rdi
callq 0x3100
movq %r15, %rdi
leaq 0x178d8(%rip), %rsi     # 0x23904
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %r13, %rdi
leaq -0x2b(%rbp), %rsi
callq 0x3280
cmpb $0x73, -0x2b(%rbp)
je 0xba11
movq 0x28(%r12), %rax
cmpq -0x90(%rbp), %rax
jne 0xc066
leaq 0x178ca(%rip), %r14     # 0x2392e
jmp 0xc0c6
leaq 0x178f4(%rip), %r14     # 0x23961
testq %rax, %rax
je 0xc0c6
leaq 0x178d7(%rip), %rsi     # 0x23950
leaq -0x6e0(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x3040
movq %r12, %rbx
movq 0x18(%r12), %r12
addq $0x8, %rbx
leaq -0x6e0(%rbp), %r15
cmpq %rbx, %r12
je 0xc0ba
leaq 0x28(%r12), %rsi
movq %r15, %rdi
callq 0xad8a
movq %r12, %rdi
callq 0x3160
movq %rax, %r12
jmp 0xc09b
leaq -0x6e0(%rbp), %rdi
callq 0x32a0
movq 0x24efb(%rip), %rdi     # 0x30fc8
movq %r14, %rsi
callq 0x31f0
movq %rax, %rdi
callq 0x3110
leaq -0x6e0(%rbp), %rdi
callq 0x32e0
leaq -0xb0(%rbp), %rdi
callq 0x3100
leaq -0xd0(%rbp), %rdi
callq 0x3100
leaq -0xf0(%rbp), %rdi
callq 0x3100
leaq -0x110(%rbp), %rdi
callq 0x3100
leaq -0x130(%rbp), %rdi
callq 0x3100
leaq -0x170(%rbp), %rdi
callq 0x3100
leaq -0x68(%rbp), %rdi
callq 0x3100
leaq -0x88(%rbp), %rdi
callq 0x3100
leaq -0x150(%rbp), %rdi
callq 0x3100
addq $0x6b8, %rsp            # imm = 0x6B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xc256
jmp 0xc247
jmp 0xc247
movq %rax, %rbx
movq %r14, %rdi
callq 0x42b4
leaq -0x358(%rbp), %rdi
callq 0x42b4
jmp 0xc1a6
jmp 0xc247
movq %rax, %rbx
jmp 0xc1ca
movq %rax, %rbx
jmp 0xc1be
movq %rax, %rbx
jmp 0xc1b2
movq %rax, %rbx
leaq -0x1f0(%rbp), %rdi
callq 0x3100
leaq -0x190(%rbp), %rdi
callq 0x3100
leaq -0x1b0(%rbp), %rdi
callq 0x3100
leaq -0x1d0(%rbp), %rdi
jmp 0xc232
jmp 0xc247
jmp 0xc247
jmp 0xc1d9
movq %rax, %rbx
leaq -0x4e0(%rbp), %rdi
callq 0x3170
jmp 0xc24a
jmp 0xc247
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
jmp 0xc232
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0xc232
movq %rax, %rbx
leaq -0x250(%rbp), %rdi
jmp 0xc232
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
jmp 0xc232
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
jmp 0xc232
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
callq 0x3100
jmp 0xc24a
jmp 0xc247
jmp 0xc247
jmp 0xc247
jmp 0xc247
jmp 0xc247
jmp 0xc247
jmp 0xc247
movq %rax, %rbx
leaq -0x6e0(%rbp), %rdi
callq 0x32e0
leaq -0xb0(%rbp), %rdi
callq 0x3100
leaq -0xd0(%rbp), %rdi
callq 0x3100
leaq -0xf0(%rbp), %rdi
callq 0x3100
leaq -0x110(%rbp), %rdi
callq 0x3100
leaq -0x130(%rbp), %rdi
callq 0x3100
leaq -0x170(%rbp), %rdi
callq 0x3100
leaq -0x68(%rbp), %rdi
callq 0x3100
leaq -0x88(%rbp), %rdi
callq 0x3100
leaq -0x150(%rbp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3370