// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/batchnorm_layer.c
// Function: make_batchnorm_layer
layer make_batchnorm_layer(int batch, int w, int h, int c)
{
    fprintf(stderr, "Batch Normalization Layer: %d x %d x %d image\n", w,h,c);
    layer l = {0};
    l.type = BATCHNORM;
    l.batch = batch;
    l.h = l.out_h = h;
    l.w = l.out_w = w;
    l.c = l.out_c = c;
    l.output = calloc(h * w * c * batch, sizeof(float));
    l.delta  = calloc(h * w * c * batch, sizeof(float));
    l.inputs = w*h*c;
    l.outputs = l.inputs;

    l.scales = calloc(c, sizeof(float));
    l.scale_updates = calloc(c, sizeof(float));
    l.biases = calloc(c, sizeof(float));
    l.bias_updates = calloc(c, sizeof(float));
    int i;
    for(i = 0; i < c; ++i){
        l.scales[i] = 1;
    }

    l.mean = calloc(c, sizeof(float));
    l.variance = calloc(c, sizeof(float));

    l.rolling_mean = calloc(c, sizeof(float));
    l.rolling_variance = calloc(c, sizeof(float));

    l.forward = forward_batchnorm_layer;
    l.backward = backward_batchnorm_layer;
    return l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x20(%rbp)
movq %rdi, -0x28(%rbp)
movl %esi, -0x4(%rbp)
movl %edx, -0x8(%rbp)
movl %ecx, -0xc(%rbp)
movl %r8d, -0x10(%rbp)
movq 0x37f14(%rip), %rax     # 0x82ff8
movq (%rax), %rdi
movl -0x8(%rbp), %edx
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
leaq 0x2a458(%rip), %rsi     # 0x75550
movb $0x0, %al
callq 0x3240
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3190
movq -0x20(%rbp), %rdi
movl $0x13, (%rdi)
movl -0x4(%rbp), %eax
movl %eax, 0x48(%rdi)
movl -0xc(%rbp), %eax
movl %eax, 0x78(%rdi)
movl %eax, 0x6c(%rdi)
movl -0x8(%rbp), %eax
movl %eax, 0x7c(%rdi)
movl %eax, 0x70(%rdi)
movl -0x10(%rbp), %eax
movl %eax, 0x80(%rdi)
movl %eax, 0x74(%rdi)
movl -0xc(%rbp), %eax
imull -0x8(%rbp), %eax
imull -0x10(%rbp), %eax
imull -0x4(%rbp), %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x268(%rdi)
movl -0xc(%rbp), %eax
imull -0x8(%rbp), %eax
imull -0x10(%rbp), %eax
imull -0x4(%rbp), %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x260(%rdi)
movl -0x8(%rbp), %eax
imull -0xc(%rbp), %eax
imull -0x10(%rbp), %eax
movl %eax, 0x54(%rdi)
movl 0x54(%rdi), %eax
movl %eax, 0x58(%rdi)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x240(%rdi)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x248(%rdi)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x230(%rdi)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rdi
movq %rax, 0x238(%rdi)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x4b239
movq -0x20(%rbp), %rax
movq 0x240(%rax), %rax
movslq -0x14(%rbp), %rcx
movss 0x25de3(%rip), %xmm0    # 0x7100c
movss %xmm0, (%rax,%rcx,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x4b20a
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x290(%rax)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x298(%rax)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x2b0(%rax)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq -0x20(%rbp), %rcx
movq %rax, %rdx
movq -0x28(%rbp), %rax
movq %rdx, 0x2b8(%rcx)
leaq 0x1c(%rip), %rdx        # 0x4b2d0
movq %rdx, 0x10(%rcx)
leaq 0x271(%rip), %rdx       # 0x4b530
movq %rdx, 0x18(%rcx)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)