// File: /workspace/github_cpp_makefile_star2_O1/btbujiangjun[P]abcdl/include/utils/ModelLoader.h
// Function: bool abcdl::utils::ModelLoader::read<float>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<abcdl::algebra::Matrix<float>*, std::allocator<abcdl::algebra::Matrix<float>*>>*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
bool ModelLoader::read(const std::string& path,
                       std::vector<abcdl::algebra::Matrix<T>*>* models,
                       const std::string& signature){
    //std::ifstream in_file(path, std::ios::binary);
    std::ifstream in_file(path, std::ios::in);
    if(!in_file){
        LOG(FATAL) << "Can't open Filename:" + path;
        return false;
    }

    size_t num_models = 0;
    std::string read_signature(signature.size(), ' ');

    in_file >> read_signature;
    //in_file.read(&read_signature[0], sizeof(char) * signature.size());
    if(read_signature != signature){
        LOG(FATAL) << "ModelLoader read model error:[signature error]";
        in_file.close();
        return false;
    }

    //in_file.read((char*)(&num_models), sizeof(size_t));
    in_file >> num_models;

    std::vector<ModelInfo> infos;
    for(size_t i = 0; i != num_models; i++){
        ModelInfo info;
        //in_file.read(&info.type, sizeof(char));
        //in_file.read((char*)(&info.rows), sizeof(size_t));
        //in_file.read((char*)(&info.cols), sizeof(size_t));
        in_file >> info.type;
        in_file >> info.rows;
        in_file >> info.cols;
        infos.push_back(info);
    }

    models->clear();
    for(size_t i = 0; i != num_models; i++){
        ModelInfo info = infos[i];
        size_t size      = info.rows * info.cols;
        
        T* data = new T[size];
        //in_file.read((char*)data, sizeof(T) * size);
        for(size_t j = 0; j < size; j++){
            in_file >> data[j];
        }
        auto mat = new abcdl::algebra::Matrix<T>();
        mat->set_shallow_data(data, info.rows, info.cols);
        models->push_back(mat);
    }

    in_file.close();
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f8, %rsp            # imm = 0x3F8
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
leaq 0x1f0(%rsp), %r12
movq %r12, %rdi
movl $0x8, %edx
callq 0x9550
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x210(%rsp,%rax)
je 0x17153
leaq 0x252fb(%rip), %rsi     # 0x3c3ed
leaq 0x60(%rsp), %rdi
movl $0xa0, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x252fc(%rip), %rsi     # 0x3c409
leaq 0x18(%rsp), %rdi
movq %rbx, %rdx
callq 0x18003
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x93b0
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17141
callq 0x9350
leaq 0x60(%rsp), %rdi
callq 0x38b76
xorl %r14d, %r14d
jmp 0x173d4
movq %r14, 0x38(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x8(%r15), %rsi
leaq 0x28(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x18(%rsp), %rdi
movl $0x20, %edx
callq 0x93c0
leaq 0x1f0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x9400
movq 0x20(%rsp), %rdx
movb $0x1, %r14b
cmpq 0x8(%r15), %rdx
jne 0x171ba
testq %rdx, %rdx
je 0x171b7
movq (%r15), %rsi
movq 0x18(%rsp), %rdi
callq 0x9380
testl %eax, %eax
setne %r14b
jmp 0x171ba
xorl %r14d, %r14d
testb %r14b, %r14b
je 0x1720c
leaq 0x25227(%rip), %rsi     # 0x3c3ed
leaq 0x60(%rsp), %rdi
movl $0xaa, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x2523d(%rip), %rsi     # 0x3c41e
leaq 0x60(%rsp), %rdi
movl $0x2e, %edx
callq 0x93b0
leaq 0x60(%rsp), %rdi
callq 0x38b76
leaq 0x1f0(%rsp), %rdi
callq 0x9090
jmp 0x173c1
leaq 0x1f0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x91c0
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x172ad
leaq 0x48(%rsp), %r15
leaq 0x50(%rsp), %r12
xorl %ebx, %ebx
leaq 0x1f0(%rsp), %r13
leaq 0x40(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x9430
movq %r13, %rdi
movq %r15, %rsi
callq 0x91c0
movq %r13, %rdi
movq %r12, %rsi
callq 0x91c0
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x17296
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsi)
movups 0x40(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x18, 0x68(%rsp)
jmp 0x172a3
leaq 0x60(%rsp), %rdi
movq %rbp, %rdx
callq 0x18084
incq %rbx
cmpq 0x8(%rsp), %rbx
jne 0x17250
movl %r14d, 0x14(%rsp)
movq 0x38(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x172c4
movq %rax, 0x8(%rcx)
cmpq $0x0, 0x8(%rsp)
je 0x1739b
xorl %r14d, %r14d
leaq 0x1f0(%rsp), %r12
movq 0x60(%rsp), %rax
leaq (%r14,%r14,2), %rcx
movq 0x8(%rax,%rcx,8), %r13
movq 0x10(%rax,%rcx,8), %rbp
movq %rbp, 0x58(%rsp)
imulq %r13, %rbp
movq %rbp, %rax
shrq $0x3e, %rax
leaq (,%rbp,4), %rcx
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x9030
movq %rax, %rbx
movq %rax, %r15
testq %rbp, %rbp
je 0x17338
movq %r12, %rdi
movq %r15, %rsi
callq 0x9670
addq $0x4, %r15
decq %rbp
jne 0x17324
movl $0x28, %edi
callq 0x9370
movq %rax, %r15
movq %rax, %rdi
callq 0x19a38
movq %r15, 0x40(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq 0x58(%rsp), %rcx
callq 0x1a00a
movq 0x38(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x17383
movq 0x40(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x1738d
leaq 0x40(%rsp), %rdx
callq 0x181f2
incq %r14
cmpq 0x8(%rsp), %r14
jne 0x172db
leaq 0x1f0(%rsp), %rdi
callq 0x9090
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
leaq 0x28(%rsp), %rbx
movl 0x14(%rsp), %r14d
je 0x173c1
callq 0x9350
movq 0x18(%rsp), %rdi
cmpq %rbx, %rdi
je 0x173d0
callq 0x9350
xorb $0x1, %r14b
leaq 0x1f0(%rsp), %rdi
callq 0x90b0
movl %r14d, %eax
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1744f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x38b76
jmp 0x17461
jmp 0x17437
jmp 0x17432
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17426
callq 0x9350
jmp 0x17426
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x38b76
jmp 0x17475
movq %rax, %rbx
jmp 0x17475
movq %rax, %rbx
jmp 0x17461
movq %rax, %rbx
movq %r15, %rdi
callq 0x9350
jmp 0x17452
jmp 0x1744f
jmp 0x1744f
jmp 0x1744f
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x17461
callq 0x9350
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x17475
callq 0x9350
leaq 0x1f0(%rsp), %rdi
callq 0x90b0
movq %rbx, %rdi
callq 0x95d0