// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/rnn_layer.c
// Function: make_rnn_layer
layer make_rnn_layer(int batch, int inputs, int outputs, int steps, ACTIVATION activation, int batch_normalize, int adam)
{
    fprintf(stderr, "RNN Layer: %d inputs, %d outputs\n", inputs, outputs);
    batch = batch / steps;
    layer l = {0};
    l.batch = batch;
    l.type = RNN;
    l.steps = steps;
    l.inputs = inputs;

    l.state = calloc(batch*outputs, sizeof(float));
    l.prev_state = calloc(batch*outputs, sizeof(float));

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

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

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

    l.outputs = outputs;
    l.output = l.output_layer->output;
    l.delta = l.output_layer->delta;

    l.forward = forward_rnn_layer;
    l.backward = backward_rnn_layer;
    l.update = update_rnn_layer;

    return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movl %r9d, 0x10(%rsp)
movl %r8d, %r15d
movl %ecx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movq 0x62a0a(%rip), %rax     # 0x69ff8
movq (%rax), %rdi
leaq 0x505da(%rip), %rsi     # 0x57bd2
movl %edx, %r12d
movl %edx, 0x14(%rsp)
xorl %eax, %eax
callq 0x3280
movl %r14d, %eax
cltd
idivl %r15d
movl %eax, %r13d
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31d0
movl %r13d, 0x48(%rbx)
movl $0xf, (%rbx)
movl %r15d, 0xc0(%rbx)
movl %r12d, 0x54(%rbx)
movl %r13d, %eax
imull %ebp, %eax
movslq %eax, %r14
pushq $0x4
popq %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x3260
movq %rax, 0x1e0(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x3260
movq %rax, 0x1e8(%rbx)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r14
movq %rax, 0x390(%rbx)
movq 0x62978(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x5056a(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
imull %r13d, %r15d
movl 0x4f8(%rsp), %eax
movl %eax, (%rsp)
leaq 0x18(%rsp), %rdi
movl %r15d, %esi
movl 0x14(%rsp), %edx
movl %ebp, %ecx
movl 0x10(%rsp), %r12d
movl %r12d, %r8d
movl 0x4f0(%rsp), %r9d
callq 0x4ab2
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x32c0
movl %r13d, 0x48(%r14)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r14
movq %rax, 0x398(%rbx)
movq 0x62901(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x504f3(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
movl 0x4f8(%rsp), %eax
movl %eax, (%rsp)
leaq 0x18(%rsp), %rdi
movl %r15d, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl %r12d, %r8d
movl 0x4f0(%rsp), %r9d
callq 0x4ab2
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x32c0
movl %r13d, 0x48(%r14)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r14
movq %rax, 0x3a0(%rbx)
movq 0x62895(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x50487(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
movl 0x4f8(%rsp), %eax
movl %eax, (%rsp)
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movl %r15d, %esi
movl %ebp, %edx
movl %ebp, %ecx
movl 0x10(%rsp), %r8d
movl 0x4f0(%rsp), %r9d
callq 0x4ab2
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
movq %r12, %rsi
callq 0x32c0
movl %r13d, 0x48(%r14)
movl %ebp, 0x58(%rbx)
movq 0x268(%r14), %rax
movq %rax, 0x268(%rbx)
movq 0x260(%r14), %rax
movq %rax, 0x260(%rbx)
leaq 0x310a7(%rip), %rax     # 0x38884
movq %rax, 0x10(%rbx)
leaq 0x31423(%rip), %rax     # 0x38c0b
movq %rax, 0x18(%rbx)
leaq 0x3188c(%rip), %rax     # 0x3907f
movq %rax, 0x20(%rbx)
movq %rbx, %rax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq