// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/convolutional_layer.c
// Function: forward_convolutional_layer
void forward_convolutional_layer(convolutional_layer l, network net)
{
    int i, j;

    fill_cpu(l.outputs*l.batch, 0, l.output, 1);

    if(l.xnor){
        binarize_weights(l.weights, l.n, l.c/l.groups*l.size*l.size, l.binary_weights);
        swap_binary(&l);
        binarize_cpu(net.input, l.c*l.h*l.w*l.batch, l.binary_input);
        net.input = l.binary_input;
    }

    int m = l.n/l.groups;
    int k = l.size*l.size*l.c/l.groups;
    int n = l.out_w*l.out_h;
    for(i = 0; i < l.batch; ++i){
        for(j = 0; j < l.groups; ++j){
            float *a = l.weights + j*l.nweights/l.groups;
            float *b = net.workspace;
            float *c = l.output + (i*l.groups + j)*n*m;
            float *im =  net.input + (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,0,m,n,k,1,a,k,b,n,1,c,n);
        }
    }

    if(l.batch_normalize){
        forward_batchnorm_layer(l, net);
    } else {
        add_bias(l.output, l.biases, l.batch, l.n, l.out_h*l.out_w);
    }

    activate_array(l.output, l.outputs*l.batch, l.activation);
    if(l.binary || l.xnor) swap_binary(&l);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x530(%rsp), %rbx
leaq 0x90(%rsp), %r15
movl 0x48(%r15), %r13d
movl 0x58(%r15), %edi
imull %r13d, %edi
movq 0x268(%r15), %r12
pushq $0x1
popq %rdx
xorps %xmm0, %xmm0
movq %r12, %rsi
callq 0x1b449
cmpl $0x0, 0xbc(%r15)
movl %r13d, 0x14(%rsp)
movq %r12, 0x38(%rsp)
je 0x63f7
movq 0x250(%r15), %r12
movl 0x74(%r15), %ebp
movl 0x84(%r15), %esi
movl %esi, 0xc(%rsp)
movl 0x8c(%r15), %ecx
movl %ecx, 0x10(%rsp)
movl %ebp, %eax
cltd
idivl %ecx
movl 0x90(%r15), %r14d
movl %r14d, %edx
imull %r14d, %edx
imull %eax, %edx
movq 0x228(%r15), %r13
movq %r12, %rdi
movq %r13, %rcx
callq 0x5be1
movq %r13, 0x250(%r15)
movl 0x14(%rsp), %r13d
movq %r12, 0x228(%r15)
movq 0xd8(%rbx), %rdi
movl 0x6c(%r15), %esi
imull %ebp, %esi
imull 0x70(%r15), %esi
imull %r13d, %esi
movq 0x388(%r15), %r12
movq %r12, %rdx
callq 0x5c6e
movl 0x10(%rsp), %edi
movl 0xc(%rsp), %eax
movq %r12, 0xd8(%rbx)
movq 0x38(%rsp), %r12
jmp 0x6410
movl 0x74(%r15), %ebp
movl 0x84(%r15), %eax
movl 0x8c(%r15), %edi
movl 0x90(%r15), %r14d
movl %eax, 0xc(%rsp)
cltd
idivl %edi
movl %eax, %ecx
imull %r14d, %r14d
imull %ebp, %r14d
movl %r14d, %eax
cltd
idivl %edi
movq %rax, 0x50(%rsp)
movl 0x78(%r15), %eax
imull 0x7c(%r15), %eax
movl %ecx, 0x34(%rsp)
movq %rax, 0x40(%rsp)
imull %eax, %ecx
movl %ecx, 0x30(%rsp)
imull %edi, %ecx
movl %ecx, 0x24(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
movl %edi, 0x10(%rsp)
cmpl %r13d, %edx
jge 0x6583
movl %edx, 0x28(%rsp)
xorl %r13d, %r13d
movl %ecx, 0x2c(%rsp)
movl %ecx, %ebp
cmpl %edi, %r13d
jge 0x655f
movl 0x5c(%r15), %eax
imull %r13d, %eax
cltd
idivl %edi
movslq %eax, %r14
shlq $0x2, %r14
addq 0x250(%r15), %r14
movq 0x18(%rsp), %rax
addl %r13d, %eax
movl 0x74(%r15), %esi
imull %esi, %eax
cltd
idivl %edi
movl 0x6c(%r15), %r11d
movl 0x70(%r15), %ecx
movl %r11d, %edx
imull %ecx, %edx
imull %eax, %edx
movslq %edx, %r10
shlq $0x2, %r10
addq 0xd8(%rbx), %r10
movl 0x90(%r15), %r8d
cmpl $0x1, %r8d
je 0x6514
movq %rbx, %r12
movq 0xf0(%rbx), %rbx
movl %esi, %eax
cltd
idivl %edi
movl 0x98(%r15), %r9d
movl 0xa8(%r15), %edx
movq %rdx, 0x48(%rsp)
movq %r10, %rdi
movl %eax, %esi
movl %r11d, %edx
pushq %rbx
pushq 0x50(%rsp)
callq 0x1a7d7
popq %rax
popq %rcx
movq %rbx, %r10
movq %r12, %rbx
movq 0x38(%rsp), %r12
movslq %ebp, %rbp
leaq (%r12,%rbp,4), %rax
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
movl 0x3c(%rsp), %edx
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %r8
movss 0x45acf(%rip), %xmm0    # 0x4c008
movq %r14, %r9
movaps %xmm0, %xmm1
pushq %rcx
pushq %rax
pushq %rcx
pushq %r10
pushq %r8
callq 0x3954
addq $0x30, %rsp
incl %r13d
addl 0x30(%rsp), %ebp
movl 0x10(%rsp), %edi
jmp 0x6473
movl 0x28(%rsp), %edx
incl %edx
movl 0x2c(%rsp), %ecx
addl 0x24(%rsp), %ecx
movq 0x18(%rsp), %rax
addl %edi, %eax
movq %rax, 0x18(%rsp)
movl 0x14(%rsp), %r13d
jmp 0x645d
cmpl $0x0, 0x40(%r15)
je 0x65be
subq $0x5b0, %rsp            # imm = 0x5B0
movl $0x94, %ecx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
pushq $0x22
popq %rcx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x2fc4e
addq $0x5b0, %rsp            # imm = 0x5B0
jmp 0x65d9
movq 0x230(%r15), %rsi
movq %r12, %rdi
movl %r13d, %edx
movl 0xc(%rsp), %ecx
movq 0x40(%rsp), %r8
callq 0x6cd3
movq 0x268(%r15), %rdi
movl 0x48(%r15), %esi
imull 0x58(%r15), %esi
movl 0x4(%r15), %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a4f8