// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/rnn_layer.c
// Function: forward_rnn_layer
void forward_rnn_layer(layer l, network net)
{
    network s = net;
    s.train = net.train;
    int i;
    layer input_layer = *(l.input_layer);
    layer self_layer = *(l.self_layer);
    layer output_layer = *(l.output_layer);

    fill_cpu(l.outputs * l.batch * l.steps, 0, output_layer.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, self_layer.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, input_layer.delta, 1);
    if(net.train) fill_cpu(l.outputs * l.batch, 0, l.state, 1);

    for (i = 0; i < l.steps; ++i) {
        s.input = net.input;
        forward_connected_layer(input_layer, s);

        s.input = l.state;
        forward_connected_layer(self_layer, s);

        float *old_state = l.state;
        if(net.train) l.state += l.outputs*l.batch;
        if(l.shortcut){
            copy_cpu(l.outputs * l.batch, old_state, 1, l.state, 1);
        }else{
            fill_cpu(l.outputs * l.batch, 0, l.state, 1);
        }
        axpy_cpu(l.outputs * l.batch, 1, input_layer.output, 1, l.state, 1);
        axpy_cpu(l.outputs * l.batch, 1, self_layer.output, 1, l.state, 1);

        s.input = l.state;
        forward_connected_layer(output_layer, s);

        net.input += l.inputs*l.batch;
        increment_layer(&input_layer, 1);
        increment_layer(&self_layer, 1);
        increment_layer(&output_layer, 1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x14c8, %rsp           # imm = 0x14C8
leaq 0x19a0(%rsp), %r14
leaq 0x1500(%rsp), %r12
leaq 0x5d8(%rsp), %rbx
movl $0x110, %edx            # imm = 0x110
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32b0
movl 0xf8(%r14), %eax
movl %eax, 0x5c0(%rsp)
movl %eax, 0xf8(%rbx)
movq 0x390(%r12), %rsi
leaq 0x6e8(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x398(%r12), %rsi
leaq 0xb88(%rsp), %r15
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
callq 0x32b0
movq 0x3a0(%r12), %rsi
leaq 0x1028(%rsp), %r14
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
callq 0x32b0
movslq 0x58(%r12), %rbx
movslq 0x48(%r12), %rcx
movq %rcx, 0x5b8(%rsp)
imulq %rcx, %rbx
movl 0xc0(%r12), %r13d
movl %ebx, %ebp
imull %r13d, %ebp
movq 0x260(%r14), %rsi
pushq $0x1
popq %r14
xorps %xmm0, %xmm0
movl %ebp, %edi
movl %r14d, %edx
callq 0x1b449
movq 0x260(%r15), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edi
movl %r14d, %edx
callq 0x1b449
leaq 0x6e8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edi
movl %r14d, %edx
callq 0x1b449
xorl %r15d, %r15d
movq 0x1e0(%r12), %r14
cmpl $0x0, 0x5c0(%rsp)
je 0x2da44
pushq $0x1
popq %rdx
xorps %xmm0, %xmm0
movl %ebx, %edi
movq %r14, %rsi
callq 0x1b449
movq %rbx, %rcx
jmp 0x2da46
xorl %ecx, %ecx
movl 0x44(%r12), %eax
movl %eax, 0x5cc(%rsp)
movl 0x54(%r12), %eax
imull 0x5b8(%rsp), %eax
cltq
leaq 0x19a0(%rsp), %rdx
movq 0xd8(%rdx), %rdx
testl %r13d, %r13d
cmovgl %r13d, %r15d
shlq $0x2, %rcx
movq %rcx, 0x5b8(%rsp)
shlq $0x2, %rax
movq %rax, 0x5d0(%rsp)
pushq $0x1
popq %rbp
subl $0x1, %r15d
jb 0x2dc7f
movq %rbx, %r12
movq %rdx, 0x5c0(%rsp)
movq %rdx, 0x6b0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x6e8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
pushq $0x22
popq %r13
movq %r13, %rcx
leaq 0x5d8(%rsp), %rbx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movq %r14, 0x6b0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0xb88(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r13, %rcx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movq 0x5b8(%rsp), %rax
leaq (%r14,%rax), %r13
cmpl $0x0, 0x5cc(%rsp)
je 0x2db42
movq %r12, %rbx
movl %ebx, %edi
movq %r14, %rsi
movl %ebp, %edx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x1b5a3
jmp 0x2db54
xorps %xmm0, %xmm0
movq %r12, %rbx
movl %ebx, %edi
movq %r13, %rsi
movl %ebp, %edx
callq 0x1b449
movq 0x950(%rsp), %rsi
movl %ebx, %edi
movss 0x1e4a2(%rip), %xmm0    # 0x4c008
movl %ebp, %edx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x1b3ed
movq 0xdf0(%rsp), %rsi
movl %ebx, %edi
movss 0x1e483(%rip), %xmm0    # 0x4c008
movl %ebp, %edx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x1b3ed
movq %r13, 0x6b0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1028(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
pushq $0x22
popq %rcx
leaq 0x5d8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl 0x730(%rsp), %eax
imull 0x740(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0x950(%rsp)
addq %rax, 0x948(%rsp)
addq %rax, 0x9a8(%rsp)
addq %rax, 0x9b0(%rsp)
movl 0xbd0(%rsp), %eax
imull 0xbe0(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0xdf0(%rsp)
addq %rax, 0xde8(%rsp)
addq %rax, 0xe48(%rsp)
addq %rax, 0xe50(%rsp)
movl 0x1070(%rsp), %eax
imull 0x1080(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0x1290(%rsp)
addq %rax, 0x1288(%rsp)
addq %rax, 0x12e8(%rsp)
addq %rax, 0x12f0(%rsp)
movq 0x5c0(%rsp), %rdx
addq 0x5d0(%rsp), %rdx
movq %r13, %r14
jmp 0x2da92
addq $0x14c8, %rsp           # imm = 0x14C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq