// File: /workspace/github_cpp_makefile_star2_O1/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 0x3a18
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 0x39bc
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 0x3a1b
movq 0x78(%rbx), %r14
testq %r14, %r14
je 0x3a55
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b6c
movq 0x70(%r14), %r14
jmp 0x3a3f
movslq 0x34(%rbx), %rax
testq %rax, %rax
jle 0x3b1b
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 0x3ab2
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 0x3a8f
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 0x3abd
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 0x3aeb
incq %r11
cmpq %rax, %r11
jne 0x3a80
movq 0x18(%rbx), %rcx
movq 0x60(%rbx), %rdx
movl %eax, %esi
xorl %edi, %edi
testl %eax, %eax
jle 0x3b59
movq (%rdx,%rdi,8), %r8
movq (%rcx,%rdi,8), %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm0
movsd (%r9,%r10,8), %xmm1
mulsd 0x40(%rbx), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, (%r9,%r10,8)
incq %r10
cmpq %r10, %rsi
jne 0x3b36
incq %rdi
cmpq $0x7, %rdi
jne 0x3b27
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop