// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/region_layer.c
// Function: delta_region_class
void delta_region_class(float *output, float *delta, int index, int class, int classes, tree *hier, float scale, int stride, float *avg_cat, int tag)
{
    int i, n;
    if(hier){
        float pred = 1;
        while(class >= 0){
            pred *= output[index + stride*class];
            int g = hier->group[class];
            int offset = hier->group_offset[g];
            for(i = 0; i < hier->group_size[g]; ++i){
                delta[index + stride*(offset + i)] = scale * (0 - output[index + stride*(offset + i)]);
            }
            delta[index + stride*class] = scale * (1 - output[index + stride*class]);

            class = hier->parent[class];
        }
        *avg_cat += pred;
    } else {
        if (delta[index] && tag){
            delta[index + stride*class] = scale * (1 - output[index + stride*class]);
            return;
        }
        for(n = 0; n < classes; ++n){
            delta[index + stride*n] = scale * (((n == class)?1 : 0) - output[index + stride*n]);
            if(n == class) *avg_cat += output[index + stride*n];
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq %r9, -0x28(%rbp)
movss %xmm0, -0x2c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x4d99b
movss 0x237a0(%rip), %xmm0    # 0x7100c
movss %xmm0, -0x38(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x4d985
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x4d92d
movss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
movl -0x40(%rbp), %esi
addl -0x30(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movslq %ecx, %rcx
xorps %xmm1, %xmm1
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
movl -0x40(%rbp), %esi
addl -0x30(%rbp), %esi
imull %esi, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4d8c8
movss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss 0x236bf(%rip), %xmm1    # 0x7100c
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
jmp 0x4d871
movss -0x38(%rbp), %xmm0
movq 0x18(%rbp), %rax
addss (%rax), %xmm0
movss %xmm0, (%rax)
jmp 0x4daa0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4d9b4
jp 0x4d9b4
jmp 0x4da00
cmpl $0x0, 0x20(%rbp)
je 0x4da00
movss -0x2c(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss 0x23632(%rip), %xmm1    # 0x7100c
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x18(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x4daa0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x4da9e
movss -0x2c(%rbp), %xmm0
movl -0x34(%rbp), %edx
movl -0x18(%rbp), %esi
xorl %eax, %eax
movl $0x1, %ecx
cmpl %esi, %edx
cmovel %ecx, %eax
cvtsi2ss %eax, %xmm1
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x34(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
subss (%rax,%rcx,4), %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x34(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0x4da8e
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x10(%rbp), %edx
imull -0x34(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movss (%rax,%rcx,4), %xmm0
movq 0x18(%rbp), %rax
addss (%rax), %xmm0
movss %xmm0, (%rax)
jmp 0x4da90
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4da07
jmp 0x4daa0
popq %rbp
retq
nopw %cs:(%rax,%rax)