// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/normalization_layer.c
// Function: forward_normalization_layer
void forward_normalization_layer(const layer layer, network net)
{
    int k,b;
    int w = layer.w;
    int h = layer.h;
    int c = layer.c;
    scal_cpu(w*h*c*layer.batch, 0, layer.squared, 1);

    for(b = 0; b < layer.batch; ++b){
        float *squared = layer.squared + w*h*c*b;
        float *norms   = layer.norms + w*h*c*b;
        float *input   = net.input + w*h*c*b;
        pow_cpu(w*h*c, 2, input, 1, squared, 1);

        const_cpu(w*h, layer.kappa, norms, 1);
        for(k = 0; k < layer.size/2; ++k){
            axpy_cpu(w*h, layer.alpha, squared + w*h*k, 1, norms, 1);
        }

        for(k = 1; k < layer.c; ++k){
            copy_cpu(w*h, norms + w*h*(k-1), 1, norms + w*h*k, 1);
            int prev = k - ((layer.size-1)/2) - 1;
            int next = k + (layer.size/2);
            if(prev >= 0)      axpy_cpu(w*h, -layer.alpha, squared + w*h*prev, 1, norms + w*h*k, 1);
            if(next < layer.c) axpy_cpu(w*h,  layer.alpha, squared + w*h*next, 1, norms + w*h*k, 1);
        }
    }
    pow_cpu(w*h*c*layer.batch, -layer.beta, layer.norms, 1, layer.output, 1);
    mul_cpu(w*h*c*layer.batch, net.input, 1, layer.output, 1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
leaq 0x110(%rsp), %r14
movl 0x70(%r14), %ebp
movslq 0x74(%r14), %rax
imull 0x6c(%r14), %ebp
movl %ebp, %ebx
movq %rax, 0x10(%rsp)
imull %eax, %ebx
movslq 0x48(%r14), %r15
movl %r15d, %edi
imull %ebx, %edi
movq 0x278(%r14), %rsi
movl $0x1, 0x4(%rsp)
xorps %xmm0, %xmm0
movl %edi, 0x1c(%rsp)
movq %rsi, 0x28(%rsp)
movl $0x1, %edx
callq 0x29d61
movq 0x280(%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x688(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r15, 0x80(%rsp)
testq %r15, %r15
jle 0x399f3
movl 0x10(%rsp), %edx
leaq 0x110(%rsp), %rax
movss 0x13c(%rax), %xmm0
movss %xmm0, 0x24(%rsp)
movl 0x90(%rax), %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
movss 0x134(%rax), %xmm0
leal -0x1(%rcx), %eax
shrl $0x1f, %eax
movq %rcx, 0x70(%rsp)
addl %ecx, %eax
decl %eax
sarl %eax
subl %eax, 0x4(%rsp)
movl %eax, %edi
negl %edi
movaps 0x1b8be(%rip), %xmm1    # 0x55090
movaps %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm1
movaps %xmm1, 0xc0(%rsp)
movslq %ebp, %r8
movq %rsi, 0x68(%rsp)
movslq %esi, %rax
movslq %ebx, %rcx
movq %rcx, 0x58(%rsp)
leaq (,%rcx,4), %rcx
movq %rcx, 0x50(%rsp)
incq %rax
movq %rax, 0x60(%rsp)
imulq %r8, %rax
shlq $0x2, %r8
movq 0x28(%rsp), %r12
leaq (%r12,%rax,4), %rax
movq %rax, 0x40(%rsp)
imull %ebp, %edi
movl %edi, 0x20(%rsp)
decq %rdx
movq %rdx, 0x78(%rsp)
xorl %edx, %edx
movq 0x8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %r8, 0xa0(%rsp)
movq %rdx, 0x90(%rsp)
movq %rdx, %rax
movq 0x58(%rsp), %rdi
imulq %rdi, %rax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,4), %r9
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,4), %r14
movq 0x30(%rsp), %rcx
leaq (%rcx,%rax,4), %rsi
movss 0x1ba0f(%rip), %xmm0    # 0x5528c
movl $0x1, %edx
movq %r9, 0x98(%rsp)
movq %r9, %rcx
movq %r8, %r15
movl $0x1, %r8d
callq 0x29ccb
movl %ebp, %edi
movss 0x24(%rsp), %xmm0
movq %r14, %rsi
movl $0x1, %edx
callq 0x29b89
movq 0x68(%rsp), %rbx
movq %r12, 0x88(%rsp)
cmpl $0x2, 0x70(%rsp)
jl 0x398ec
movl %ebp, %edi
movaps 0xb0(%rsp), %xmm0
movq %r12, %rsi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x29d31
addq %r15, %r12
decq %rbx
jne 0x398c4
movq %r15, %r8
movq 0x78(%rsp), %r15
movl 0x20(%rsp), %ebx
movl 0x4(%rsp), %r13d
movq 0x38(%rsp), %rsi
movq 0x60(%rsp), %r12
movq 0x40(%rsp), %r14
cmpl $0x2, 0x10(%rsp)
jl 0x399c0
movq %r15, 0xa8(%rsp)
leaq (%rsi,%r8), %r15
movl %ebp, %edi
movl $0x1, %edx
movq %r15, %rcx
movl $0x1, %r8d
callq 0x29fe0
testl %r13d, %r13d
jle 0x39969
movslq %ebx, %rax
movq 0x98(%rsp), %rcx
leaq (%rcx,%rax,4), %rsi
movl %ebp, %edi
movaps 0xc0(%rsp), %xmm0
movl $0x1, %edx
movq %r15, %rcx
movl $0x1, %r8d
callq 0x29d31
movq %r15, 0x48(%rsp)
cmpq 0x10(%rsp), %r12
movq 0xa8(%rsp), %r15
jge 0x3999f
movl %ebp, %edi
movaps 0xb0(%rsp), %xmm0
movq %r14, %rsi
movl $0x1, %edx
movq 0x48(%rsp), %rcx
movl $0x1, %r8d
callq 0x29d31
movq 0xa0(%rsp), %r8
addq %r8, %r14
incq %r12
incl %r13d
addl %ebp, %ebx
decq %r15
movq 0x48(%rsp), %rsi
jne 0x39917
movq 0x90(%rsp), %rdx
incq %rdx
movq 0x50(%rsp), %rax
movq 0x88(%rsp), %r12
addq %rax, %r12
addq %rax, 0x40(%rsp)
addq %rax, 0x38(%rsp)
cmpq 0x80(%rsp), %rdx
jne 0x39846
leaq 0x110(%rsp), %rax
movss 0x138(%rax), %xmm0
xorps 0x1b686(%rip), %xmm0    # 0x55090
movq 0x268(%rax), %rbx
movl 0x1c(%rsp), %ebp
movl %ebp, %edi
movq 0x8(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x29ccb
movl %ebp, %edi
movq 0x30(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29c9f