// File: /workspace/github_cpp_makefile_star2_O2/brashi[P]PetFera/src/./banco_dados.cpp
// Function: BancoDados::lerAnimais()
void BancoDados::lerAnimais() {
    if(!fs::exists(animalArq)) {
        cout << "Arquivo de animais ainda não criado." << endl;
        cout << "Leitura cancelada..." << endl;
        
        return;
    }
    if(fs::is_empty(animalArq)) {
        cout << "Arquivo de animais vazio." << endl;
        cout << "Leitura cancelada..." << endl;
        return;
    }

    ifstream arqDados(animalArq);
    if(arqDados.bad() || arqDados.fail()){
        throw "Arquivo de animais inexistente ou corrompido.";
    }
    int count = 0;
    int prox;

    string temp;
    string linha;
    string palavra;
    string classe, classificacao;
    vector<string> tokens;
    shared_ptr<Animal> animal;

    while(!arqDados.eof()) {
        tokens.clear();

        getline(arqDados, linha);
        stringstream s(linha);
        while(getline(s, palavra, ';')) {
            tokens.push_back(palavra);
        }

        if(tokens.size()) {
            classe = tokens.at(0);
            classificacao = tokens.at(1);

            animal = mapa.aMap[classe + classificacao]();
            animal->setNome(tokens.at(2));
            animal->setEspecie(tokens.at(3));
            animal->setAmeacadoPor(tokens.at(4));
            animal->setVeterinario(petshop->findVeterinario(tokens.at(5)));
            animal->setTratador(petshop->findTratador(tokens.at(6)));
            animal->setPerigoso(stoi(tokens.at(7)));

            switch(strFiltro[classificacao]) {
                case 'D':
                    dynamic_pointer_cast<Domestico>(animal)->setAdestrado(stoi(tokens.at(8)));
                    prox = 9;
                    break;
                case 'E':
                    dynamic_pointer_cast<Exotico>(animal)->setLocal(tokens.at(8));
                    prox = 9;
                    break;
                case 'N':
                    dynamic_pointer_cast<Nativo>(animal)->setRegiao(tokens.at(8));
                    dynamic_pointer_cast<Nativo>(animal)->setLicenca(tokens.at(9));
                    prox = 10;
                    break;
            }
            
            switch(strFiltro[classe]) {
                case 'A':
                    dynamic_pointer_cast<Ave>(animal)->setVoa(stoi(tokens.at(prox)));
                    break;
                case 'F':
                    dynamic_pointer_cast<Anfibio>(animal)->setCauda(stoi(tokens.at(prox)));
                    dynamic_pointer_cast<Anfibio>(animal)->setPata(stoi(tokens.at(prox + 1)));
                    break;
                case 'R':
                    dynamic_pointer_cast<Reptil>(animal)->setPele(static_cast<Pele>(stoi(tokens.at(prox))));
                    break;
                case 'M':
                    dynamic_pointer_cast<Mamifero>(animal)->setGestacao(stoi(tokens.at(prox)));
            }

            petshop->adicionarAnimal(animal);
            count++;
        }


    }
    arqDados.close();
    cout << "Arquivo de animais carregado com sucesso." << endl;
    cout << "Foram carregados " << count << " animais." << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5e8, %rsp            # imm = 0x5E8
movq %rdi, 0x40(%rsp)
leaq 0x30(%rdi), %r14
leaq 0x258(%rsp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7cce
movq %rbx, %rdi
callq 0x7cb2
movl %eax, %ebx
leaq 0x258(%rsp), %rdi
callq 0x7d36
testb %bl, %bl
je 0x6f32
leaq 0x258(%rsp), %rbx
pushq $0x2
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7cce
movq %rbx, %rdi
callq 0x5470
movl %eax, %ebx
leaq 0x258(%rsp), %rdi
callq 0x7d36
testb %bl, %bl
je 0x6f6c
movq 0x1f09f(%rip), %rbx     # 0x25fc8
leaq 0x10340(%rip), %rsi     # 0x17270
jmp 0x6f40
movq 0x1f08f(%rip), %rbx     # 0x25fc8
leaq 0x1030a(%rip), %rsi     # 0x1724a
movq %rbx, %rdi
callq 0x5270
movq %rax, %rdi
callq 0x5160
leaq 0x10242(%rip), %rsi     # 0x17199
movq %rbx, %rdi
callq 0x5270
movq %rax, %rdi
callq 0x5160
jmp 0x76f7
leaq 0x258(%rsp), %rbx
pushq $0x8
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x53e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0x278(%rsp,%rcx)
jne 0x7709
leaq 0x1e8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq 0xf8(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
xorl %edi, %edi
movb %dil, (%rcx)
leaq 0x168(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq 0xd8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
andq $0x0, -0x8(%rsi)
movb %dil, (%rdx)
movb %dil, (%rcx)
movb %dil, (%rsi)
leaq 0xb8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movq $0x0, 0x48(%rsp)
movb %dil, (%rcx)
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rbp
movaps %xmm0, (%rbp)
andq $0x0, 0x10(%rbp)
movq %rsp, %rcx
movaps %xmm0, (%rcx)
movq 0x40(%rsp), %rcx
leaq 0x70(%rcx), %rdx
movq %rdx, 0x58(%rsp)
addq $0xa0, %rcx
movq %rcx, 0x50(%rsp)
leaq 0xe8(%rsp), %rbx
leaq 0x460(%rsp), %r15
leaq 0x158(%rsp), %r13
movq %rcx, 0x38(%rsp)
movq -0x18(%rax), %rax
testb $0x2, 0x278(%rsp,%rax)
jne 0x7636
movq %rbp, %rdi
callq 0x8040
leaq 0x258(%rsp), %rdi
movq %rbx, %rsi
callq 0x5060
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x18
popq %rdx
callq 0x53d0
movq %r15, %rdi
movq %r13, %rsi
pushq $0x3b
popq %rdx
callq 0x5450
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x70b5
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8048
jmp 0x708c
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0x7619
movq %rbp, %rdi
xorl %esi, %esi
callq 0x8082
leaq 0xc8(%rsp), %rdi
movq %rax, %rsi
callq 0x5190
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0x8082
leaq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x5190
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0xc8(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x8196
movq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x8130
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x81ce
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x98ce
leaq 0x150(%rsp), %rdi
callq 0x8466
leaq 0x18(%rsp), %rdi
callq 0x54c8
movq (%rsp), %rbx
movq %rbp, %rdi
pushq $0x2
popq %rsi
callq 0x8082
leaq 0x1b8(%rsp), %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
leaq 0x1b8(%rsp), %rbx
movq %rbx, %rsi
callq 0x10bce
movq %rbx, %rdi
callq 0x54c8
movq (%rsp), %rbx
movq %rbp, %rdi
pushq $0x3
popq %rsi
callq 0x8082
leaq 0x198(%rsp), %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
leaq 0x198(%rsp), %rbx
movq %rbx, %rsi
callq 0x10d8e
movq %rbx, %rdi
callq 0x54c8
movq (%rsp), %rbx
movq %rbp, %rdi
pushq $0x4
popq %rsi
callq 0x8082
leaq 0x178(%rsp), %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
leaq 0x178(%rsp), %rbx
movq %rbx, %rsi
callq 0x10e7c
movq %rbx, %rdi
callq 0x54c8
movq (%rsp), %r14
movq 0x40(%rsp), %rax
movq (%rax), %rbx
movq %rbp, %rdi
pushq $0x5
popq %rsi
callq 0x8082
leaq 0x128(%rsp), %rdi
movq %rax, %rsi
callq 0x5340
leaq 0x98(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
leaq 0x128(%rsp), %rdx
callq 0xb2b6
movq %r14, %rdi
movq %r12, %rsi
callq 0x10e98
leaq 0xa0(%rsp), %rdi
callq 0x8466
leaq 0x128(%rsp), %rdi
callq 0x54c8
movq (%rsp), %r14
movq 0x40(%rsp), %rax
movq (%rax), %rbx
movq %rbp, %rdi
pushq $0x6
popq %rsi
callq 0x8082
leaq 0x108(%rsp), %rdi
movq %rax, %rsi
callq 0x5340
leaq 0x88(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
leaq 0x108(%rsp), %rdx
callq 0xb4f6
movq %r14, %rdi
movq %r12, %rsi
callq 0x10eb4
leaq 0x90(%rsp), %rdi
callq 0x8466
leaq 0x108(%rsp), %rdi
callq 0x54c8
movq (%rsp), %r14
movq %rbp, %rdi
pushq $0x7
popq %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %r14, %rdi
callq 0x10f52
movq 0x50(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x8c52
movzbl (%rax), %eax
cmpl $0x44, %eax
je 0x7417
cmpl $0x45, %eax
je 0x73d2
cmpl $0x4e, %eax
jne 0x7463
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7e73
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
pushq $0x8
popq %rsi
callq 0x8082
leaq 0x218(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x14a7c
movq %r14, %rdi
callq 0x54c8
leaq 0x20(%rsp), %rdi
callq 0x8466
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7e73
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
pushq $0x9
popq %rsi
callq 0x8082
leaq 0x1f8(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1498e
movq %r14, %rdi
callq 0x54c8
leaq 0x20(%rsp), %rdi
callq 0x8466
pushq $0xa
jmp 0x745d
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7e1d
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
pushq $0x8
popq %rsi
callq 0x8082
leaq 0x238(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1215a
movq %r14, %rdi
callq 0x54c8
jmp 0x7451
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7dc7
movq 0x18(%rsp), %r14
movq %rbp, %rdi
pushq $0x8
popq %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %r14, %rdi
callq 0x12046
leaq 0x20(%rsp), %rdi
callq 0x8466
pushq $0x9
popq %rax
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x8c52
movzbl (%rax), %eax
movslq 0x38(%rsp), %r14
cmpl $0x52, %eax
je 0x759f
cmpl $0x46, %eax
je 0x74dc
cmpl $0x4d, %eax
je 0x7563
cmpl $0x41, %eax
jne 0x75dd
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7ec9
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %rbx, %rdi
callq 0x14d30
jmp 0x75d3
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7f1e
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %rbx, %rdi
callq 0x1644c
leaq 0x20(%rsp), %rdi
callq 0x8466
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7f1e
movq 0x18(%rsp), %r14
movq 0x38(%rsp), %rax
incl %eax
movslq %eax, %rsi
movq %rbp, %rdi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %r14, %rdi
callq 0x164f0
jmp 0x75d3
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7fc8
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
xorl %esi, %esi
testl %eax, %eax
setne %sil
movq %rbx, %rdi
callq 0x154c4
jmp 0x75d3
leaq 0x18(%rsp), %rdi
movq %rsp, %rsi
callq 0x7f73
movq 0x18(%rsp), %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8082
movq %rax, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x80f1
movq %rbx, %rdi
movl %eax, %esi
callq 0x15cb4
leaq 0x20(%rsp), %rdi
callq 0x8466
movq 0x40(%rsp), %rax
movq (%rax), %rbx
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %rsp, %rsi
callq 0x84e2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb0e2
leaq 0x80(%rsp), %rdi
callq 0x8466
movq 0x48(%rsp), %rax
incl %eax
movq %rax, 0x48(%rsp)
movq %r15, %rdi
callq 0x51f0
movq 0x258(%rsp), %rax
leaq 0xe8(%rsp), %rbx
jmp 0x7054
leaq 0x258(%rsp), %rdi
callq 0x5080
movq 0x1e97e(%rip), %rdi     # 0x25fc8
leaq 0xfc67(%rip), %rsi      # 0x172b8
callq 0x5270
movq %rax, %rdi
callq 0x5160
movq 0x1e963(%rip), %rdi     # 0x25fc8
leaq 0xfbcc(%rip), %rsi      # 0x17238
callq 0x5270
movq %rax, %rdi
movq 0x48(%rsp), %rsi
callq 0x5420
leaq 0xfd0b(%rip), %rsi      # 0x17390
movq %rax, %rdi
callq 0x5270
movq %rax, %rdi
callq 0x5160
leaq 0x8(%rsp), %rdi
callq 0x8466
leaq 0x60(%rsp), %rdi
callq 0x810e
leaq 0xa8(%rsp), %rdi
callq 0x54c8
leaq 0xc8(%rsp), %rdi
callq 0x54c8
leaq 0x158(%rsp), %rdi
callq 0x54c8
leaq 0xe8(%rsp), %rdi
callq 0x54c8
leaq 0x1d8(%rsp), %rdi
callq 0x54c8
leaq 0x258(%rsp), %rdi
callq 0x50a0
addq $0x5e8, %rsp            # imm = 0x5E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x5170
leaq 0xfb72(%rip), %rcx      # 0x1728a
movq %rcx, (%rax)
movq 0x1e88e(%rip), %rsi     # 0x25fb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5410
movq %rax, %rbx
jmp 0x788f
jmp 0x7736
movq %rax, %rbx
leaq 0x258(%rsp), %rdi
callq 0x7d36
jmp 0x789c
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
jmp 0x7770
movq %rax, %rbx
leaq 0x238(%rsp), %rdi
jmp 0x7770
movq %rax, %rbx
leaq 0x218(%rsp), %rdi
callq 0x54c8
jmp 0x778f
jmp 0x7814
jmp 0x778c
jmp 0x778c
jmp 0x778c
jmp 0x778c
jmp 0x778c
jmp 0x778c
jmp 0x778c
jmp 0x778c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x8466
jmp 0x782d
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x7794
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
jmp 0x7821
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x8466
jmp 0x77d2
movq %rax, %rbx
jmp 0x77ec
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
jmp 0x7821
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x8466
leaq 0x108(%rsp), %rdi
jmp 0x7821
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
jmp 0x7821
jmp 0x782a
movq %rax, %rbx
leaq 0x1b8(%rsp), %rdi
jmp 0x7821
jmp 0x7814
movq %rax, %rbx
jmp 0x783a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x54c8
jmp 0x782d
jmp 0x782a
movq %rax, %rbx
leaq 0x460(%rsp), %rdi
callq 0x51f0
leaq 0x8(%rsp), %rdi
callq 0x8466
leaq 0x60(%rsp), %rdi
callq 0x810e
leaq 0xa8(%rsp), %rdi
callq 0x54c8
leaq 0xc8(%rsp), %rdi
callq 0x54c8
leaq 0x158(%rsp), %rdi
callq 0x54c8
leaq 0xe8(%rsp), %rdi
callq 0x54c8
leaq 0x1d8(%rsp), %rdi
callq 0x54c8
leaq 0x258(%rsp), %rdi
callq 0x50a0
movq %rbx, %rdi
callq 0x5430