// File: /workspace/github_c_makefile_star2_O3/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), %r12
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(%r12), %rsi
leaq 0x1de8(%rsp), %rbx
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
callq 0x32b0
movq 0x438(%r12), %rsi
leaq 0x1948(%rsp), %rbp
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbp, %rdi
callq 0x32b0
movq 0x448(%r12), %rsi
leaq 0x14a8(%rsp), %r13
movl $0x4a0, %edx            # imm = 0x4A0
movq %r13, %rdi
callq 0x32b0
movq 0x420(%r12), %rsi
leaq 0x1008(%rsp), %r14
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
callq 0x32b0
movq 0x430(%r12), %rsi
leaq 0xb68(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movq 0x440(%r12), %rsi
leaq 0x6c8(%rsp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x32b0
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
movq 0x260(%rbx), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
movq 0x260(%rbp), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
movq 0x260(%r13), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
movq 0x260(%r14), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
leaq 0xb68(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
leaq 0x6c8(%rsp), %rax
movq 0x260(%rax), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
testl %r15d, %r15d
je 0x3b66c
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
imull 0xc0(%r12), %edi
movq 0x260(%r12), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x29d83
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x1e0(%r12), %rsi
movq 0x1e8(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
cmpl $0x0, 0xc0(%r12)
jle 0x3bb78
leaq 0x2760(%rsp), %rax
movq 0xd8(%rax), %r13
xorl %ebp, %ebp
leaq 0x5b8(%rsp), %r14
leaq 0x6c8(%rsp), %rbx
movq 0x1e0(%r12), %rax
movq %rax, 0x690(%rsp)
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
leaq 0xb68(%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 %r13, 0x690(%rsp)
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
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 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x2050(%rsp), %rsi
movq 0x300(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x1270(%rsp), %rsi
movq 0x300(%r12), %rcx
movss 0x1982f(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x1bb0(%rsp), %rsi
movq 0x308(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0xdd0(%rsp), %rsi
movq 0x308(%r12), %rcx
movss 0x197d1(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movq 0x300(%r12), %rdi
movl 0x48(%r12), %esi
imull 0x58(%r12), %esi
xorl %edx, %edx
callq 0x28c99
movq 0x308(%r12), %rdi
movl 0x48(%r12), %esi
imull 0x58(%r12), %esi
xorl %edx, %edx
callq 0x28c99
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x1e0(%r12), %rsi
movq 0x1f0(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x308(%r12), %rsi
movq 0x1f0(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29c9f
movq 0x1f0(%r12), %rax
movq %rax, 0x690(%rsp)
movl $0x94, %ecx
movq %rsp, %rdi
movq %rbx, %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(%r12), %edi
imull 0x58(%r12), %edi
movq 0x1710(%rsp), %r15
movq 0x310(%r12), %rcx
movq %r15, %rsi
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x930(%rsp), %rsi
movq 0x310(%r12), %rcx
movss 0x196b0(%rip), %xmm0    # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
xorl %eax, %eax
cmpl $0x0, 0x120(%r12)
setne %al
movq 0x310(%r12), %rdi
movl 0x48(%r12), %esi
imull 0x58(%r12), %esi
leal (%rax,%rax,4), %edx
callq 0x28c99
movq 0x1e0(%r12), %rdi
movq 0x310(%r12), %rsi
movq 0x300(%r12), %rdx
movl 0x48(%r12), %ecx
imull 0x58(%r12), %ecx
movq 0x268(%r12), %r8
callq 0x29516
movl 0x48(%r12), %edi
imull 0x58(%r12), %edi
movq 0x268(%r12), %rsi
movq 0x1e0(%r12), %rcx
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29fe0
movslq 0x54(%r12), %rax
movslq 0x48(%r12), %rcx
movslq 0x58(%r12), %rdx
imulq %rcx, %rdx
shlq $0x2, %rdx
addq %rdx, 0x268(%r12)
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 (%r15,%rsi,4), %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)
addq %rsi, 0x928(%rsp)
addq %rsi, 0x988(%rsp)
imulq %rcx, %rax
addq %rsi, 0x990(%rsp)
leaq (%r13,%rax,4), %r13
incl %ebp
cmpl 0xc0(%r12), %ebp
jl 0x3b69c
addq $0x2288, %rsp           # imm = 0x2288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq