// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/deconvolutional_layer.c
// Function: backward_deconvolutional_layer
void backward_deconvolutional_layer(layer l, network net)
{
    int i;

    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, l.out_w*l.out_h);
    }

    //if(net.delta) memset(net.delta, 0, l.batch*l.h*l.w*l.c*sizeof(float));

    for(i = 0; i < l.batch; ++i){
        int m = l.c;
        int n = l.size*l.size*l.n;
        int k = l.h*l.w;

        float *a = net.input + i*m*k;
        float *b = net.workspace;
        float *c = l.weight_updates;

        im2col_cpu(l.delta + i*l.outputs, l.out_c, l.out_h, l.out_w, 
                l.size, l.stride, l.pad, b);
        gemm_cpu(0,1,m,n,k,1,a,k,b,k,1,c,n);

        if(net.delta){
            int m = l.c;
            int n = l.h*l.w;
            int k = l.size*l.size*l.n;

            float *a = l.weights;
            float *b = net.workspace;
            float *c = net.delta + i*n*m;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x4f0(%rsp), %rbx
leaq 0x50(%rsp), %r14
movq 0x268(%r14), %rdi
movl 0x4(%r14), %edx
movl 0x48(%r14), %ebp
movl 0x58(%r14), %esi
imull %ebp, %esi
movq 0x260(%r14), %r15
movq %r15, %rcx
callq 0x28ee8
cmpl $0x0, 0x40(%r14)
je 0x10104
subq $0x5b0, %rsp            # imm = 0x5B0
movl $0x94, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x3c842
addq $0x5b0, %rsp            # imm = 0x5B0
movl 0x48(%r14), %ebp
jmp 0x10125
movq 0x238(%r14), %rdi
movl 0x78(%r14), %r8d
movl 0x84(%r14), %ecx
imull 0x7c(%r14), %r8d
movq %r15, %rsi
movl %ebp, %edx
callq 0x11402
testl %ebp, %ebp
leaq 0x4f0(%rsp), %rbp
jle 0x1027c
xorl %ebx, %ebx
movl 0x70(%r14), %r15d
movl 0x74(%r14), %eax
movl %eax, 0xc(%rsp)
movl 0x90(%r14), %r8d
movl %r8d, %r12d
imull %r12d, %r12d
imull 0x84(%r14), %r12d
imull 0x6c(%r14), %r15d
imull %ebx, %eax
imull %r15d, %eax
movslq %eax, %r13
shlq $0x2, %r13
addq 0xd8(%rbp), %r13
leaq 0x4f0(%rsp), %rax
movq 0xf0(%rax), %rbp
movq 0x258(%r14), %rax
movq %rax, 0x10(%rsp)
movslq 0x58(%r14), %rax
movslq %ebx, %rdi
imulq %rax, %rdi
shlq $0x2, %rdi
addq 0x260(%r14), %rdi
movl 0x80(%r14), %esi
movl 0x78(%r14), %edx
movl 0x7c(%r14), %ecx
movl 0x98(%r14), %r9d
movl 0xa8(%r14), %eax
pushq %rbp
pushq %rax
callq 0x28f73
addq $0x8, %rsp
xorl %edi, %edi
movl $0x1, %esi
movl 0x14(%rsp), %edx
movl %r12d, %ecx
movl %r15d, %r8d
movss 0x44e23(%rip), %xmm0    # 0x55008
movq %r13, %r9
movaps %xmm0, %xmm1
pushq %r12
pushq 0x20(%rsp)
pushq %r15
pushq %rbp
leaq 0x518(%rsp), %rbp
pushq %r15
callq 0xe40a
addq $0x30, %rsp
movq 0xe8(%rbp), %rax
testq %rax, %rax
je 0x10270
movl 0x70(%r14), %ecx
movl 0x74(%r14), %edx
imull 0x6c(%r14), %ecx
movl 0x90(%r14), %r8d
imull %r8d, %r8d
imull 0x84(%r14), %r8d
movq 0x250(%r14), %r9
movl %edx, %esi
imull %ebx, %esi
imull %ecx, %esi
movslq %esi, %rsi
leaq (%rax,%rsi,4), %rax
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
movss 0x44daf(%rip), %xmm0    # 0x55008
movaps %xmm0, %xmm1
pushq %rcx
pushq %rax
pushq %rcx
pushq 0xf0(%rbp)
pushq %r8
callq 0xe40a
addq $0x30, %rsp
incl %ebx
cmpl 0x48(%r14), %ebx
jl 0x10137
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq