// File: 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
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x40(%rax)
movl $0x0, -0x14(%rbp)
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x40bb
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x30(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20a0
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x34(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20a0
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x20a0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x404a
movl $0x0, -0x14(%rbp)
cmpl $0x7, -0x14(%rbp)
jge 0x40f2
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movslq 0x34(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x20a0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x40c2
movq -0x30(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4120
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4340
movq -0x20(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x40fe
movl $0x0, -0x14(%rbp)
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x42a0
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x30(%rcx), %eax
jge 0x41ac
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x24(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x40(%rax), %xmm2
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x413e
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x4221
movq -0x30(%rbp), %rax
movq 0x68(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x24(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x40(%rax), %xmm2
movq 0x20(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x41b3
movl $0x0, -0x24(%rbp)
cmpl $0x7, -0x24(%rbp)
jge 0x4290
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x24(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x40(%rax), %xmm2
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4228
jmp 0x4292
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4127
movl $0x0, -0x14(%rbp)
cmpl $0x7, -0x14(%rbp)
jge 0x4336
movl $0x0, -0x24(%rbp)
movq -0x30(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0x4326
movq -0x30(%rbp), %rax
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq -0x24(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd 0x40(%rax), %xmm2
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x42b8
jmp 0x4328
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x42a7
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)