// File: /workspace/github_cpp_makefile_star2_O2/nataly-enne[P]pet-fera/pet_fera_checagem.cpp
// Function: verifica_ID(std::map<int, AVE_NATIVO, std::less<int>, std::allocator<std::pair<int const, AVE_NATIVO>>>&, std::map<int, AVE_EXOTICO, std::less<int>, std::allocator<std::pair<int const, AVE_EXOTICO>>>&, char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char&)
bool verifica_ID(map <int, AVE_NATIVO> &aves_nat, map <int, AVE_EXOTICO> &aves_ex, char tipo, 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(tipo == 'n'){
			if(aves_nat.empty()){
				sucesso = 's';
				return 1;
			}
			else{
				for(auto it = aves_nat.begin(); it != aves_nat.end();it++){
					if(it->second.getId() == id){
						sucesso = 'n';
						cout << "ERRO: id já cadastrado!" << endl << endl;
						return 0;				
					}
				}
					
			}
		} // Aves_nat
		else{
			if(aves_ex.empty()){
				sucesso = 's';
				return 1;
			}
			else{
				for(auto it = aves_ex.begin(); it != aves_ex.end();it++){
					if(it->second.getId() == id){
						sucesso = 'n';
						cout << "ERRO: id já cadastrado!" << endl << endl;
						return 0;				
					}
				}	
			}
		} // Aves_ex 		
	}
	else{
		cout << "ERRO: valor inválido!" << endl << endl;
		return 0;
	}

	sucesso = 's';
	return 1;	

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %r8, %rbx
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %r15
movb $0x6e, (%r8)
movl 0x8(%rcx), %eax
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
cmpq %rdx, %rsi
je 0x218b1
movq (%rcx), %rdi
movsbl (%rdi,%rdx), %edi
addl $-0x30, %edi
incq %rdx
cmpl $0xa, %edi
jb 0x2188a
movq 0xf720(%rip), %rdi      # 0x30fc8
leaq 0x2dc4(%rip), %rsi      # 0x24673
jmp 0x21925
testl %eax, %eax
js 0x21917
leaq -0x1b8(%rbp), %r13
pushq $0x18
popq %rdx
movq %r13, %rdi
movq %rcx, %rsi
callq 0x3300
leaq -0x2c(%rbp), %rsi
movq %r13, %rdi
callq 0x3150
cmpb $0x6e, %r12b
jne 0x21952
cmpq $0x0, 0x28(%r15)
je 0x21981
movq 0x18(%r15), %r14
addq $0x8, %r15
cmpq %r15, %r14
je 0x2198c
leaq 0x28(%r14), %rdi
callq 0x690e
cmpl -0x2c(%rbp), %eax
je 0x21991
movq %r14, %rdi
callq 0x3160
movq %rax, %r14
jmp 0x218ef
movq 0xf6aa(%rip), %rdi      # 0x30fc8
leaq 0x2d1e(%rip), %rsi      # 0x24643
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x28(%r14)
je 0x21981
movq 0x18(%r14), %r15
addq $0x8, %r14
cmpq %r14, %r15
je 0x2198c
leaq 0x28(%r15), %rdi
callq 0x6bb0
cmpl -0x2c(%rbp), %eax
je 0x219b9
movq %r15, %rdi
callq 0x3160
movq %rax, %r15
jmp 0x21961
movb $0x73, (%rbx)
movb $0x1, %r14b
xorl %r15d, %r15d
jmp 0x219e5
movb $0x1, %r15b
jmp 0x219e2
movb $0x6e, (%rbx)
movq 0xf62d(%rip), %rdi      # 0x30fc8
leaq 0x2cb8(%rip), %rsi      # 0x2465a
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0x219df
movb $0x6e, (%rbx)
movq 0xf605(%rip), %rdi      # 0x30fc8
leaq 0x2c90(%rip), %rsi      # 0x2465a
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
xorl %r15d, %r15d
xorl %r14d, %r14d
leaq -0x1b8(%rbp), %rdi
callq 0x3170
testb %r15b, %r15b
je 0x2193d
movb $0x73, (%rbx)
movb $0x1, %r14b
jmp 0x2193d
jmp 0x21a0d
jmp 0x21a0d
jmp 0x21a0d
jmp 0x21a0d
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3370