// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/crnn_layer.c
// Function: make_crnn_layer
layer make_crnn_layer(int batch, int h, int w, int c, int hidden_filters, int output_filters, int steps, ACTIVATION activation, int batch_normalize)
{
    fprintf(stderr, "CRNN Layer: %d x %d x %d image, %d filters\n", h,w,c,output_filters);
    batch = batch / steps;
    layer l = {0};
    l.batch = batch;
    l.type = CRNN;
    l.steps = steps;
    l.h = h;
    l.w = w;
    l.c = c;
    l.out_h = h;
    l.out_w = w;
    l.out_c = output_filters;
    l.inputs = h*w*c;
    l.hidden = h * w * hidden_filters;
    l.outputs = l.out_h * l.out_w * l.out_c;

    l.state = calloc(l.hidden*batch*(steps+1), sizeof(float));

    l.input_layer = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.input_layer) = make_convolutional_layer(batch*steps, h, w, c, hidden_filters, 1, 3, 1, 1,  activation, batch_normalize, 0, 0, 0);
    l.input_layer->batch = batch;

    l.self_layer = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.self_layer) = make_convolutional_layer(batch*steps, h, w, hidden_filters, hidden_filters, 1, 3, 1, 1,  activation, batch_normalize, 0, 0, 0);
    l.self_layer->batch = batch;

    l.output_layer = malloc(sizeof(layer));
    fprintf(stderr, "\t\t");
    *(l.output_layer) = make_convolutional_layer(batch*steps, h, w, hidden_filters, output_filters, 1, 3, 1, 1,  activation, batch_normalize, 0, 0, 0);
    l.output_layer->batch = batch;

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

    l.forward = forward_crnn_layer;
    l.backward = backward_crnn_layer;
    l.update = update_crnn_layer;


    return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movl %r9d, 0x4(%rsp)
movl %r8d, %r14d
movl %ecx, %r15d
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movl 0x4f8(%rsp), %r13d
movl 0x4f0(%rsp), %r9d
movq 0x6239b(%rip), %rax     # 0x69ff8
movq (%rax), %rdi
leaq 0x4ffb2(%rip), %rsi     # 0x57c19
xorl %eax, %eax
callq 0x3280
movl %ebp, %eax
cltd
idivl %r13d
movl %eax, %ebp
movl $0x4a0, %edx            # imm = 0x4A0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31d0
movl %ebp, 0x48(%rbx)
movl $0x12, (%rbx)
movl %r13d, 0xc0(%rbx)
movl %r12d, 0xc(%rsp)
movl %r12d, 0x6c(%rbx)
movl %r15d, 0x8(%rsp)
movl %r15d, 0x70(%rbx)
movl %r14d, 0x74(%rbx)
movl %r12d, 0x78(%rbx)
movl %r15d, 0x7c(%rbx)
movl 0x4f0(%rsp), %edx
movl %edx, 0x80(%rbx)
imull %r12d, %r15d
movl %r15d, %ecx
imull %r14d, %ecx
movl %ecx, 0x54(%rbx)
movl %r15d, %ecx
movl 0x4(%rsp), %r12d
imull %r12d, %ecx
movl %ecx, 0xc4(%rbx)
imull %edx, %r15d
movl %r15d, 0x58(%rbx)
leal 0x1(%r13), %eax
imull %ecx, %eax
imull %ebp, %eax
movslq %eax, %rdi
pushq $0x4
popq %rsi
callq 0x3260
movq %rax, 0x1e0(%rbx)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r15
movq %rax, 0x390(%rbx)
movq 0x622d9(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x4fecb(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
movq %r13, %rsi
imull %ebp, %esi
movq %rsi, 0x10(%rsp)
movl %ebp, %r13d
subq $0x8, %rsp
pushq $0x1
popq %r11
pushq $0x3
popq %r10
leaq 0x20(%rsp), %rdi
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ebp
movl %ebp, %ecx
movl %r14d, %r8d
movl %r12d, %r9d
pushq $0x0
pushq $0x0
pushq $0x0
movl 0x528(%rsp), %eax
pushq %rax
movl 0x528(%rsp), %eax
pushq %rax
pushq %r11
pushq %r11
pushq %r10
pushq %r11
callq 0x39e8
addq $0x50, %rsp
movl $0x4a0, %edx            # imm = 0x4A0
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x32c0
movl %r13d, 0x48(%r15)
movl %r13d, %r15d
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r14
movq %rax, 0x398(%rbx)
movq 0x6223a(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x4fe2c(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
subq $0x8, %rsp
leaq 0x20(%rsp), %rdi
movq 0x18(%rsp), %r13
movl %r13d, %esi
movl 0x14(%rsp), %r12d
movl %r12d, %edx
movl %ebp, %ecx
movl 0xc(%rsp), %ebp
movl %ebp, %r8d
movl %ebp, %r9d
pushq $0x0
pushq $0x0
pushq $0x0
movl 0x528(%rsp), %eax
pushq %rax
movl 0x528(%rsp), %eax
pushq %rax
pushq $0x1
popq %rax
pushq %rax
pushq %rax
pushq $0x3
popq %r10
pushq %r10
pushq %rax
callq 0x39e8
addq $0x50, %rsp
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x32c0
movl %r15d, 0x48(%r14)
movl $0x4a0, %edi            # imm = 0x4A0
callq 0x3310
movq %rax, %r14
movq %rax, 0x3a0(%rbx)
movq 0x621a4(%rip), %rax     # 0x69ff8
movq (%rax), %rcx
leaq 0x4fd96(%rip), %rdi     # 0x57bf4
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x3450
subq $0x8, %rsp
leaq 0x20(%rsp), %rdi
movl %r13d, %esi
movl %r12d, %edx
movl 0x10(%rsp), %ecx
movl %ebp, %r8d
movl 0x4f8(%rsp), %r9d
pushq $0x0
pushq $0x0
pushq $0x0
movl 0x528(%rsp), %eax
pushq %rax
movl 0x528(%rsp), %eax
pushq %rax
pushq $0x1
popq %rax
pushq %rax
pushq %rax
movq %rax, %r10
pushq $0x3
popq %rax
pushq %rax
pushq %r10
callq 0x39e8
addq $0x50, %rsp
movl $0x4a0, %edx            # imm = 0x4A0
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x32c0
movl %r15d, 0x48(%r14)
movq 0x268(%r14), %rax
movq %rax, 0x268(%rbx)
movq 0x260(%r14), %rax
movq %rax, 0x260(%rbx)
leaq 0x31b9b(%rip), %rax     # 0x39a88
movq %rax, 0x10(%rbx)
leaq 0x31f20(%rip), %rax     # 0x39e18
movq %rax, 0x18(%rbx)
leaq 0x3237c(%rip), %rax     # 0x3a27f
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