// File: /workspace/github_cpp_makefile_star2_O1/huiwenliuge[P]EmoAnaer/src/RNNet.cpp
// Function: RNNet::FetchSent(char const*)
Sentence RNNet::FetchSent(const char* pathRoot){

    //Sentence ret;
    char** filelist=(char**)malloc(sizeof(char*)*EMOTIONNUM);
    int i,j,len,pathrootlen;
    FILE* sentfp;
    char* line=(char*)calloc(sizeof(char),421);
    totnum = 0;
    pathrootlen=strlen(pathRoot);
    for(i=0;i<EMOTIONNUM;++i){
        filelist[i]=(char*)calloc(sizeof(char),101);
        strcpy(filelist[i],pathRoot);
        strcpy(filelist[i]+pathrootlen,EMOLIST[i]);
        //std::cout<< filelist[i] <<std::endl;

        sentfp=fopen(filelist[i],"r");
        // const double* ans=(double*)calloc(sizeof(double),EMOTIONNUM);
        // ans[i]=1.0;

        while(fscanf(sentfp,"%s\n",line)!=-1){

            len=strLenUTF8(line);
            Sentence sentunit=(Sentence)malloc(sizeof(struct sentence));
            sentunit->num = totnum;
            totnum++;
            sentunit->schar=line;
            sentunit->tlen=len;
            sentunit->inVec=crtInvec(line,featureNUM,ccdict);
            sentunit->hidLay=(double**)malloc(sizeof(double*)*len);
            sentunit->kLayer=(double**)malloc(sizeof(double*)*len);
            sentunit->outLay=(double**)malloc(sizeof(double*)*len);
            sentunit->DLDo  =(double**)malloc(sizeof(double*)*len);
            sentunit->DLDh  =(double**)malloc(sizeof(double*)*len);
            sentunit->DLDx  =(double**)malloc(sizeof(double*)*len);
            sentunit->energy=(double**)malloc(sizeof(double*)*len);
            sentunit->stdAns=(double*)calloc(sizeof(double),EMOTIONNUM);
            sentunit->eng=(double*)calloc(sizeof(double),EMOTIONNUM);

            for(j=0;j<len;++j){
                // for(int k=0;k<featureNUM;++k){
                //     std::cout<<sentunit->inVec[j][k];
                // }
                //std::cout<<std::endl;
                sentunit->energy[j]=(double*)calloc(sizeof(double),EMOTIONNUM);
                sentunit->hidLay[j]=(double*)calloc(sizeof(double),hidlayerNUM);
                sentunit->kLayer[j]=(double*)calloc(sizeof(double),hidlayerNUM);
                sentunit->outLay[j]=(double*)calloc(sizeof(double),EMOTIONNUM);
                sentunit->DLDo[j]  =(double*)calloc(sizeof(double),EMOTIONNUM);
                sentunit->DLDh[j]  =(double*)calloc(sizeof(double),hidlayerNUM);
                sentunit->DLDx[j]  =(double*)calloc(sizeof(double),featureNUM);
            }

            sentunit->stdAns[i]=1.0;
            sentunit->next=sent;
            sent=sentunit;

            
            line=(char*)calloc(sizeof(char),421);
        }
        fclose(sentfp);

    }

    for(i=0;i<EMOTIONNUM;++i)
        free(filelist[i]);
    //fclose(sentfp);
    free(filelist);
    std::cout<< totnum <<std::endl;
    return sent;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movl $0x38, %edi
callq 0x21f0
movq %rax, %r13
movl $0x1, %edi
movl $0x1a5, %esi            # imm = 0x1A5
callq 0x20c0
movq %rax, %r14
movq $0x0, 0x50(%r12)
movq %rbx, -0x48(%rbp)
movq %rbx, %rdi
callq 0x2080
cltq
movq %rax, -0x40(%rbp)
xorl %ebx, %ebx
movq %r12, -0x38(%rbp)
movq %r13, -0x50(%rbp)
movl $0x1, %edi
movl $0x65, %esi
callq 0x20c0
movq %rax, %r15
movq %rax, (%r13,%rbx,8)
movq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0x2140
movq -0x40(%rbp), %rax
leaq (%r15,%rax), %rdi
movq 0x80(%r12), %rax
movq (%rax,%rbx,8), %rsi
callq 0x2140
movq %r15, %rdi
leaq 0x30b1(%rip), %rsi      # 0x6074
callq 0x21c0
movq %rax, -0x30(%rbp)
movq %rax, %rdi
leaq 0x30a0(%rip), %rsi      # 0x6076
movq %r14, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $-0x1, %eax
je 0x31cd
movq %rbx, -0x58(%rbp)
movq %r14, %rdi
callq 0x55e3
movl %eax, %r13d
movl $0x78, %edi
callq 0x21f0
movq %rax, %r15
movq 0x50(%r12), %rax
movq %rax, (%r15)
incq %rax
movq %rax, 0x50(%r12)
movq %r14, 0x8(%r15)
movl %r13d, 0x10(%r15)
movl 0x30(%r12), %esi
movq (%r12), %rdx
movq %r14, %rdi
callq 0x5634
movq %rax, 0x18(%r15)
movslq %r13d, %rbx
leaq (,%rbx,8), %r14
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x20(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x28(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x30(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x58(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x60(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x68(%r15)
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x38(%r15)
movl $0x8, %edi
movl $0x7, %esi
callq 0x20c0
movq %rax, 0x48(%r15)
movl $0x8, %edi
movl $0x7, %esi
callq 0x20c0
movq %rax, 0x40(%r15)
testl %ebx, %ebx
jle 0x3175
movq -0x38(%rbp), %rax
movslq 0x34(%rax), %r14
movslq 0x30(%rax), %r12
movl %r13d, %r13d
xorl %ebx, %ebx
movl $0x8, %edi
movl $0x7, %esi
callq 0x20c0
movq 0x38(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movq %r14, %rsi
callq 0x20c0
movq 0x20(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movq %r14, %rsi
callq 0x20c0
movq 0x28(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movl $0x7, %esi
callq 0x20c0
movq 0x30(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movl $0x7, %esi
callq 0x20c0
movq 0x58(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movq %r14, %rsi
callq 0x20c0
movq 0x60(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
movl $0x8, %edi
movq %r12, %rsi
callq 0x20c0
movq 0x68(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r13
jne 0x30d0
movq 0x48(%r15), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq -0x58(%rbp), %rbx
movq %rcx, (%rax,%rbx,8)
movq -0x38(%rbp), %r12
movq 0x78(%r12), %rax
movq %rax, 0x70(%r15)
movq %r15, 0x78(%r12)
movl $0x1, %edi
movl $0x1a5, %esi            # imm = 0x1A5
callq 0x20c0
movq %rax, %r14
movq -0x30(%rbp), %rdi
leaq 0x2ebc(%rip), %rsi      # 0x6076
movq %rax, %rdx
xorl %eax, %eax
callq 0x2280
cmpl $-0x1, %eax
jne 0x2fed
movq -0x30(%rbp), %rdi
callq 0x2180
incq %rbx
cmpq $0x7, %rbx
movq -0x50(%rbp), %r13
jne 0x2f7d
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
callq 0x21d0
incq %rbx
cmpq $0x7, %rbx
jne 0x31e9
movq %r13, %rdi
callq 0x21d0
movq 0x50(%r12), %rsi
movq 0x4dc8(%rip), %rdi      # 0x7fd8
callq 0x2160
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2170
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq 0x78(%r12), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop