// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/lstm_layer.c
// Function: forward_lstm_layer
void forward_lstm_layer(layer l, network state)
{
    network s = { 0 };
    s.train = state.train;
    int i;
    layer wf = *(l.wf);
    layer wi = *(l.wi);
    layer wg = *(l.wg);
    layer wo = *(l.wo);

    layer uf = *(l.uf);
    layer ui = *(l.ui);
    layer ug = *(l.ug);
    layer uo = *(l.uo);

    fill_cpu(l.outputs * l.batch * l.steps, 0, wf.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, wi.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, wg.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, wo.delta, 1);

    fill_cpu(l.outputs * l.batch * l.steps, 0, uf.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, ui.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, ug.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, uo.delta, 1);
    if (state.train) {
        fill_cpu(l.outputs * l.batch * l.steps, 0, l.delta, 1);
    }

    for (i = 0; i < l.steps; ++i) {
        s.input = l.h_cpu;
        forward_connected_layer(wf, s);							
        forward_connected_layer(wi, s);							
        forward_connected_layer(wg, s);							
        forward_connected_layer(wo, s);							

        s.input = state.input;
        forward_connected_layer(uf, s);							
        forward_connected_layer(ui, s);							
        forward_connected_layer(ug, s);							
        forward_connected_layer(uo, s);							

        copy_cpu(l.outputs*l.batch, wf.output, 1, l.f_cpu, 1);
        axpy_cpu(l.outputs*l.batch, 1, uf.output, 1, l.f_cpu, 1);

        copy_cpu(l.outputs*l.batch, wi.output, 1, l.i_cpu, 1);	
        axpy_cpu(l.outputs*l.batch, 1, ui.output, 1, l.i_cpu, 1);	

        copy_cpu(l.outputs*l.batch, wg.output, 1, l.g_cpu, 1);	
        axpy_cpu(l.outputs*l.batch, 1, ug.output, 1, l.g_cpu, 1);	

        copy_cpu(l.outputs*l.batch, wo.output, 1, l.o_cpu, 1);	
        axpy_cpu(l.outputs*l.batch, 1, uo.output, 1, l.o_cpu, 1);	

        activate_array(l.f_cpu, l.outputs*l.batch, LOGISTIC);		
        activate_array(l.i_cpu, l.outputs*l.batch, LOGISTIC);		
        activate_array(l.g_cpu, l.outputs*l.batch, TANH);			
        activate_array(l.o_cpu, l.outputs*l.batch, LOGISTIC);		

        copy_cpu(l.outputs*l.batch, l.i_cpu, 1, l.temp_cpu, 1);		
        mul_cpu(l.outputs*l.batch, l.g_cpu, 1, l.temp_cpu, 1);		
        mul_cpu(l.outputs*l.batch, l.f_cpu, 1, l.c_cpu, 1);			
        axpy_cpu(l.outputs*l.batch, 1, l.temp_cpu, 1, l.c_cpu, 1);	

        copy_cpu(l.outputs*l.batch, l.c_cpu, 1, l.h_cpu, 1);			
        activate_array(l.h_cpu, l.outputs*l.batch, TANH);		
        mul_cpu(l.outputs*l.batch, l.o_cpu, 1, l.h_cpu, 1);	

        copy_cpu(l.outputs*l.batch, l.c_cpu, 1, l.cell_cpu, 1);		
        copy_cpu(l.outputs*l.batch, l.h_cpu, 1, l.output, 1);

        state.input += l.inputs*l.batch;
        l.output    += l.outputs*l.batch;
        l.cell_cpu      += l.outputs*l.batch;

        increment_layer(&wf, 1);
        increment_layer(&wi, 1);
        increment_layer(&wg, 1);
        increment_layer(&wo, 1);

        increment_layer(&uf, 1);
        increment_layer(&ui, 1);
        increment_layer(&ug, 1);
        increment_layer(&uo, 1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2bc8, %rsp           # imm = 0x2BC8
leaq 0x2c00(%rsp), %r13
leaq 0x5b8(%rsp), %rbx
movl $0x110, %edx            # imm = 0x110
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31c0
movl 0x3198(%rsp), %r12d
movl %r12d, 0xf8(%rbx)
movq 0x468(%r13), %rsi
leaq 0x2728(%rsp), %r14
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
callq 0x32b0
movq 0x478(%r13), %rsi
leaq 0x2288(%rsp), %rbx
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
callq 0x32b0
movq 0x488(%r13), %rsi
leaq 0x1de8(%rsp), %rbp
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbp, %rdi
callq 0x32b0
movq 0x458(%r13), %rsi
leaq 0x1948(%rsp), %r15
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
callq 0x32b0
movq 0x460(%r13), %rsi
leaq 0x14a8(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x470(%r13), %rsi
leaq 0x1008(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x480(%r13), %rsi
leaq 0xb68(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x450(%r13), %rsi
leaq 0x6c8(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r14), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%rbx), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%rbp), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r15), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0x14a8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0x1008(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0xb68(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0x6c8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
testl %r12d, %r12d
je 0x3f655
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r13), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
cmpl $0x0, 0xc0(%r13)
jle 0x3fcf4
leaq 0x30a0(%rsp), %rax
movq 0xd8(%rax), %rbp
xorl %ebx, %ebx
leaq 0x5b8(%rsp), %r14
leaq 0xb68(%rsp), %r15
leaq 0x6c8(%rsp), %r12
movq 0x310(%r13), %rax
movq %rax, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x2728(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x2288(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1de8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1948(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movq %rbp, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x14a8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1008(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl $0x94, %ecx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x2990(%rsp), %rsi
movq 0x358(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1710(%rsp), %rsi
movq 0x358(%r13), %rcx
movss 0x157cf(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x24f0(%rsp), %rsi
movq 0x360(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1270(%rsp), %rsi
movq 0x360(%r13), %rcx
movss 0x15777(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x2050(%rsp), %rsi
movq 0x368(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0xdd0(%rsp), %rsi
movq 0x368(%r13), %rcx
movss 0x1571f(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1bb0(%rsp), %rsi
movq 0x370(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x930(%rsp), %rsi
movq 0x370(%r13), %rcx
movss 0x156c7(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movq 0x358(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
xorl %edx, %edx
callq 0x28c99
movq 0x360(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
xorl %edx, %edx
callq 0x28c99
movq 0x368(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
movl $0x5, %edx
callq 0x28c99
movq 0x370(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
xorl %edx, %edx
callq 0x28c99
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x360(%r13), %rsi
movq 0x320(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x368(%r13), %rsi
movq 0x320(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29c9f
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x358(%r13), %rsi
movq 0x378(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29c9f
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x320(%r13), %rsi
movq 0x378(%r13), %rcx
movss 0x155c4(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x378(%r13), %rsi
movq 0x310(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movq 0x310(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
movl $0x5, %edx
callq 0x28c99
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x370(%r13), %rsi
movq 0x310(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29c9f
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x378(%r13), %rsi
movq 0x350(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x310(%r13), %rsi
movq 0x268(%r13), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movslq 0x54(%r13), %rax
movslq 0x48(%r13), %rcx
movslq 0x58(%r13), %rdx
imulq %rcx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x268(%r13)
addq %rdx, 0x350(%r13)
movl 0x2770(%rsp), %edx
imull 0x2780(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x2990(%rsp)
addq %rdx, 0x2988(%rsp)
addq %rdx, 0x29e8(%rsp)
addq %rdx, 0x29f0(%rsp)
movl 0x22d0(%rsp), %edx
imull 0x22e0(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x24f0(%rsp)
addq %rdx, 0x24e8(%rsp)
addq %rdx, 0x2548(%rsp)
addq %rdx, 0x2550(%rsp)
movl 0x1e30(%rsp), %edx
imull 0x1e40(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x2050(%rsp)
addq %rdx, 0x2048(%rsp)
addq %rdx, 0x20a8(%rsp)
addq %rdx, 0x20b0(%rsp)
movl 0x1990(%rsp), %edx
imull 0x19a0(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x1bb0(%rsp)
addq %rdx, 0x1ba8(%rsp)
addq %rdx, 0x1c08(%rsp)
addq %rdx, 0x1c10(%rsp)
movl 0x14f0(%rsp), %edx
imull 0x1500(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x1710(%rsp)
addq %rdx, 0x1708(%rsp)
addq %rdx, 0x1768(%rsp)
addq %rdx, 0x1770(%rsp)
movl 0x1050(%rsp), %edx
imull 0x1060(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x1270(%rsp)
addq %rdx, 0x1268(%rsp)
addq %rdx, 0x12c8(%rsp)
addq %rdx, 0x12d0(%rsp)
movl 0xbb0(%rsp), %edx
imull 0xbc0(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0xdd0(%rsp)
addq %rdx, 0xdc8(%rsp)
addq %rdx, 0xe28(%rsp)
addq %rdx, 0xe30(%rsp)
movl 0x710(%rsp), %edx
imull 0x720(%rsp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x930(%rsp)
addq %rdx, 0x928(%rsp)
addq %rdx, 0x988(%rsp)
imulq %rcx, %rax
addq %rdx, 0x990(%rsp)
leaq (%rbp,%rax,4), %rbp
incl %ebx
cmpl 0xc0(%r13), %ebx
jl 0x3f68c
addq $0x2bc8, %rsp           # imm = 0x2BC8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq