// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
movq %rdi, %rbx
movsd %xmm0, 0x40(%rdi)
xorl %r14d, %r14d
movslq 0x34(%rbx), %rax
cmpq %rax, %r14
jge 0x3761
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)
andq $0x0, 0x30(%rax)
incq %r14
jmp 0x3706
xorl %r14d, %r14d
cmpq $0x7, %r14
je 0x3786
movq 0x60(%rbx), %rax
movq (%rax,%r14,8), %rdi
movslq 0x34(%rbx), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20b0
incq %r14
jmp 0x3764
leaq 0x78(%rbx), %r14
movq (%r14), %r14
testq %r14, %r14
je 0x37a3
movq %rbx, %rdi
movq %r14, %rsi
callq 0x38c0
addq $0x70, %r14
jmp 0x378a
movl 0x34(%rbx), %ecx
movl 0x30(%rbx), %edx
movq 0x70(%rbx), %rsi
movq 0x28(%rbx), %rdi
xorl %r8d, %r8d
testl %edx, %edx
cmovlel %r8d, %edx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
cmpq %rax, %r8
je 0x3876
movq 0x10(%rbx), %r9
movq 0x58(%rbx), %r10
xorl %r11d, %r11d
cmpq %r11, %rdx
je 0x3805
movq (%r10,%r8,8), %r14
movsd (%r14,%r11,8), %xmm0
movq (%r9,%r8,8), %r14
mulsd 0x40(%rbx), %xmm0
movsd (%r14,%r11,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r14,%r11,8)
incq %r11
jmp 0x37d8
movq 0x20(%rbx), %r9
movq 0x68(%rbx), %r10
xorl %r11d, %r11d
cmpq %r11, %rcx
je 0x383d
movq (%r10,%r8,8), %r14
movsd (%r14,%r11,8), %xmm0
movq (%r9,%r8,8), %r14
mulsd 0x40(%rbx), %xmm0
movsd (%r14,%r11,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r14,%r11,8)
incq %r11
jmp 0x3810
movq (%rsi,%r8,8), %r9
movq (%rdi,%r8,8), %r10
xorl %r11d, %r11d
cmpq $0x7, %r11
je 0x386e
movsd (%r9,%r11,8), %xmm0
mulsd 0x40(%rbx), %xmm0
movsd (%r10,%r11,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r10,%r11,8)
incq %r11
jmp 0x3848
incq %r8
jmp 0x37c4
xorl %ecx, %ecx
cmpq $0x7, %rcx
je 0x38ba
movq 0x18(%rbx), %rdx
movq 0x60(%rbx), %rsi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x38b5
movq (%rsi,%rcx,8), %r8
movsd (%r8,%rdi,8), %xmm0
movq (%rdx,%rcx,8), %r8
mulsd 0x40(%rbx), %xmm0
movsd (%r8,%rdi,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%r8,%rdi,8)
incq %rdi
jmp 0x3888
incq %rcx
jmp 0x3878
popq %rbx
popq %r14
popq %rbp
retq
nop