// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/local_layer.c
// Function: backward_local_layer
void backward_local_layer(local_layer l, network net)
{
    int i, j;
    int locations = l.out_w*l.out_h;

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

    for(i = 0; i < l.batch; ++i){
        axpy_cpu(l.outputs, 1, l.delta + i*l.outputs, 1, l.bias_updates, 1);
    }

    for(i = 0; i < l.batch; ++i){
        float *input = net.input + i*l.w*l.h*l.c;
        im2col_cpu(input, l.c, l.h, l.w, 
                l.size, l.stride, l.pad, net.workspace);

        for(j = 0; j < locations; ++j){ 
            float *a = l.delta + i*l.outputs + j;
            float *b = net.workspace + j;
            float *c = l.weight_updates + j*l.size*l.size*l.c*l.n;
            int m = l.n;
            int n = l.size*l.size*l.c;
            int k = 1;

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

        if(net.delta){
            for(j = 0; j < locations; ++j){ 
                float *a = l.weights + j*l.size*l.size*l.c*l.n;
                float *b = l.delta + i*l.outputs + j;
                float *c = net.workspace + j;

                int m = l.size*l.size*l.c;
                int n = 1;
                int k = l.n;

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

            col2im_cpu(net.workspace, l.c,  l.h,  l.w,  l.size,  l.stride, l.pad, net.delta+i*l.c*l.h*l.w);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
leaq 0xc0(%rsp), %r13
movl 0x7c(%r13), %eax
movl %eax, 0x8(%rsp)
movl 0x78(%r13), %r15d
movq 0x268(%r13), %rdi
movslq 0x58(%r13), %r14
movl 0x4(%r13), %edx
movl 0x48(%r13), %ebx
movl %ebx, %esi
imull %r14d, %esi
movq 0x260(%r13), %r12
movq %r12, %rcx
callq 0x1a748
movq 0x238(%r13), %r13
xorl %eax, %eax
testl %ebx, %ebx
cmovgl %ebx, %eax
leaq (,%r14,4), %rcx
movq %rcx, 0x50(%rsp)
pushq $0x1
popq %rbp
movq %r12, 0x30(%rsp)
movq %rax, 0x60(%rsp)
movq %rax, %rbx
subq $0x1, %rbx
jb 0x2cd86
movl %r14d, %edi
movss 0x1f299(%rip), %xmm0    # 0x4c008
movq %r12, %rsi
movl %ebp, %edx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x1b3ed
addq 0x50(%rsp), %r12
jmp 0x2cd5e
imull 0x8(%rsp), %r15d
leaq 0x560(%rsp), %rdi
movq 0xd8(%rdi), %rax
movq %rax, 0x58(%rsp)
movq 0xe8(%rdi), %rax
movq %rax, 0x48(%rsp)
leaq 0xc0(%rsp), %rsi
movl 0x6c(%rsi), %eax
movl 0x70(%rsi), %ecx
movl %ecx, 0x20(%rsp)
movl %eax, 0x24(%rsp)
imull %eax, %ecx
movl 0x74(%rsi), %eax
imull %eax, %ecx
movl %ecx, 0x3c(%rsp)
movl 0x90(%rsi), %ecx
movl 0x98(%rsi), %edx
movl %edx, 0x14(%rsp)
movl 0xa8(%rsi), %edx
movq %rdx, 0x40(%rsp)
movq 0xf0(%rdi), %rdx
movq %rdx, 0x8(%rsp)
movl %ecx, 0x18(%rsp)
movl %ecx, %r14d
imull %r14d, %r14d
movq 0x258(%rsi), %rcx
movq %rcx, 0x80(%rsp)
movl 0x84(%rsi), %ecx
movl %eax, 0x1c(%rsp)
imull %eax, %r14d
movq 0x250(%rsi), %rax
movq %rax, 0x78(%rsp)
xorl %edx, %edx
testl %r15d, %r15d
movl $0x0, %ebx
cmovgl %r15d, %ebx
shlq $0x2, %rbx
movl %r14d, %eax
movl %ecx, 0x2c(%rsp)
imull %ecx, %eax
movl %eax, 0x28(%rsp)
pushq $0x1
popq %r12
cmpq 0x60(%rsp), %rdx
je 0x2cfba
movl 0x3c(%rsp), %eax
movq %rdx, 0x70(%rsp)
imull %edx, %eax
movslq %eax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x68(%rsp)
leaq (%rax,%rcx,4), %rdi
movl 0x1c(%rsp), %esi
movl 0x24(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0x18(%rsp), %r8d
movl 0x14(%rsp), %r9d
pushq 0x8(%rsp)
pushq 0x48(%rsp)
callq 0x1a7d7
popq %rax
popq %rcx
xorl %r13d, %r13d
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x2cf00
movq 0x30(%rsp), %rax
leaq (%rax,%rbp), %r9
movq 0x8(%rsp), %rax
addq %rbp, %rax
movslq %r13d, %r13
movq 0x80(%rsp), %rcx
leaq (%rcx,%r13,4), %r10
subq $0x8, %rsp
xorl %edi, %edi
movl %r12d, %esi
movl 0x34(%rsp), %edx
movl %r14d, %ecx
movl %r12d, %r8d
movss 0x1f128(%rip), %xmm0    # 0x4c008
movaps %xmm0, %xmm1
pushq %r14
pushq %r10
pushq %r15
pushq %rax
pushq %r15
callq 0x3954
addq $0x30, %rsp
addq $0x4, %rbp
addl 0x28(%rsp), %r13d
jmp 0x2cea0
cmpq $0x0, 0x48(%rsp)
je 0x2cfa3
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x2cf6e
movslq %ebp, %rbp
movq 0x78(%rsp), %rax
leaq (%rax,%rbp,4), %r9
movq 0x30(%rsp), %rax
addq %r13, %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%r13), %r10
subq $0x8, %rsp
xorps %xmm1, %xmm1
movl %r12d, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %r12d, %ecx
movl 0x34(%rsp), %r8d
movss 0x1f0b6(%rip), %xmm0    # 0x4c008
pushq %r15
pushq %r10
pushq %r15
pushq %rax
pushq %r14
callq 0x3954
addq $0x30, %rsp
addq $0x4, %r13
addl 0x28(%rsp), %ebp
jmp 0x2cf11
movq 0x48(%rsp), %rax
movq 0x68(%rsp), %rcx
leaq (%rax,%rcx,4), %rax
movq 0x8(%rsp), %rdi
movl 0x1c(%rsp), %esi
movl 0x24(%rsp), %edx
movl 0x20(%rsp), %ecx
movl 0x18(%rsp), %r8d
movl 0x14(%rsp), %r9d
pushq %rax
pushq 0x48(%rsp)
callq 0x1a969
popq %rax
popq %rcx
movq 0x70(%rsp), %rdx
incq %rdx
movq 0x50(%rsp), %rax
addq %rax, 0x30(%rsp)
jmp 0x2ce4e
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq