// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r12
pushq $0x38
popq %rdi
callq 0x21d0
movq %rax, -0x30(%rbp)
pushq $0x1
popq %rdi
movl $0x1a5, %esi            # imm = 0x1A5
callq 0x20c0
movq %rax, %r15
andq $0x0, 0x50(%r12)
movq %rbx, -0x50(%rbp)
movq %rbx, %rdi
callq 0x2070
cltq
movq %rax, -0x48(%rbp)
pushq $0x8
popq %r14
xorl %r13d, %r13d
movq %r12, -0x58(%rbp)
cmpq $0x7, %r13
je 0x2fed
pushq $0x1
popq %rdi
pushq $0x65
popq %rsi
callq 0x20c0
movq %rax, %rbx
movq -0x30(%rbp), %rax
movq %rbx, (%rax,%r13,8)
movq %rbx, %rdi
movq -0x50(%rbp), %rsi
callq 0x2130
movq -0x48(%rbp), %rax
leaq (%rbx,%rax), %rdi
movq 0x80(%r12), %rax
movq %r13, -0x38(%rbp)
movq (%rax,%r13,8), %rsi
callq 0x2130
movq %rbx, %rdi
leaq 0x3283(%rip), %rsi      # 0x6074
callq 0x21a0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x3271(%rip), %rsi      # 0x6076
movq %r15, %rdx
xorl %eax, %eax
callq 0x2250
cmpl $-0x1, %eax
je 0x2fd8
movq %r15, %rdi
callq 0x4fc2
movl %eax, %ebx
pushq $0x78
popq %rdi
callq 0x21d0
movq %rax, %r13
movq 0x50(%r12), %rax
movq %rax, (%r13)
incq %rax
movq %rax, 0x50(%r12)
movq %r15, 0x8(%r13)
movl %ebx, 0x10(%r13)
movl 0x30(%r12), %esi
movq (%r12), %rdx
movq %r15, %rdi
callq 0x4fec
movq %rax, 0x18(%r13)
movq %r12, %r15
movslq %ebx, %r12
leaq (,%r12,8), %rbx
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x20(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x28(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x30(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x58(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x60(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x68(%r13)
movq %rbx, %rdi
callq 0x21d0
movq %rax, 0x38(%r13)
movq %r14, %rdi
pushq $0x7
popq %rbx
movq %rbx, %rsi
callq 0x20c0
movq %rax, 0x48(%r13)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20c0
movq %rax, 0x40(%r13)
movq %r15, %rax
movslq 0x34(%r15), %r15
movslq 0x30(%rax), %rax
movq %rax, -0x60(%rbp)
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
movq %r12, -0x68(%rbp)
xorl %r12d, %r12d
cmpq %r12, -0x68(%rbp)
je 0x2f9b
movq %r14, %rdi
pushq $0x7
popq %rbx
movq %rbx, %rsi
callq 0x20c0
movq 0x38(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movq 0x20(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movq 0x28(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20c0
movq 0x30(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20c0
movq 0x58(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq %r15, %rsi
callq 0x20c0
movq 0x60(%r13), %rcx
movq %rax, (%rcx,%r12,8)
movq %r14, %rdi
movq -0x60(%rbp), %rsi
callq 0x20c0
movq 0x68(%r13), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
jmp 0x2f00
movq 0x48(%r13), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq -0x38(%rbp), %rdx
movq %rcx, (%rax,%rdx,8)
movq -0x58(%rbp), %r12
movq 0x78(%r12), %rax
movq %rax, 0x70(%r13)
movq %r13, 0x78(%r12)
movl $0x1a5, %esi            # imm = 0x1A5
pushq $0x1
popq %rdi
callq 0x20c0
movq %rax, %r15
jmp 0x2dfa
movq -0x40(%rbp), %rdi
callq 0x2170
movq -0x38(%rbp), %r13
incq %r13
jmp 0x2d9e
xorl %ebx, %ebx
cmpq $0x7, %rbx
je 0x3007
movq -0x30(%rbp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x21b0
incq %rbx
jmp 0x2fef
movq -0x30(%rbp), %rdi
callq 0x21b0
movq 0x50(%r12), %rsi
movq 0x5fbc(%rip), %rdi      # 0x8fd8
callq 0x2150
movq %rax, %rdi
callq 0x20a0
movq 0x78(%r12), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop