// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/gru_layer.c
// Function: forward_gru_layer
void forward_gru_layer(layer l, network net)
{
    network s = net;
    s.train = net.train;
    int i;
    layer uz = *(l.uz);
    layer ur = *(l.ur);
    layer uh = *(l.uh);

    layer wz = *(l.wz);
    layer wr = *(l.wr);
    layer wh = *(l.wh);

    fill_cpu(l.outputs * l.batch * l.steps, 0, uz.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, ur.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, uh.delta, 1);

    fill_cpu(l.outputs * l.batch * l.steps, 0, wz.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, wr.delta, 1);
    fill_cpu(l.outputs * l.batch * l.steps, 0, wh.delta, 1);
    if(net.train) {
        fill_cpu(l.outputs * l.batch * l.steps, 0, l.delta, 1);
        copy_cpu(l.outputs*l.batch, l.state, 1, l.prev_state, 1);
    }

    for (i = 0; i < l.steps; ++i) {
        s.input = l.state;
        forward_connected_layer(wz, s);
        forward_connected_layer(wr, s);

        s.input = net.input;
        forward_connected_layer(uz, s);
        forward_connected_layer(ur, s);
        forward_connected_layer(uh, s);


        copy_cpu(l.outputs*l.batch, uz.output, 1, l.z_cpu, 1);
        axpy_cpu(l.outputs*l.batch, 1, wz.output, 1, l.z_cpu, 1);

        copy_cpu(l.outputs*l.batch, ur.output, 1, l.r_cpu, 1);
        axpy_cpu(l.outputs*l.batch, 1, wr.output, 1, l.r_cpu, 1);

        activate_array(l.z_cpu, l.outputs*l.batch, LOGISTIC);
        activate_array(l.r_cpu, l.outputs*l.batch, LOGISTIC);

        copy_cpu(l.outputs*l.batch, l.state, 1, l.forgot_state, 1);
        mul_cpu(l.outputs*l.batch, l.r_cpu, 1, l.forgot_state, 1);

        s.input = l.forgot_state;
        forward_connected_layer(wh, s);

        copy_cpu(l.outputs*l.batch, uh.output, 1, l.h_cpu, 1);
        axpy_cpu(l.outputs*l.batch, 1, wh.output, 1, l.h_cpu, 1);

        if(l.tanh){
            activate_array(l.h_cpu, l.outputs*l.batch, TANH);
        } else {
            activate_array(l.h_cpu, l.outputs*l.batch, LOGISTIC);
        }

        weighted_sum_cpu(l.state, l.h_cpu, l.z_cpu, l.outputs*l.batch, l.output);

        copy_cpu(l.outputs*l.batch, l.output, 1, l.state, 1);

        net.input += l.inputs*l.batch;
        l.output += l.outputs*l.batch;
        increment_layer(&uz, 1);
        increment_layer(&ur, 1);
        increment_layer(&uh, 1);

        increment_layer(&wz, 1);
        increment_layer(&wr, 1);
        increment_layer(&wh, 1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2288, %rsp           # imm = 0x2288
leaq 0x2760(%rsp), %r14
leaq 0x22c0(%rsp), %r13
leaq 0x5b8(%rsp), %rbx
movl $0x110, %edx            # imm = 0x110
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32b0
movl 0xf8(%r14), %r15d
movl %r15d, 0xf8(%rbx)
movq 0x428(%r13), %rsi
leaq 0x1de8(%rsp), %rbp
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbp, %rdi
callq 0x32b0
movq 0x438(%r13), %rsi
leaq 0x1948(%rsp), %rbx
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
callq 0x32b0
movq 0x448(%r13), %rsi
leaq 0x14a8(%rsp), %r14
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
callq 0x32b0
movq 0x420(%r13), %rsi
leaq 0x1008(%rsp), %r12
movl $0x4a0, %edx            # imm = 0x4A0
movq %r12, %rdi
callq 0x32b0
movq 0x430(%r13), %rsi
leaq 0xb68(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x440(%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(%rbp), %rsi
pushq $0x1
popq %rbp
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%rbx), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r14), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r12), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0xb68(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
leaq 0x6c8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl %ebp, %edx
callq 0x1b449
testl %r15d, %r15d
je 0x2e83a
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
imull 0xc0(%r13), %edi
movq 0x260(%r13), %rsi
pushq $0x1
popq %rbx
xorps %xmm0, %xmm0
movl %ebx, %edx
callq 0x1b449
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1e0(%r13), %rsi
movq 0x1e8(%r13), %rcx
movl %ebx, %edx
movl %ebx, %r8d
callq 0x1b5a3
leaq 0x2760(%rsp), %rax
movq 0xd8(%rax), %rbx
xorl %eax, %eax
pushq $0x22
popq %r14
leaq 0x5b8(%rsp), %r15
pushq $0x1
popq %r12
cmpl 0xc0(%r13), %eax
jge 0x2ece7
movl %eax, 0x5b4(%rsp)
movq 0x1e0(%r13), %rax
movq %rax, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1008(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0xb68(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movq %rbx, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1de8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x1948(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x14a8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x2050(%rsp), %rsi
movq 0x300(%r13), %rcx
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b5a3
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1270(%rsp), %rsi
movq 0x300(%r13), %rcx
movss 0x1d672(%rip), %xmm0    # 0x4c008
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b3ed
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1bb0(%rsp), %rsi
movq 0x308(%r13), %rcx
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b5a3
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0xdd0(%rsp), %rsi
movq 0x308(%r13), %rcx
movss 0x1d624(%rip), %xmm0    # 0x4c008
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b3ed
movq 0x300(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
xorl %edx, %edx
callq 0x1a4f8
movq 0x308(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
xorl %edx, %edx
callq 0x1a4f8
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1e0(%r13), %rsi
movq 0x1f0(%r13), %rcx
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b5a3
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x308(%r13), %rsi
movq 0x1f0(%r13), %rcx
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b353
movq 0x1f0(%r13), %rax
movq %rax, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
leaq 0x6c8(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movq %r14, %rcx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x244cc
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x1710(%rsp), %rbp
movq 0x310(%r13), %rcx
movq %rbp, %rsi
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b5a3
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x930(%rsp), %rsi
movq 0x310(%r13), %rcx
movss 0x1d529(%rip), %xmm0    # 0x4c008
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b3ed
xorl %eax, %eax
cmpl $0x0, 0x120(%r13)
setne %al
movq 0x310(%r13), %rdi
movl 0x48(%r13), %esi
imull 0x58(%r13), %esi
leal (%rax,%rax,4), %edx
callq 0x1a4f8
movq 0x1e0(%r13), %rdi
movq 0x310(%r13), %rsi
movq 0x300(%r13), %rdx
movl 0x48(%r13), %ecx
imull 0x58(%r13), %ecx
movq 0x268(%r13), %r8
callq 0x1acf7
movl 0x48(%r13), %edi
imull 0x58(%r13), %edi
movq 0x268(%r13), %rsi
movq 0x1e0(%r13), %rcx
movl %r12d, %edx
movl %r12d, %r8d
callq 0x1b5a3
movslq 0x54(%r13), %rax
movslq 0x48(%r13), %rcx
movslq 0x58(%r13), %rdx
imulq %rcx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x268(%r13)
movslq 0x1e40(%rsp), %rdx
movslq 0x1e30(%rsp), %rsi
imulq %rdx, %rsi
shlq $0x2, %rsi
addq %rsi, 0x2050(%rsp)
addq %rsi, 0x2048(%rsp)
addq %rsi, 0x20a8(%rsp)
addq %rsi, 0x20b0(%rsp)
movslq 0x19a0(%rsp), %rdx
movslq 0x1990(%rsp), %rsi
imulq %rdx, %rsi
shlq $0x2, %rsi
addq %rsi, 0x1bb0(%rsp)
addq %rsi, 0x1ba8(%rsp)
addq %rsi, 0x1c08(%rsp)
addq %rsi, 0x1c10(%rsp)
movslq 0x1500(%rsp), %rdx
movslq 0x14f0(%rsp), %rsi
imulq %rdx, %rsi
leaq (,%rsi,4), %rdx
addq %rbp, %rdx
shlq $0x2, %rsi
movq %rdx, 0x1710(%rsp)
addq %rsi, 0x1708(%rsp)
addq %rsi, 0x1768(%rsp)
addq %rsi, 0x1770(%rsp)
movslq 0x1060(%rsp), %rdx
movslq 0x1050(%rsp), %rsi
imulq %rdx, %rsi
shlq $0x2, %rsi
addq %rsi, 0x1270(%rsp)
addq %rsi, 0x1268(%rsp)
addq %rsi, 0x12c8(%rsp)
addq %rsi, 0x12d0(%rsp)
movslq 0xbc0(%rsp), %rdx
movslq 0xbb0(%rsp), %rsi
imulq %rdx, %rsi
shlq $0x2, %rsi
addq %rsi, 0xdd0(%rsp)
addq %rsi, 0xdc8(%rsp)
addq %rsi, 0xe28(%rsp)
addq %rsi, 0xe30(%rsp)
movslq 0x720(%rsp), %rdx
movslq 0x710(%rsp), %rsi
imulq %rdx, %rsi
shlq $0x2, %rsi
addq %rsi, 0x930(%rsp)
imulq %rcx, %rax
addq %rsi, 0x928(%rsp)
leaq (%rbx,%rax,4), %rbx
movl 0x5b4(%rsp), %eax
addq %rsi, 0x988(%rsp)
addq %rsi, 0x990(%rsp)
incl %eax
jmp 0x2e85b
addq $0x2288, %rsp           # imm = 0x2288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq