// File: /workspace/github_cpp_makefile_star2_O2/nataly-enne[P]pet-fera/pet_fera_checagem.cpp
// Function: verifica_ID(std::map<int, ANFIBIO_NATIVO, std::less<int>, std::allocator<std::pair<int const, ANFIBIO_NATIVO>>>&, std::map<int, ANFIBIO_EXOTICO, std::less<int>, std::allocator<std::pair<int const, ANFIBIO_EXOTICO>>>&, char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char&)
bool verifica_ID(map <int, ANFIBIO_NATIVO> &anfibios_nat, map <int, ANFIBIO_EXOTICO> &anfibios_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(anfibios_nat.empty()){
				sucesso = 's';
				return 1;
			}
			else{
				for(auto it = anfibios_nat.begin(); it != anfibios_nat.end();it++){
					if(it->second.getId() == id){
						sucesso = 'n';
						cout << "ERRO: id já cadastrado!" << endl << endl;
						return 0;				
					}
				}		
			}
		} // Anfibios_nat
		else{
			if(anfibios_ex.empty()){
				sucesso = 's';
				return 1;
			}
			else{
				for(auto it = anfibios_ex.begin(); it != anfibios_ex.end();it++){
					if(it->second.getId() == id){
						sucesso = 'n';
						cout << "ERRO: id já cadastrado!" << endl << endl;
						return 0;				
					}
				}	
			}
		} // Anfibios_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 0x2134a
movq (%rcx), %rdi
movsbl (%rdi,%rdx), %edi
addl $-0x30, %edi
incq %rdx
cmpl $0xa, %edi
jb 0x21331
jmp 0x213b0
testl %eax, %eax
js 0x213b0
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 0x213eb
cmpq $0x0, 0x28(%r15)
je 0x2141a
movq 0x18(%r15), %r14
addq $0x8, %r15
cmpq %r15, %r14
je 0x21425
leaq 0x28(%r14), %rdi
callq 0x546e
cmpl -0x2c(%rbp), %eax
je 0x2142a
movq %r14, %rdi
callq 0x3160
movq %rax, %r14
jmp 0x21388
movq 0xfc11(%rip), %rdi      # 0x30fc8
leaq 0x3285(%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 0x2141a
movq 0x18(%r14), %r15
addq $0x8, %r14
cmpq %r14, %r15
je 0x21425
leaq 0x28(%r15), %rdi
callq 0x5a3c
cmpl -0x2c(%rbp), %eax
je 0x21452
movq %r15, %rdi
callq 0x3160
movq %rax, %r15
jmp 0x213fa
movb $0x73, (%rbx)
movb $0x1, %r14b
xorl %r15d, %r15d
jmp 0x2147e
movb $0x1, %r15b
jmp 0x2147b
movb $0x6e, (%rbx)
movq 0xfb94(%rip), %rdi      # 0x30fc8
leaq 0x321f(%rip), %rsi      # 0x2465a
callq 0x31f0
movq %rax, %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3110
jmp 0x21478
movb $0x6e, (%rbx)
movq 0xfb6c(%rip), %rdi      # 0x30fc8
leaq 0x31f7(%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 0x213d6
movb $0x73, (%rbx)
movb $0x1, %r14b
jmp 0x213d6
jmp 0x214a6
jmp 0x214a6
jmp 0x214a6
jmp 0x214a6
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3370