// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/gru_layer.c
// Function: make_gru_layer
layer make_gru_layer(int batch, int inputs, int outputs, int steps, int batch_normalize, int adam)
{
    fprintf(stderr, "GRU Layer: %d inputs, %d outputs\n", inputs, outputs);
    batch = batch / steps;
    layer l = {0};
    l.batch = batch;
    l.type = GRU;
    l.steps = steps;
    l.inputs = inputs;

    l.uz = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.uz) = make_connected_layer(batch*steps, inputs, outputs, LINEAR, batch_normalize, adam);
    l.uz->batch = batch;

    l.wz = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.wz) = make_connected_layer(batch*steps, outputs, outputs, LINEAR, batch_normalize, adam);
    l.wz->batch = batch;

    l.ur = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.ur) = make_connected_layer(batch*steps, inputs, outputs, LINEAR, batch_normalize, adam);
    l.ur->batch = batch;

    l.wr = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.wr) = make_connected_layer(batch*steps, outputs, outputs, LINEAR, batch_normalize, adam);
    l.wr->batch = batch;



    l.uh = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.uh) = make_connected_layer(batch*steps, inputs, outputs, LINEAR, batch_normalize, adam);
    l.uh->batch = batch;

    l.wh = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.wh) = make_connected_layer(batch*steps, outputs, outputs, LINEAR, batch_normalize, adam);
    l.wh->batch = batch;

    l.batch_normalize = batch_normalize;


    l.outputs = outputs;
    l.output = calloc(outputs*batch*steps, sizeof(float));
    l.delta = calloc(outputs*batch*steps, sizeof(float));
    l.state = calloc(outputs*batch, sizeof(float));
    l.prev_state = calloc(outputs*batch, sizeof(float));
    l.forgot_state = calloc(outputs*batch, sizeof(float));
    l.forgot_delta = calloc(outputs*batch, sizeof(float));

    l.r_cpu = calloc(outputs*batch, sizeof(float));
    l.z_cpu = calloc(outputs*batch, sizeof(float));
    l.h_cpu = calloc(outputs*batch, sizeof(float));

    l.forward = forward_gru_layer;
    l.backward = backward_gru_layer;
    l.update = update_gru_layer;


    return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
movl %r9d, 0x1c(%rsp)
movl %r8d, %r15d
movl %esi, %ebp
movq %rdi, %rbx
movq 0x64526(%rip), %rax     # 0x6bff8
movq (%rax), %rdi
leaq 0x52203(%rip), %rsi     # 0x59cdf
movl %edx, %r13d
movl %ecx, %r12d
movl %ecx, 0x18(%rsp)
xorl %eax, %eax
callq 0x3270
movl %ebp, %eax
cltd
idivl %r15d
movl %eax, %r14d
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31c0
movl %r14d, 0x48(%rbx)
movl $0x10, (%rbx)
movl %r15d, 0xc0(%rbx)
movl %r15d, 0x24(%rsp)
movl %r13d, 0x54(%rbx)
movl %r13d, %ebp
movl %r13d, 0x20(%rsp)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r13
movq %rax, 0x428(%rbx)
movq 0x644b6(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x52190(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl %r14d, %esi
imull %r15d, %esi
movl %esi, 0x14(%rsp)
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %r15
pushq $0x3
popq %r8
movq %r15, %rdi
movl %ebp, %edx
movl %r12d, %ecx
movl 0x1c(%rsp), %r12d
movl %r12d, %r9d
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r13, %rdi
movq %r15, %rsi
callq 0x32b0
movl %r14d, 0x48(%r13)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r15
movq %rax, 0x420(%rbx)
movq 0x6443f(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x52119(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %rdi
movl 0x14(%rsp), %ebp
movl %ebp, %esi
movl 0x18(%rsp), %ecx
movl %ecx, %edx
pushq $0x3
popq %r8
movl %r12d, %r13d
movl %r12d, %r9d
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x32b0
movl %r14d, 0x48(%r15)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r15
movq %rax, 0x438(%rbx)
movq 0x643cf(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x520a9(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
movl 0x20(%rsp), %edx
movl 0x18(%rsp), %r12d
movl %r12d, %ecx
pushq $0x3
popq %r8
movl %r13d, %r9d
movl %r13d, %ebp
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x32b0
movl %r14d, 0x48(%r15)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r15
movq %rax, 0x430(%rbx)
movq 0x6435d(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x52037(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %rdi
movl 0x14(%rsp), %r13d
movl %r13d, %esi
movl %r12d, %edx
movl %r12d, %ecx
pushq $0x3
popq %r8
movl %ebp, %r9d
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x32b0
movl %r14d, %ebp
movl %r14d, 0x48(%r15)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r15
movq %rax, 0x448(%rbx)
movq 0x642eb(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x51fc5(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %rdi
movl %r13d, %esi
movl 0x20(%rsp), %edx
movl %r12d, %ecx
pushq $0x3
popq %r8
movl 0x1c(%rsp), %r14d
movl %r14d, %r9d
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x32b0
movl %ebp, 0x48(%r15)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3300
movq %rax, %r15
movq %rax, 0x440(%rbx)
movq 0x6427b(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x51f55(%rip), %rdi     # 0x59cdc
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
movl 0x500(%rsp), %eax
movl %eax, (%rsp)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movl 0x14(%rsp), %esi
movl %r12d, %edx
movl %r12d, %ecx
pushq $0x3
popq %r8
movl %r14d, %r9d
callq 0x4c3c
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
movq %r13, %rsi
callq 0x32b0
movl %ebp, 0x48(%r15)
movl %r14d, 0x40(%rbx)
movl %r12d, 0x58(%rbx)
imull %r12d, %ebp
movl 0x24(%rsp), %eax
imull %ebp, %eax
movslq %eax, %r15
pushq $0x4
popq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x268(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x260(%rbx)
movslq %ebp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x1e0(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x1e8(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x1f0(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x1f8(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x308(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x300(%rbx)
movq %r15, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, 0x310(%rbx)
leaq 0x33590(%rip), %rax     # 0x3b424
movq %rax, 0x10(%rbx)
leaq 0x33ceb(%rip), %rax     # 0x3bb8a
movq %rax, 0x18(%rbx)
leaq 0x33ce1(%rip), %rax     # 0x3bb8b
movq %rax, 0x20(%rbx)
movq %rbx, %rax
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq