// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rsi, %r15
movl %edi, %r14d
movq 0x10(%rsi), %rbx
movq 0x18(%rsi), %rax
movq %rax, 0x58(%rsp)
leaq 0x1a245(%rip), %rax     # 0x6a7c0
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x4ebd
movq %rax, %r12
movq %rbx, %rdi
callq 0x4ebd
movq %rax, %rbx
movq %r15, 0x68(%rsp)
movq 0x20(%r15), %rsi
movq %rax, %rdi
callq 0x6c4b
movq %r14, 0x40(%rsp)
cmpl $0x6, %r14d
movq %r12, 0x48(%rsp)
movq %rbx, 0x50(%rsp)
jl 0x5082d
movq 0x40(%rsp), %rax
addl $-0x5, %eax
movq %rax, 0x60(%rsp)
xorl %ecx, %ecx
movq 0x68(%rsp), %rax
movq %rcx, 0x70(%rsp)
movq 0x28(%rax,%rcx,8), %rsi
movq %r12, %rdi
callq 0x6c4b
movss 0x2a19(%rip), %xmm0     # 0x53008
cmpl $0x0, (%r12)
jle 0x5081a
movl $0x230, %r15d           # imm = 0x230
xorl %r14d, %r14d
movq 0x20(%r12), %rax
movl -0x230(%rax,%r15), %r13d
movl -0x1dc(%rax,%r15), %ebp
movl -0x1d8(%rax,%r15), %edi
movq (%rax,%r15), %rsi
movq 0x20(%rax,%r15), %rcx
movq %rcx, (%rsp)
movq 0x20(%rbx), %r8
movq (%r8,%r15), %rcx
movq 0x20(%r8,%r15), %rdx
movq %rdx, 0x10(%rsp)
cmpl $0x2, %r13d
je 0x507b9
testl %r13d, %r13d
jne 0x50803
movl %edi, 0xc(%rsp)
movl -0x1ac(%rax,%r15), %ebx
movq 0x10(%rax,%r15), %rdx
movq %rdx, 0x80(%rsp)
movq 0x80(%rax,%r15), %rdx
movq %rdx, 0x90(%rsp)
movq 0x88(%rax,%r15), %rdx
movq %rdx, 0x20(%rsp)
movq 0x10(%r8,%r15), %rdx
movq %rdx, 0x78(%rsp)
movq 0x80(%r8,%r15), %rdx
movq %rdx, 0x88(%rsp)
movq 0x88(%r8,%r15), %rdx
movq %rdx, 0x18(%rsp)
movl -0x1a0(%rax,%r15), %edx
movl %edx, %r12d
imull %ebx, %r12d
imull %edx, %r12d
imull -0x1bc(%rax,%r15), %r12d
movl -0x1f0(%rax,%r15), %eax
movl %eax, 0x28(%rsp)
movl %ebx, %edi
movq %rsi, 0x38(%rsp)
movl $0x1, %edx
movq %rcx, 0x30(%rsp)
movl $0x1, %r8d
callq 0x285e9
movl %r12d, %edi
movss 0x290a(%rip), %xmm0     # 0x53008
movq (%rsp), %rsi
movl $0x1, %edx
movq 0x10(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
cmpl $0x0, 0x28(%rsp)
je 0x50793
movl %ebx, %edi
movss 0x28e0(%rip), %xmm0     # 0x53008
movq 0x80(%rsp), %rsi
movl $0x1, %edx
movq 0x78(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
movl %ebx, %edi
movss 0x28b9(%rip), %xmm0     # 0x53008
movq 0x90(%rsp), %rsi
movl $0x1, %edx
movq 0x88(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
movl %ebx, %edi
movss 0x288f(%rip), %xmm0     # 0x53008
movq 0x20(%rsp), %rsi
movl $0x1, %edx
movq 0x18(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
cmpl $0x2, %r13d
movq 0x48(%rsp), %r12
movq 0x50(%rsp), %rbx
movss 0x285f(%rip), %xmm0     # 0x53008
movl 0xc(%rsp), %edi
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rcx
jne 0x50803
movl %edi, %r13d
movss 0x2844(%rip), %xmm0     # 0x53008
movl $0x1, %edx
movl $0x1, %r8d
callq 0x285e9
imull %r13d, %ebp
movl %ebp, %edi
movss 0x2826(%rip), %xmm0     # 0x53008
movq (%rsp), %rsi
movl $0x1, %edx
movq 0x10(%rsp), %rcx
movl $0x1, %r8d
callq 0x285e9
movss 0x2805(%rip), %xmm0     # 0x53008
incq %r14
movslq (%r12), %rax
addq $0x4a0, %r15            # imm = 0x4A0
cmpq %rax, %r14
jl 0x50603
movq 0x70(%rsp), %rcx
incq %rcx
cmpq 0x60(%rsp), %rcx
jne 0x505d0
cmpl $0x0, (%r12)
jle 0x509cd
movq 0x40(%rsp), %rax
addl $-0x4, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd 0x28d9(%rip), %xmm1     # 0x53128
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
xorl %r14d, %r14d
xorl %r15d, %r15d
movss %xmm0, (%rsp)
movq 0x20(%rbx), %rax
movl (%rax,%r14), %ebp
movl 0x54(%rax,%r14), %ebx
movl 0x58(%rax,%r14), %ecx
movq 0x230(%rax,%r14), %rsi
movq 0x250(%rax,%r14), %r13
cmpl $0x2, %ebp
je 0x50982
testl %ebp, %ebp
jne 0x509b1
movl %ecx, 0xc(%rsp)
movl 0x84(%rax,%r14), %r12d
movq 0x240(%rax,%r14), %rcx
movq %rcx, 0x18(%rsp)
movq 0x2b0(%rax,%r14), %rcx
movq %rcx, 0x20(%rsp)
movq 0x2b8(%rax,%r14), %rcx
movq %rcx, 0x28(%rsp)
movl 0x90(%rax,%r14), %ecx
movq %r13, 0x10(%rsp)
movl %ecx, %r13d
imull %r12d, %r13d
imull %ecx, %r13d
imull 0x74(%rax,%r14), %r13d
movl 0x40(%rax,%r14), %eax
movl %eax, 0x30(%rsp)
movl %r12d, %edi
movq %rsi, 0x38(%rsp)
movl $0x1, %edx
callq 0x28619
movl %r13d, %edi
movq 0x10(%rsp), %r13
movss (%rsp), %xmm0
movq %r13, %rsi
movl $0x1, %edx
callq 0x28619
cmpl $0x0, 0x30(%rsp)
je 0x5096a
movl %r12d, %edi
movss (%rsp), %xmm0
movq 0x18(%rsp), %rsi
movl $0x1, %edx
callq 0x28619
movl %r12d, %edi
movss (%rsp), %xmm0
movq 0x20(%rsp), %rsi
movl $0x1, %edx
callq 0x28619
movl %r12d, %edi
movss (%rsp), %xmm0
movq 0x28(%rsp), %rsi
movl $0x1, %edx
callq 0x28619
cmpl $0x2, %ebp
movq 0x48(%rsp), %r12
movss (%rsp), %xmm0
movl 0xc(%rsp), %ecx
movq 0x38(%rsp), %rsi
jne 0x509b1
movl %ecx, %ebp
movl %ecx, %edi
movss (%rsp), %xmm0
movl $0x1, %edx
callq 0x28619
imull %ebp, %ebx
movl %ebx, %edi
movss (%rsp), %xmm0
movq %r13, %rsi
movl $0x1, %edx
callq 0x28619
movss (%rsp), %xmm0
incq %r15
movslq (%r12), %rax
addq $0x4a0, %r14            # imm = 0x4A0
cmpq %rax, %r15
movq 0x50(%rsp), %rbx
jl 0x50865
movq %rbx, %rdi
movq 0x58(%rsp), %rsi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x66cd