// File: /workspace/github_cpp_makefile_star2_O3/huiwenliuge[P]EmoAnaer/src/RNNet.cpp
// Function: RNNet::RNNBackward_CROSSENTROPY(double)
void RNNet::RNNBackward_CROSSENTROPY(double lnrate){

    // int i;
    // for(i=0;i<hidlayerNUM;++i){
    //     DLDin2hid[i]=(double*)calloc(sizeof(double),featureNUM);
    //     DLDrh2h[i]=(double*)calloc(sizeof(double),hidlayerNUM);
    //     DLDro2h[i]=(double*)calloc(sizeof(double),EMOTIONNUM);
    // }
    // for(i=0;i<EMOTIONNUM;++i)
    //     DLDk2out[i] =(double*)calloc(sizeof(double),hidlayerNUM);
    lnrt=lnrate;
    int i;
    for(i=0;i<hidlayerNUM;++i){
        memset(DLDin2hid[i],'\0',sizeof(double)*featureNUM);
        memset(DLDrh2h[i],'\0',sizeof(double)*hidlayerNUM);
        memset(DLDro2h[i],'\0',sizeof(double)*EMOTIONNUM);
    }
    for(i=0;i<EMOTIONNUM;++i)
        memset(DLDk2out[i],'\0',sizeof(double)*hidlayerNUM);

    Sentence sentmp = sent;

    while(sentmp){
        _Backward_CROSSENTROPY(sentmp);
        sentmp=sentmp->next;
    }
    
    int j;
    for(i=0;i<hidlayerNUM;++i){
        for(j=0;j<featureNUM;++j){
            in2hid[i][j]-=DLDin2hid[i][j]*lnrt;
        }
        for(j=0;j<hidlayerNUM;++j){
            rh2h[i][j]-=DLDrh2h[i][j]*lnrt;
        }
        for(j=0;j<EMOTIONNUM;++j){
            ro2h[i][j]-=DLDro2h[i][j]*lnrt;
        }
    }
    for(i=0;i<EMOTIONNUM;++i){
        for(j=0;j<hidlayerNUM;++j){
            k2out[i][j]-=DLDk2out[i][j]*lnrt;
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movsd %xmm0, 0x40(%rdi)
cmpl $0x0, 0x34(%rdi)
jle 0x39cc
xorl %r14d, %r14d
movq 0x58(%rbx), %rax
movq (%rax,%r14,8), %rdi
movslq 0x30(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20b0
movq 0x68(%rbx), %rax
movq (%rax,%r14,8), %rdi
movslq 0x34(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20b0
movq 0x70(%rbx), %rax
movq (%rax,%r14,8), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax)
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movq $0x0, 0x30(%rax)
incq %r14
movslq 0x34(%rbx), %rax
cmpq %rax, %r14
jl 0x3970
xorl %r14d, %r14d
movq 0x60(%rbx), %rax
movq (%rax,%r14,8), %rdi
movslq 0x34(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20b0
incq %r14
cmpq $0x7, %r14
jne 0x39cf
movq 0x78(%rbx), %r14
testq %r14, %r14
je 0x3a09
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b1c
movq 0x70(%r14), %r14
jmp 0x39f3
movl 0x34(%rbx), %eax
testl %eax, %eax
jle 0x3acd
movl 0x30(%rbx), %ecx
movq 0x58(%rbx), %rdx
movq 0x10(%rbx), %rsi
movq 0x20(%rbx), %rdi
movq 0x68(%rbx), %r8
movq 0x70(%rbx), %r9
movq 0x28(%rbx), %r10
xorl %r11d, %r11d
testl %ecx, %ecx
jle 0x3a64
movq (%rdx,%r11,8), %r14
movq (%rsi,%r11,8), %r15
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd 0x40(%rbx), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r15,%r12,8)
incq %r12
cmpq %r12, %rcx
jne 0x3a41
movq (%r8,%r11,8), %r14
movq (%rdi,%r11,8), %r15
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd 0x40(%rbx), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r15,%r12,8)
incq %r12
cmpq %r12, %rax
jne 0x3a6f
movq (%r9,%r11,8), %r14
movq (%r10,%r11,8), %r15
xorl %r12d, %r12d
movsd (%r14,%r12,8), %xmm0
movsd (%r15,%r12,8), %xmm1
mulsd 0x40(%rbx), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r15,%r12,8)
incq %r12
cmpq $0x7, %r12
jne 0x3a9d
incq %r11
cmpq %rax, %r11
jne 0x3a32
movq 0x18(%rbx), %rcx
movq 0x60(%rbx), %rdx
xorl %esi, %esi
testl %eax, %eax
jle 0x3b09
movq (%rdx,%rsi,8), %rdi
movq (%rcx,%rsi,8), %r8
xorl %r9d, %r9d
movsd (%rdi,%r9,8), %xmm0
movsd (%r8,%r9,8), %xmm1
mulsd 0x40(%rbx), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r8,%r9,8)
incq %r9
cmpq %r9, %rax
jne 0x3ae6
incq %rsi
cmpq $0x7, %rsi
jne 0x3ad7
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop