// File: /workspace/github_c_makefile_star2_O3/SimpleDoger[P]Darknet_CPU_Only/tree.c
// Function: read_tree
tree *read_tree(char *filename)
{
    tree t = {0};
    FILE *fp = fopen(filename, "r");

    char *line;
    int last_parent = -1;
    int group_size = 0;
    int groups = 0;
    int n = 0;
    while((line=fgetl(fp)) != 0){
        char *id = calloc(256, sizeof(char));
        int parent = -1;
        sscanf(line, "%s %d", id, &parent);
        t.parent = realloc(t.parent, (n+1)*sizeof(int));
        t.parent[n] = parent;

        t.child = realloc(t.child, (n+1)*sizeof(int));
        t.child[n] = -1;

        t.name = realloc(t.name, (n+1)*sizeof(char *));
        t.name[n] = id;
        if(parent != last_parent){
            ++groups;
            t.group_offset = realloc(t.group_offset, groups * sizeof(int));
            t.group_offset[groups - 1] = n - group_size;
            t.group_size = realloc(t.group_size, groups * sizeof(int));
            t.group_size[groups - 1] = group_size;
            group_size = 0;
            last_parent = parent;
        }
        t.group = realloc(t.group, (n+1)*sizeof(int));
        t.group[n] = groups;
        if (parent >= 0) {
            t.child[parent] = groups;
        }
        ++n;
        ++group_size;
    }
    ++groups;
    t.group_offset = realloc(t.group_offset, groups * sizeof(int));
    t.group_offset[groups - 1] = n - group_size;
    t.group_size = realloc(t.group_size, groups * sizeof(int));
    t.group_size[groups - 1] = group_size;
    t.n = n;
    t.groups = groups;
    t.leaf = calloc(n, sizeof(int));
    int i;
    for(i = 0; i < n; ++i) t.leaf[i] = 1;
    for(i = 0; i < n; ++i) if(t.parent[i] >= 0) t.leaf[t.parent[i]] = 0;

    fclose(fp);
    tree *tree_ptr = calloc(1, sizeof(tree));
    *tree_ptr = t;
    //error(0);
    return tree_ptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
leaq 0x1be38(%rip), %rsi     # 0x5ae29
callq 0x3390
movq %rax, 0x48(%rsp)
movq %rax, %rdi
callq 0xe948
testq %rax, %rax
je 0x3f1c2
movq %rax, %r14
movl $0x4, %ebp
movl $0x8, %ebx
xorl %r13d, %r13d
movl $0x0, 0xc(%rsp)
movl $0x0, 0x10(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq %rbx, 0x50(%rsp)
movl $0x100, %edi            # imm = 0x100
movl $0x1, %esi
callq 0x3250
movl %r15d, %r12d
movq %rax, %r15
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, 0x14(%rsp)
movq %r14, %rdi
leaq 0x1ae0a(%rip), %rsi     # 0x59e9f
movq %rax, %rdx
leaq 0x14(%rsp), %rcx
xorl %eax, %eax
callq 0x3320
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x3350
movl 0x14(%rsp), %r14d
movq %rax, 0x20(%rsp)
movl %r14d, (%rax,%r13,4)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x3350
movq %rax, 0x18(%rsp)
movl %ebx, (%rax,%r13,4)
movq 0x50(%rsp), %rbx
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x3350
movq %rax, 0x30(%rsp)
movq %r15, (%rax,%r13,8)
cmpl %r12d, %r14d
jne 0x3f104
movl %r12d, %r15d
movl 0xc(%rsp), %r12d
movl 0x10(%rsp), %r14d
jmp 0x3f159
movl 0xc(%rsp), %r12d
movslq %r12d, %r15
incl %r12d
leaq 0x4(,%r15,4), %r14
movq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x3350
movl %r13d, %edx
movl 0x10(%rsp), %ebx
subl %ebx, %edx
movq %rax, 0x40(%rsp)
movl %edx, (%rax,%r15,4)
movq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x3350
movq %rax, 0x38(%rsp)
movl %ebx, (%rax,%r15,4)
movq 0x50(%rsp), %rbx
xorl %r14d, %r14d
movl 0x14(%rsp), %r15d
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x3350
movq %rax, 0x28(%rsp)
movl %r12d, (%rax,%r13,4)
testl %r15d, %r15d
js 0x3f180
movl %r15d, %eax
movq 0x18(%rsp), %rcx
movl %r12d, (%rcx,%rax,4)
movl %r12d, 0xc(%rsp)
incl %r14d
movl %r14d, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0xe948
movq %rax, %r14
addq $0x4, %rbp
addq $0x8, %rbx
incq %r13
testq %rax, %rax
jne 0x3f068
movl 0xc(%rsp), %eax
movl 0x10(%rsp), %ebp
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %rdi
jmp 0x3f1f2
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
xorl %r12d, %r12d
xorl %edi, %edi
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
xorl %ebp, %ebp
xorl %eax, %eax
xorl %r13d, %r13d
movslq %eax, %r14
incl %eax
movl %eax, 0xc(%rsp)
leaq 0x4(,%r14,4), %rbx
movq %rbx, %rsi
callq 0x3350
movl %r13d, %ecx
subl %ebp, %ecx
movq %rax, %r15
movl %ecx, (%rax,%r14,4)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3350
movq %rax, %r12
movl %ebp, (%rax,%r14,4)
movl %r13d, %ebp
movl $0x4, %esi
movq %rbp, %rdi
callq 0x3250
movq %rax, %rbx
movq %r13, %r14
testl %r13d, %r13d
movq 0x20(%rsp), %r13
je 0x3f368
leaq -0x1(%rbp), %rax
movq %rax, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0xc(,%rbp,4), %rax
andq $-0x10, %rax
movdqa 0x15f01(%rip), %xmm1    # 0x55170
movdqa 0x15e09(%rip), %xmm2    # 0x55080
xorl %ecx, %ecx
movdqa 0x15e0f(%rip), %xmm3    # 0x55090
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x15eef(%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, %edx
notl %edx
testb $0x1, %dl
je 0x3f2cc
movl $0x1, (%rbx,%rcx)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3f2e2
movl $0x1, 0x4(%rbx,%rcx)
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, %edx
testb $0x1, %dl
je 0x3f321
movl $0x1, 0x8(%rbx,%rcx)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x3f333
movl $0x1, 0xc(%rbx,%rcx)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x3f291
testl %r14d, %r14d
je 0x3f368
xorl %eax, %eax
movslq (%r13,%rax,4), %rcx
testq %rcx, %rcx
js 0x3f360
movl $0x0, (%rbx,%rcx,4)
incq %rax
cmpq %rax, %rbp
jne 0x3f34f
movq 0x48(%rsp), %rdi
callq 0x3130
movl $0x1, %edi
movl $0x48, %esi
callq 0x3250
movq %rbx, (%rax)
movl %r14d, 0x8(%rax)
xorl %ecx, %ecx
movl %ecx, 0xc(%rax)
movq %r13, 0x10(%rax)
movq 0x18(%rsp), %rdx
movq %rdx, 0x18(%rax)
movq 0x28(%rsp), %rdx
movq %rdx, 0x20(%rax)
movq 0x30(%rsp), %rdx
movq %rdx, 0x28(%rax)
movl 0xc(%rsp), %edx
movl %edx, 0x30(%rax)
movl %ecx, 0x34(%rax)
movq %r12, 0x38(%rax)
movq %r15, 0x40(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)