// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
leaq 0x500(%rsp), %r15
leaq 0x60(%rsp), %rbx
movl 0x48(%rbx), %edi
imull 0x58(%rbx), %edi
movq 0x268(%rbx), %rsi
xorps %xmm0, %xmm0
movl $0x1, %edx
callq 0x2863b
cmpl $0x0, 0xbc(%rbx)
je 0x10093
movq 0x250(%rbx), %rdi
movl 0x74(%rbx), %eax
movl 0x84(%rbx), %esi
cltd
idivl 0x8c(%rbx)
movl 0x90(%rbx), %edx
imull %edx, %edx
imull %eax, %edx
movq 0x228(%rbx), %rcx
callq 0xfdc5
movq 0x250(%rbx), %rax
movq 0x228(%rbx), %rcx
movq %rcx, 0x250(%rbx)
movq %rax, 0x228(%rbx)
movl 0x6c(%rbx), %edx
imull 0x74(%rbx), %edx
imull 0x70(%rbx), %edx
imull 0x48(%rbx), %edx
movq 0x388(%rbx), %rax
testl %edx, %edx
jle 0x1008c
movq 0xd8(%r15), %rcx
movl %edx, %edx
xorl %esi, %esi
xorps %xmm0, %xmm0
leaq 0x43136(%rip), %rdi     # 0x531a0
movss (%rcx,%rsi,4), %xmm1
xorl %r8d, %r8d
ucomiss %xmm0, %xmm1
seta %r8b
movss (%rdi,%r8,4), %xmm1
movss %xmm1, (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x1006a
movq %rax, 0xd8(%r15)
movl 0x84(%rbx), %eax
movl 0x8c(%rbx), %ecx
cltd
idivl %ecx
movl %eax, %r12d
movl 0x90(%rbx), %eax
imull %eax, %eax
imull 0x74(%rbx), %eax
cltd
idivl %ecx
movq %rax, 0x20(%rsp)
movl 0x48(%rbx), %edx
testl %edx, %edx
jle 0x101fd
movl 0x78(%rbx), %eax
imull 0x7c(%rbx), %eax
movl %r12d, %ecx
movq %rax, 0x18(%rsp)
imull %eax, %ecx
movl %ecx, 0xc(%rsp)
movl $0x0, 0x4(%rsp)
movl %r12d, 0x8(%rsp)
movl 0x8c(%rbx), %edi
testl %edi, %edi
jle 0x101e8
xorl %ebp, %ebp
movl 0x5c(%rbx), %eax
imull %ebp, %eax
cltd
idivl %edi
movslq %eax, %r13
shlq $0x2, %r13
addq 0x250(%rbx), %r13
movl 0x4(%rsp), %eax
imull %edi, %eax
addl %ebp, %eax
movl 0xc(%rsp), %ecx
imull %eax, %ecx
movslq %ecx, %r14
shlq $0x2, %r14
addq 0x268(%rbx), %r14
movl 0x74(%rbx), %esi
imull %esi, %eax
cltd
idivl %edi
movl 0x6c(%rbx), %r11d
movl 0x70(%rbx), %ecx
movl %r11d, %edx
imull %ecx, %edx
imull %eax, %edx
movslq %edx, %r10
shlq $0x2, %r10
addq 0xd8(%r15), %r10
movl 0x90(%rbx), %r8d
cmpl $0x1, %r8d
je 0x101a4
movq %r15, %r12
movq 0xf0(%r15), %r15
movl %esi, %eax
cltd
idivl %edi
movl 0x98(%rbx), %r9d
movl 0xa8(%rbx), %edx
movq %rdx, 0x10(%rsp)
movq %r10, %rdi
movl %eax, %esi
movl %r11d, %edx
pushq %r15
pushq 0x18(%rsp)
callq 0x278bf
addq $0x10, %rsp
movq %r15, %r10
movq %r12, %r15
movl 0x8(%rsp), %r12d
subq $0x8, %rsp
xorl %edi, %edi
xorl %esi, %esi
movl %r12d, %edx
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
movss 0x42e47(%rip), %xmm0    # 0x53008
movq %r13, %r9
movaps %xmm0, %xmm1
pushq %rcx
pushq %r14
pushq %rcx
pushq %r10
pushq %r8
callq 0xdd4d
addq $0x30, %rsp
incl %ebp
movl 0x8c(%rbx), %edi
cmpl %edi, %ebp
jl 0x100f8
movl 0x4(%rsp), %eax
incl %eax
movl 0x48(%rbx), %edx
movl %eax, 0x4(%rsp)
cmpl %edx, %eax
jl 0x100e8
cmpl $0x0, 0x40(%rbx)
je 0x10239
subq $0x5b0, %rsp            # imm = 0x5B0
movl $0x94, %ecx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a0(%rsp), %rdi
movl $0x22, %ecx
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x3a360
addq $0x5b0, %rsp            # imm = 0x5B0
jmp 0x1025b
movq 0x268(%rbx), %rdi
movq 0x230(%rbx), %rsi
movl 0x7c(%rbx), %r8d
movl 0x84(%rbx), %ecx
imull 0x78(%rbx), %r8d
callq 0x10996
movq 0x268(%rbx), %rdi
movl 0x4(%rbx), %edx
movl 0x48(%rbx), %esi
imull 0x58(%rbx), %esi
callq 0x275e5
movl 0xbc(%rbx), %eax
orl 0xb8(%rbx), %eax
je 0x1029b
movq 0x228(%rbx), %rax
movq 0x250(%rbx), %rcx
movq %rax, 0x250(%rbx)
movq %rcx, 0x228(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq