// File: /workspace/github_c_makefile_star2_O1/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), %rax
movl 0x70(%rax), %ebp
movslq 0x74(%rax), %rcx
imull 0x6c(%rax), %ebp
movl %ebp, %ebx
movq %rcx, 0x8(%rsp)
imull %ecx, %ebx
movslq 0x48(%rax), %r14
movl %r14d, %edi
imull %ebx, %edi
movq 0x278(%rax), %rsi
movl $0x1, 0x4(%rsp)
xorps %xmm0, %xmm0
movl %edi, 0x14(%rsp)
movq %rsi, 0x20(%rsp)
movl $0x1, %edx
callq 0x28619
movq %r14, 0x80(%rsp)
testq %r14, %r14
jle 0x37824
movl 0x8(%rsp), %edx
leaq 0x110(%rsp), %rcx
movq 0x280(%rcx), %rsi
leaq 0x5b0(%rsp), %rax
movq 0xd8(%rax), %rax
movq %rax, 0x68(%rsp)
movss 0x13c(%rcx), %xmm0
movss %xmm0, 0x1c(%rsp)
movl 0x90(%rcx), %edi
movl %edi, %r8d
shrl $0x1f, %r8d
addl %edi, %r8d
sarl %r8d
movss 0x134(%rcx), %xmm0
leal -0x1(%rdi), %eax
shrl $0x1f, %eax
movq %rdi, 0x60(%rsp)
addl %edi, %eax
decl %eax
sarl %eax
subl %eax, 0x4(%rsp)
movl %eax, %edi
negl %edi
movaps 0x1bb56(%rip), %xmm1    # 0x53150
movaps %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm1
movaps %xmm1, 0xc0(%rsp)
movslq %ebp, %r9
movq %r8, 0x58(%rsp)
movslq %r8d, %rax
movslq %ebx, %rcx
movq %rcx, 0x48(%rsp)
leaq (,%rcx,4), %rcx
movq %rcx, 0x40(%rsp)
incq %rax
movq %rax, 0x50(%rsp)
imulq %r9, %rax
shlq $0x2, %r9
movq 0x20(%rsp), %r13
leaq (,%rax,4), %rax
addq %r13, %rax
movq %rax, 0x30(%rsp)
imull %ebp, %edi
movl %edi, 0x18(%rsp)
decq %rdx
movq %rdx, 0x78(%rsp)
xorl %edx, %edx
movq %rsi, 0x70(%rsp)
movq %rsi, 0x28(%rsp)
movq %r9, 0xa0(%rsp)
movq %rdx, 0x90(%rsp)
movq %rdx, %rax
movq 0x48(%rsp), %rdi
imulq %rdi, %rax
movq 0x20(%rsp), %rcx
leaq (%rcx,%rax,4), %r8
movq 0x70(%rsp), %rcx
leaq (%rcx,%rax,4), %rbx
movq 0x68(%rsp), %rcx
leaq (%rcx,%rax,4), %rsi
movss 0x1bbb4(%rip), %xmm0    # 0x53260
movl $0x1, %edx
movq %r8, 0x98(%rsp)
movq %r8, %rcx
movl $0x1, %r8d
movq %r9, %r15
callq 0x28583
movl %ebp, %edi
movss 0x1c(%rsp), %xmm0
movq %rbx, %rsi
movl $0x1, %edx
callq 0x2853d
movq 0x58(%rsp), %r14
movq %r13, 0x88(%rsp)
cmpl $0x2, 0x60(%rsp)
jl 0x3771b
movl %ebp, %edi
movaps 0xb0(%rsp), %xmm0
movq %r13, %rsi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x285e9
addq %r15, %r13
decq %r14
jne 0x376f3
movq 0x78(%rsp), %r14
movl 0x18(%rsp), %r12d
movq %r15, %r9
movl 0x4(%rsp), %r15d
movq 0x28(%rsp), %rsi
movq 0x50(%rsp), %rbx
movq 0x30(%rsp), %r13
cmpl $0x2, 0x8(%rsp)
jl 0x377f1
movq %r14, 0xa8(%rsp)
leaq (%rsi,%r9), %r14
movl %ebp, %edi
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x2879c
testl %r15d, %r15d
jle 0x37799
movslq %r12d, %rax
movq 0x98(%rsp), %rcx
leaq (%rcx,%rax,4), %rsi
movl %ebp, %edi
movaps 0xc0(%rsp), %xmm0
movl $0x1, %edx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x285e9
movq %r14, 0x38(%rsp)
cmpq 0x8(%rsp), %rbx
movq 0xa8(%rsp), %r14
jge 0x377cf
movl %ebp, %edi
movaps 0xb0(%rsp), %xmm0
movq %r13, %rsi
movl $0x1, %edx
movq 0x38(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
movq 0xa0(%rsp), %r9
addq %r9, %r13
incq %rbx
incl %r15d
addl %ebp, %r12d
decq %r14
movq 0x38(%rsp), %rsi
jne 0x37747
movq 0x90(%rsp), %rdx
incq %rdx
movq 0x40(%rsp), %rax
movq 0x88(%rsp), %r13
addq %rax, %r13
addq %rax, 0x30(%rsp)
addq %rax, 0x28(%rsp)
cmpq 0x80(%rsp), %rdx
jne 0x37675
leaq 0x110(%rsp), %rax
movss 0x138(%rax), %xmm0
xorps 0x1b915(%rip), %xmm0    # 0x53150
movq 0x280(%rax), %rsi
movq 0x268(%rax), %rbx
movl 0x14(%rsp), %ebp
movl %ebp, %edi
movl $0x1, %edx
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x28583
leaq 0x5b0(%rsp), %rax
movq 0xd8(%rax), %rsi
movl %ebp, %edi
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 0x28557