// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/darknet.c
// Function: average
void average(int argc, char *argv[])
{
    char *cfgfile = argv[2];
    char *outfile = argv[3];
    gpu_index = -1;
    network *net = parse_network_cfg(cfgfile);
    network *sum = parse_network_cfg(cfgfile);

    char *weightfile = argv[4];   
    load_weights(sum, weightfile);

    int i, j;
    int n = argc - 5;
    for(i = 0; i < n; ++i){
        weightfile = argv[i+5];   
        load_weights(net, weightfile);
        for(j = 0; j < net->n; ++j){
            layer l = net->layers[j];
            layer out = sum->layers[j];
            if(l.type == CONVOLUTIONAL){
                int num = l.n*l.c*l.size*l.size;
                axpy_cpu(l.n, 1, l.biases, 1, out.biases, 1);
                axpy_cpu(num, 1, l.weights, 1, out.weights, 1);
                if(l.batch_normalize){
                    axpy_cpu(l.n, 1, l.scales, 1, out.scales, 1);
                    axpy_cpu(l.n, 1, l.rolling_mean, 1, out.rolling_mean, 1);
                    axpy_cpu(l.n, 1, l.rolling_variance, 1, out.rolling_variance, 1);
                }
            }
            if(l.type == CONNECTED){
                axpy_cpu(l.outputs, 1, l.biases, 1, out.biases, 1);
                axpy_cpu(l.outputs*l.inputs, 1, l.weights, 1, out.weights, 1);
            }
        }
    }
    n = n+1;
    for(j = 0; j < net->n; ++j){
        layer l = sum->layers[j];
        if(l.type == CONVOLUTIONAL){
            int num = l.n*l.c*l.size*l.size;
            scal_cpu(l.n, 1./n, l.biases, 1);
            scal_cpu(num, 1./n, l.weights, 1);
                if(l.batch_normalize){
                    scal_cpu(l.n, 1./n, l.scales, 1);
                    scal_cpu(l.n, 1./n, l.rolling_mean, 1);
                    scal_cpu(l.n, 1./n, l.rolling_variance, 1);
                }
        }
        if(l.type == CONNECTED){
            scal_cpu(l.outputs, 1./n, l.biases, 1);
            scal_cpu(l.outputs*l.inputs, 1./n, l.weights, 1);
        }
    }
    save_weights(sum, outfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r13
movl %edi, %r12d
movq 0x10(%rsi), %rbx
movq 0x18(%rsi), %r14
leaq 0x19ff9(%rip), %rax     # 0x6c7b0
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x5145
movq %rax, %r15
movq %rbx, %rdi
callq 0x5145
movq %r13, 0x50(%rsp)
movq 0x20(%r13), %rsi
movq %rax, 0x28(%rsp)
movq %rax, %rdi
callq 0x6eeb
cmpl $0x5, %r12d
movq %r15, 0x30(%rsp)
movq %r14, 0x40(%rsp)
movq %r12, 0x38(%rsp)
jle 0x52a10
leal -0x5(%r12), %eax
movq %rax, 0x48(%rsp)
xorl %ebx, %ebx
movq 0x50(%rsp), %rax
movq 0x28(%rax,%rbx,8), %rsi
movq %r15, %rdi
callq 0x6eeb
movl (%r15), %eax
testl %eax, %eax
jle 0x52a00
movq %rbx, 0x58(%rsp)
movl $0x230, %r13d           # imm = 0x230
xorl %r12d, %r12d
movq 0x20(%r15), %rax
movl -0x230(%rax,%r13), %edi
movq (%rax,%r13), %rsi
movq 0x20(%rax,%r13), %rbx
movq 0x28(%rsp), %rcx
movq 0x20(%rcx), %rdx
movq (%rdx,%r13), %rcx
movq 0x20(%rdx,%r13), %rbp
cmpl $0x2, %edi
je 0x52998
testl %edi, %edi
jne 0x529e5
movl -0x1ac(%rax,%r13), %r14d
movq 0x10(%rax,%r13), %rdi
movq %rdi, 0x68(%rsp)
movq 0x80(%rax,%r13), %rdi
movq %rdi, 0x10(%rsp)
movq 0x88(%rax,%r13), %rdi
movq %rdi, 0x20(%rsp)
movq 0x10(%rdx,%r13), %rdi
movq %rdi, 0x60(%rsp)
movq 0x80(%rdx,%r13), %rdi
movq %rdi, 0x70(%rsp)
movq 0x88(%rdx,%r13), %rdx
movq %rdx, 0x18(%rsp)
movl -0x1a0(%rax,%r13), %edx
movl %edx, %r15d
imull %r14d, %r15d
imull %edx, %r15d
imull -0x1bc(%rax,%r13), %r15d
movl -0x1f0(%rax,%r13), %eax
movl %eax, 0xc(%rsp)
movl %r14d, %edi
movss 0x2717(%rip), %xmm0     # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl %r15d, %edi
movq 0x30(%rsp), %r15
movss 0x26f7(%rip), %xmm0     # 0x55008
movq %rbx, %rsi
movl $0x1, %edx
movq %rbp, %rcx
movl $0x1, %r8d
callq 0x29d31
cmpl $0x0, 0xc(%rsp)
je 0x529e5
movl %r14d, %edi
movss 0x26cb(%rip), %xmm0     # 0x55008
movq 0x68(%rsp), %rsi
movl $0x1, %edx
movq 0x60(%rsp), %rcx
movl $0x1, %r8d
callq 0x29d31
movl %r14d, %edi
movss 0x26a6(%rip), %xmm0     # 0x55008
movq 0x10(%rsp), %rsi
movl $0x1, %edx
movq 0x70(%rsp), %rcx
movl $0x1, %r8d
callq 0x29d31
movl %r14d, %edi
movss 0x2681(%rip), %xmm0     # 0x55008
movq 0x20(%rsp), %rsi
movl $0x1, %edx
movq 0x18(%rsp), %rcx
jmp 0x529da
movl -0x1d8(%rax,%r13), %edi
movl -0x1dc(%rax,%r13), %r14d
imull %edi, %r14d
movss 0x2654(%rip), %xmm0     # 0x55008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x29d31
movl %r14d, %edi
movss 0x2639(%rip), %xmm0     # 0x55008
movq %rbx, %rsi
movl $0x1, %edx
movq %rbp, %rcx
movl $0x1, %r8d
callq 0x29d31
incq %r12
movslq (%r15), %rax
addq $0x4a0, %r13            # imm = 0x4A0
cmpq %rax, %r12
jl 0x52836
movq 0x58(%rsp), %rbx
incq %rbx
cmpq 0x48(%rsp), %rbx
jne 0x5280b
jmp 0x52a13
movl (%r15), %eax
testl %eax, %eax
jle 0x52b7b
movq 0x38(%rsp), %rax
addl $-0x4, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x271e(%rip), %xmm1     # 0x55150
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rax
movl (%rax,%r15), %ecx
movq 0x230(%rax,%r15), %rsi
movq 0x250(%rax,%r15), %rbx
cmpl $0x2, %ecx
je 0x52b2e
testl %ecx, %ecx
jne 0x52b60
movl 0x84(%rax,%r15), %ebp
movq 0x240(%rax,%r15), %rcx
movq %rcx, 0x10(%rsp)
movq 0x2b0(%rax,%r15), %rcx
movq %rcx, 0x18(%rsp)
movq 0x2b8(%rax,%r15), %rcx
movq %rcx, 0x20(%rsp)
movl 0x90(%rax,%r15), %ecx
movl %ecx, %r13d
imull %ebp, %r13d
imull %ecx, %r13d
imull 0x74(%rax,%r15), %r13d
movl 0x40(%rax,%r15), %r12d
movl %ebp, %edi
movss 0xc(%rsp), %xmm0
movl $0x1, %edx
callq 0x29d61
movl %r13d, %edi
movss 0xc(%rsp), %xmm0
movq %rbx, %rsi
movl $0x1, %edx
callq 0x29d61
testl %r12d, %r12d
je 0x52b60
movl %ebp, %edi
movss 0xc(%rsp), %xmm0
movq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x29d61
movl %ebp, %edi
movss 0xc(%rsp), %xmm0
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x29d61
movl %ebp, %edi
movss 0xc(%rsp), %xmm0
movq 0x20(%rsp), %rsi
jmp 0x52b56
movl 0x58(%rax,%r15), %edi
movl 0x54(%rax,%r15), %ebp
imull %edi, %ebp
movss 0xc(%rsp), %xmm0
movl $0x1, %edx
callq 0x29d61
movl %ebp, %edi
movss 0xc(%rsp), %xmm0
movq %rbx, %rsi
movl $0x1, %edx
callq 0x29d61
incq %r14
movq 0x30(%rsp), %rax
movslq (%rax), %rax
addq $0x4a0, %r15            # imm = 0x4A0
cmpq %rax, %r14
jl 0x52a49
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6879