// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/region_layer.c
// Function: make_region_layer
layer make_region_layer(int batch, int w, int h, int n, int classes, int coords)
{
    layer l = {0};
    l.type = REGION;

    l.n = n;
    l.batch = batch;
    l.h = h;
    l.w = w;
    l.c = n*(classes + coords + 1);
    l.out_w = l.w;
    l.out_h = l.h;
    l.out_c = l.c;
    l.classes = classes;
    l.coords = coords;
    l.cost = calloc(1, sizeof(float));
    l.biases = calloc(n*2, sizeof(float));
    l.bias_updates = calloc(n*2, sizeof(float));
    l.outputs = h*w*n*(classes + coords + 1);
    l.inputs = l.outputs;
    l.truths = 30*(l.coords + 1);
    l.delta = calloc(batch*l.outputs, sizeof(float));
    l.output = calloc(batch*l.outputs, sizeof(float));
    int i;
    for(i = 0; i < n*2; ++i){
        l.biases[i] = .5;
    }

    l.forward = forward_region_layer;
    l.backward = backward_region_layer;

    fprintf(stderr, "detection\n");
    srand(0);

    return l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r14d
movl %r8d, %r15d
movl %ecx, %r13d
movl %edx, %ebp
movl %esi, %r12d
movl %esi, 0xc(%rsp)
movq %rdi, %rbx
movl $0x4a0, %edx            # imm = 0x4A0
xorl %esi, %esi
callq 0x31c0
movl $0x16, (%rbx)
movl %r15d, 0x84(%rbx)
movl %r12d, 0x48(%rbx)
movl %r13d, %eax
movl %r13d, 0x8(%rsp)
movl %r13d, 0x6c(%rbx)
movl %ebp, 0x70(%rbx)
movl 0x50(%rsp), %ecx
leal (%r14,%rcx), %r13d
incl %r13d
imull %r15d, %r13d
movq %r15, 0x10(%rsp)
movl %r13d, 0x74(%rbx)
movl %ebp, 0x7c(%rbx)
movl %eax, 0x78(%rbx)
movl %r13d, 0x80(%rbx)
movl %r14d, 0xfc(%rbx)
movl %ecx, 0x100(%rbx)
pushq $0x1
popq %rdi
pushq $0x4
popq %r14
movq %r14, %rsi
callq 0x3250
movq %rax, 0x1d8(%rbx)
addl %r15d, %r15d
movslq %r15d, %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x3250
movq %rax, %r14
movq %rax, 0x230(%rbx)
movq %r12, %rdi
pushq $0x4
popq %rsi
callq 0x3250
movq %rax, 0x238(%rbx)
imull 0x8(%rsp), %ebp
imull %r13d, %ebp
movl %ebp, 0x58(%rbx)
movl %ebp, 0x54(%rbx)
movl 0x50(%rsp), %eax
imull $0x1e, %eax, %eax
addl $0x1e, %eax
movl %eax, 0x68(%rbx)
imull 0xc(%rsp), %ebp
movslq %ebp, %r12
movq %r12, %rdi
pushq $0x4
popq %r13
movq %r13, %rsi
callq 0x3250
movq %rax, 0x260(%rbx)
movq %r12, %rdi
movq %r13, %rsi
callq 0x3250
movq %rax, 0x268(%rbx)
cmpl $0x0, 0x10(%rsp)
jle 0x866c
movl %r15d, %eax
addl $0x3, %r15d
andl $-0x4, %r15d
decq %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x4cbe1(%rip), %xmm1    # 0x55170
movdqa 0x4cae9(%rip), %xmm2    # 0x55080
xorl %eax, %eax
movdqa 0x4caef(%rip), %xmm3    # 0x55090
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x4cbcf(%rip), %xmm5    # 0x55180
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %ecx
notl %ecx
testb $0x1, %cl
je 0x85ed
movl $0x3f000000, (%r14,%rax,4) # imm = 0x3F000000
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %ecx
testb $0x1, %cl
je 0x8604
movl $0x3f000000, 0x4(%r14,%rax,4) # imm = 0x3F000000
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %ecx
testb $0x1, %cl
je 0x8644
movl $0x3f000000, 0x8(%r14,%rax,4) # imm = 0x3F000000
pextrw $0x4, %xmm6, %ecx
testb $0x1, %cl
je 0x8657
movl $0x3f000000, 0xc(%r14,%rax,4) # imm = 0x3F000000
addq $0x4, %rax
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
cmpq %rax, %r15
jne 0x85b1
leaq 0x34805(%rip), %rax     # 0x3ce78
movq %rax, 0x10(%rbx)
leaq 0x3567d(%rip), %rax     # 0x3dcfb
movq %rax, 0x18(%rbx)
movq 0x6396f(%rip), %rax     # 0x6bff8
movq (%rax), %rcx
leaq 0x51741(%rip), %rdi     # 0x59dd4
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
callq 0x3440
xorl %edi, %edi
callq 0x3220
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq