// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/convolutional_layer.c
// Function: backward_convolutional_layer
void backward_convolutional_layer(convolutional_layer l, network net)
{
    int i, j;
    int m = l.n/l.groups;
    int n = l.size*l.size*l.c/l.groups;
    int k = l.out_w*l.out_h;

    gradient_array(l.output, l.outputs*l.batch, l.activation, l.delta);

    if(l.batch_normalize){
        backward_batchnorm_layer(l, net);
    } else {
        backward_bias(l.bias_updates, l.delta, l.batch, l.n, k);
    }

    for(i = 0; i < l.batch; ++i){
        for(j = 0; j < l.groups; ++j){
            float *a = l.delta + (i*l.groups + j)*m*k;
            float *b = net.workspace;
            float *c = l.weight_updates + j*l.nweights/l.groups;

            float *im  = net.input + (i*l.groups + j)*l.c/l.groups*l.h*l.w;
            float *imd = net.delta + (i*l.groups + j)*l.c/l.groups*l.h*l.w;

            if(l.size == 1){
                b = im;
            } else {
                im2col_cpu(im, l.c/l.groups, l.h, l.w, 
                        l.size, l.stride, l.pad, b);
            }

            gemm(0,1,m,n,k,1,a,k,b,k,1,c,n);

            if (net.delta) {
                a = l.weights + j*l.nweights/l.groups;
                b = l.delta + (i*l.groups + j)*m*k;
                c = net.workspace;
                if (l.size == 1) {
                    c = imd;
                }

                gemm(1,0,n,k,m,1,a,n,b,k,0,c,k);

                if (l.size != 1) {
                    col2im_cpu(net.workspace, l.c/l.groups, l.h, l.w, l.size, l.stride, l.pad, imd);
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x610, %rsp            # imm = 0x610
leaq 0x4b0(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movl 0x84(%rcx), %eax
cltd
idivl 0x8c(%rcx)
movl %eax, -0x1c(%rbp)
movl 0x90(%rcx), %eax
imull 0x90(%rcx), %eax
imull 0x74(%rcx), %eax
cltd
idivl 0x8c(%rcx)
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, -0x20(%rbp)
movl 0x7c(%rax), %ecx
imull 0x78(%rax), %ecx
movl %ecx, -0x24(%rbp)
movq 0x268(%rax), %rdi
movl 0x58(%rax), %esi
imull 0x48(%rax), %esi
movl 0x4(%rax), %edx
movq 0x260(%rax), %rcx
callq 0x2e560
movq -0x58(%rbp), %rax
cmpl $0x0, 0x40(%rax)
je 0x7fb4
movq -0x58(%rbp), %rsi
movq %rsp, %rdi
movq %rdi, -0x68(%rbp)
movl $0x94, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
addq $0x4a0, %rdi            # imm = 0x4A0
movl $0x22, %ecx
rep  movsq (%rsi), %es:(%rdi)
callq 0x4b530
jmp 0x7fd8
movq -0x58(%rbp), %rax
movq 0x238(%rax), %rdi
movq 0x260(%rax), %rsi
movl 0x48(%rax), %edx
movl 0x84(%rax), %ecx
movl -0x24(%rbp), %r8d
callq 0x8980
movl $0x0, -0x14(%rbp)
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x48(%rcx), %eax
jge 0x82e7
movl $0x0, -0x18(%rbp)
movq -0x58(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x8c(%rcx), %eax
jge 0x82d7
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rax
movq 0x260(%rsi), %rcx
movl -0x14(%rbp), %edx
imull 0x8c(%rsi), %edx
addl -0x18(%rbp), %edx
imull -0x1c(%rbp), %edx
imull -0x24(%rbp), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, -0x30(%rbp)
movq 0xf0(%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x258(%rsi), %rcx
movl -0x18(%rbp), %eax
imull 0x5c(%rsi), %eax
cltd
idivl 0x8c(%rsi)
movl %eax, %edx
movq -0x60(%rbp), %rax
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, -0x40(%rbp)
movq 0xd8(%rax), %rcx
movl -0x14(%rbp), %eax
imull 0x8c(%rsi), %eax
addl -0x18(%rbp), %eax
imull 0x74(%rsi), %eax
cltd
idivl 0x8c(%rsi)
movl %eax, %edx
movq -0x60(%rbp), %rax
imull 0x6c(%rsi), %edx
imull 0x70(%rsi), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq 0xe8(%rax), %rcx
movl -0x14(%rbp), %eax
imull 0x8c(%rsi), %eax
addl -0x18(%rbp), %eax
imull 0x74(%rsi), %eax
cltd
idivl 0x8c(%rsi)
movl %eax, %edx
movq -0x58(%rbp), %rax
imull 0x6c(%rax), %edx
imull 0x70(%rax), %edx
movslq %edx, %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, -0x50(%rbp)
cmpl $0x1, 0x90(%rax)
jne 0x80f8
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x813d
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rdi
movl 0x74(%rcx), %eax
cltd
idivl 0x8c(%rcx)
movl %eax, %esi
movq -0x58(%rbp), %rax
movl 0x6c(%rax), %edx
movl 0x70(%rax), %ecx
movl 0x90(%rax), %r8d
movl 0x98(%rax), %r9d
movl 0xa8(%rax), %r10d
movq -0x38(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2e650
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
movq -0x30(%rbp), %r9
movl -0x24(%rbp), %r14d
movq -0x38(%rbp), %rbx
movl -0x24(%rbp), %r11d
movq -0x40(%rbp), %r10
movl -0x20(%rbp), %eax
xorl %edi, %edi
movl $0x1, %esi
movss 0x68e9f(%rip), %xmm1    # 0x7100c
movaps %xmm1, %xmm0
movl %r14d, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movl %eax, 0x20(%rsp)
callq 0x3aa0
movq -0x60(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
je 0x82c7
movq -0x58(%rbp), %rsi
movq -0x60(%rbp), %rcx
movq 0x250(%rsi), %rax
movq %rax, -0x70(%rbp)
movl -0x18(%rbp), %eax
imull 0x5c(%rsi), %eax
cltd
idivl 0x8c(%rsi)
movq -0x70(%rbp), %rdx
movl %eax, %esi
movq -0x58(%rbp), %rax
movslq %esi, %rsi
shlq $0x2, %rsi
addq %rsi, %rdx
movq %rdx, -0x30(%rbp)
movq 0x260(%rax), %rdx
movl -0x14(%rbp), %esi
imull 0x8c(%rax), %esi
addl -0x18(%rbp), %esi
imull -0x1c(%rbp), %esi
imull -0x24(%rbp), %esi
movslq %esi, %rsi
shlq $0x2, %rsi
addq %rsi, %rdx
movq %rdx, -0x38(%rbp)
movq 0xf0(%rcx), %rcx
movq %rcx, -0x40(%rbp)
cmpl $0x1, 0x90(%rax)
jne 0x821d
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x20(%rbp), %edx
movl -0x24(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movq -0x30(%rbp), %r9
movl -0x20(%rbp), %r14d
movq -0x38(%rbp), %rbx
movl -0x24(%rbp), %r11d
movq -0x40(%rbp), %r10
movl -0x24(%rbp), %eax
movl $0x1, %edi
xorl %esi, %esi
movss 0x68dbf(%rip), %xmm0    # 0x7100c
xorps %xmm1, %xmm1
movl %r14d, (%rsp)
movq %rbx, 0x8(%rsp)
movl %r11d, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movl %eax, 0x20(%rsp)
callq 0x3aa0
movq -0x58(%rbp), %rax
cmpl $0x1, 0x90(%rax)
je 0x82c5
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %rax
movq 0xf0(%rax), %rdi
movl 0x74(%rcx), %eax
cltd
idivl 0x8c(%rcx)
movl %eax, %esi
movq -0x58(%rbp), %rax
movl 0x6c(%rax), %edx
movl 0x70(%rax), %ecx
movl 0x90(%rax), %r8d
movl 0x98(%rax), %r9d
movl 0xa8(%rax), %r10d
movq -0x50(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2e840
jmp 0x82c7
jmp 0x82c9
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x7ff6
jmp 0x82d9
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7fdf
addq $0x610, %rsp            # imm = 0x610
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)