// File: nataly-enne[P]pet-fera/pet_fera_checagem.cpp
// Function: verifica_ID(std::map<int, TRATADOR, std::less<int>, std::allocator<std::pair<int const, TRATADOR>>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char&)
bool verifica_ID(map <int, TRATADOR> &tratadores, string id_string, char &sucesso){
	int cont = 0, id, verificacao;
	char c;
	sucesso = 'n';
	for(int i = 0; i < (int)id_string.size(); i++){
		c = id_string[i];
		verificacao = isdigit(c);
		if(!verificacao){
			cout << "ERRO: valor inválido!" << endl << endl;
			return 0;
		}
		else cont++;
	}

	if(cont == (int) id_string.size()){
		stringstream ss(id_string);
		ss >> id;
		if(tratadores.empty()){
			sucesso = 's';
			return 1;
		}
		else{
			for(auto it = tratadores.begin(); it != tratadores.end();it++){
				if(it->second.getId() == id){
					sucesso = 'n';
					cout << "ERRO: id já cadastrado!" << endl << endl;
					return 0;				
				}
			}	
		}	
	}
	else{
		cout << "ERRO: valor inválido!" << endl << endl;
		return 0;
	}

	sucesso = 's';
	return 1;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rsi, -0x1f0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rax
movb $0x6e, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x1f0(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, -0x1f4(%rbp)
callq 0x31a0
movq %rax, %rcx
movl -0x1f4(%rbp), %eax
cmpl %ecx, %eax
jge 0x3e06f
movq -0x1f0(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x3430
movb (%rax), %al
movb %al, -0x2d(%rbp)
movsbl -0x2d(%rbp), %edi
callq 0x3220
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x3e056
movq 0x12f95(%rip), %rdi     # 0x50fb8
leaq 0x4619(%rip), %rsi      # 0x42643
callq 0x3240
movq %rax, %rdi
movq 0x12f67(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, %rdi
movq 0x12f58(%rip), %rsi     # 0x50fa0
callq 0x3280
movb $0x0, -0x1(%rbp)
jmp 0x3e26f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3e061
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3dfd3
movq -0x1f0(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, -0x1f8(%rbp)
callq 0x31a0
movq %rax, %rcx
movl -0x1f8(%rbp), %eax
cmpl %ecx, %eax
jne 0x3e22d
movl $0x10, %edi
movl $0x8, %esi
callq 0x13c90
movq -0x1f0(%rbp), %rsi
movl %eax, %edx
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3370
movq -0x200(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3170
jmp 0x3e0d2
movq -0x10(%rbp), %rdi
callq 0x1f890
testb $0x1, %al
jne 0x3e0e1
jmp 0x3e11e
movq -0x20(%rbp), %rax
movb $0x73, (%rax)
movb $0x1, -0x1(%rbp)
movl $0x1, -0x1d0(%rbp)
jmp 0x3e211
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c8(%rbp)
movl %eax, -0x1cc(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31b0
jmp 0x3e27d
movq -0x10(%rbp), %rdi
callq 0x1f8b0
movq %rax, -0x1d8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1f910
movq %rax, -0x1e0(%rbp)
leaq -0x1d8(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x1f8e0
testb $0x1, %al
jne 0x3e15a
jmp 0x3e205
leaq -0x1d8(%rbp), %rdi
callq 0x3d5d0
movq %rax, %rdi
addq $0x8, %rdi
callq 0x12d40
movl %eax, -0x204(%rbp)
jmp 0x3e17a
movl -0x204(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x3e1e9
movq -0x20(%rbp), %rax
movb $0x6e, (%rax)
movq 0x12e25(%rip), %rdi     # 0x50fb8
leaq 0x44c0(%rip), %rsi      # 0x4265a
callq 0x3240
movq %rax, -0x210(%rbp)
jmp 0x3e1a8
movq -0x210(%rbp), %rdi
movq 0x12dea(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, -0x218(%rbp)
jmp 0x3e1c4
movq -0x218(%rbp), %rdi
movq 0x12dce(%rip), %rsi     # 0x50fa0
callq 0x3280
jmp 0x3e1d9
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1d0(%rbp)
jmp 0x3e211
jmp 0x3e1eb
leaq -0x1d8(%rbp), %rdi
xorl %esi, %esi
callq 0x1f960
movq %rax, -0x1e8(%rbp)
jmp 0x3e12e
jmp 0x3e207
movl $0x0, -0x1d0(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x31b0
movl -0x1d0(%rbp), %eax
testl %eax, %eax
je 0x3e22b
jmp 0x3e229
jmp 0x3e26f
jmp 0x3e264
movq 0x12d84(%rip), %rdi     # 0x50fb8
leaq 0x4408(%rip), %rsi      # 0x42643
callq 0x3240
movq %rax, %rdi
movq 0x12d56(%rip), %rsi     # 0x50fa0
callq 0x3280
movq %rax, %rdi
movq 0x12d47(%rip), %rsi     # 0x50fa0
callq 0x3280
movb $0x0, -0x1(%rbp)
jmp 0x3e26f
movq -0x20(%rbp), %rax
movb $0x73, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x1c8(%rbp), %rdi
callq 0x33d0
nopl (%rax)