// File: /workspace/github_c_makefile_star2_O3/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 $0x14b8, %rsp           # imm = 0x14B8
leaq 0x1990(%rsp), %r14
leaq 0x14f0(%rsp), %r13
leaq 0x5c8(%rsp), %rbx
movl $0x110, %edx            # imm = 0x110
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32b0
movl 0xf8(%r14), %r14d
movl %r14d, 0xf8(%rbx)
movq 0x390(%r13), %rsi
leaq 0xb78(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x398(%r13), %rsi
leaq 0x6d8(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x3a0(%r13), %rsi
leaq 0x1018(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movl 0x48(%r13), %r15d
movl 0xc0(%r13), %r12d
movl 0x58(%r13), %ebx
imull %r15d, %ebx
movl %ebx, %ebp
imull %r12d, %ebp
leaq 0x1018(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edi
movl $0x1, %edx
callq 0x29d83
leaq 0x6d8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edi
movl $0x1, %edx
callq 0x29d83
leaq 0xb78(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edi
movq %r13, %rbp
movl $0x1, %edx
callq 0x29d83
testl %r14d, %r14d
je 0x3ac4f
movq 0x1e0(%rbp), %rsi
xorps %xmm0, %xmm0
movl %ebx, %edi
movl $0x1, %edx
callq 0x29d83
testl %r12d, %r12d
jle 0x3ae82
imull 0x54(%rbp), %r15d
testl %r14d, %r14d
movl 0x44(%rbp), %eax
movl %eax, 0x5b4(%rsp)
movslq %r15d, %rax
leaq 0x1990(%rsp), %rcx
movq 0xd8(%rcx), %r13
movq 0x1e0(%rbp), %rbp
cmovnel %ebx, %r14d
movslq %r14d, %rcx
shlq $0x2, %rcx
movq %rcx, 0x5b8(%rsp)
shlq $0x2, %rax
movq %rax, 0x5c0(%rsp)
leaq 0x5c8(%rsp), %r15
movq %r13, 0x6a0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0xb78(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movq %rbp, 0x6a0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x6d8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movq 0x5b8(%rsp), %rax
leaq (%rax,%rbp), %r14
cmpl $0x0, 0x5b4(%rsp)
je 0x3ad40
movl %ebx, %edi
movq %rbp, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x29fe0
jmp 0x3ad52
xorps %xmm0, %xmm0
movl %ebx, %edi
movq %r14, %rsi
movl $0x1, %edx
callq 0x29d83
movq 0xde0(%rsp), %rsi
movl %ebx, %edi
movss 0x1a2a4(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x29d31
movq 0x940(%rsp), %rsi
movl %ebx, %edi
movss 0x1a27f(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x29d31
movq %r14, 0x6a0(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1018(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x335d8
movl 0xbc0(%rsp), %eax
imull 0xbd0(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0xde0(%rsp)
addq %rax, 0xdd8(%rsp)
addq %rax, 0xe38(%rsp)
addq %rax, 0xe40(%rsp)
movl 0x720(%rsp), %eax
imull 0x730(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0x940(%rsp)
addq %rax, 0x938(%rsp)
addq %rax, 0x998(%rsp)
addq %rax, 0x9a0(%rsp)
movl 0x1060(%rsp), %eax
imull 0x1070(%rsp), %eax
cltq
shlq $0x2, %rax
addq %rax, 0x1280(%rsp)
addq %rax, 0x1278(%rsp)
addq %rax, 0x12d8(%rsp)
addq %rax, 0x12e0(%rsp)
addq 0x5c0(%rsp), %r13
movq %r14, %rbp
decl %r12d
jne 0x3acaa
addq $0x14b8, %rsp           # imm = 0x14B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq