// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x3190
movq -0x8(%rbp), %rdi
leaq 0x27383(%rip), %rsi     # 0x7656d
callq 0x3360
movq %rax, -0x58(%rbp)
movl $0xffffffff, -0x64(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x58(%rbp), %rdi
callq 0x4140
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x4f399
movl $0x100, %edi            # imm = 0x100
movl $0x1, %esi
callq 0x3220
movq %rax, -0x78(%rbp)
movl $0xffffffff, -0x7c(%rbp) # imm = 0xFFFFFFFF
movq -0x60(%rbp), %rdi
movq -0x78(%rbp), %rdx
leaq 0x2641c(%rip), %rsi     # 0x7566b
leaq -0x7c(%rbp), %rcx
movb $0x0, %al
callq 0x32f0
movq -0x40(%rbp), %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x40(%rbp)
movl -0x7c(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x3310
movq %rax, -0x28(%rbp)
movq -0x78(%rbp), %rdx
movq -0x28(%rbp), %rax
movslq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x7c(%rbp), %eax
cmpl -0x64(%rbp), %eax
je 0x4f346
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x10(%rbp)
movl -0x70(%rbp), %edx
subl -0x68(%rbp), %edx
movq -0x10(%rbp), %rax
movl -0x6c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x18(%rbp)
movl -0x68(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x6c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x68(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x30(%rbp), %rdi
movl -0x70(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x30(%rbp)
movl -0x6c(%rbp), %edx
movq -0x30(%rbp), %rax
movslq -0x70(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x7c(%rbp)
jl 0x4f382
movl -0x6c(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x4f20f
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x10(%rbp)
movl -0x70(%rbp), %edx
subl -0x68(%rbp), %edx
movq -0x10(%rbp), %rax
movl -0x6c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
shlq $0x2, %rsi
callq 0x3310
movq %rax, -0x18(%rbp)
movl -0x68(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x6c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x70(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x20(%rbp)
movslq -0x70(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x50(%rbp)
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x70(%rbp), %eax
jge 0x4f43c
movq -0x50(%rbp), %rax
movslq -0x80(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x4f41a
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x70(%rbp), %eax
jge 0x4f47d
movq -0x40(%rbp), %rax
movslq -0x80(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x4f470
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq -0x80(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x4f472
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x4f443
movq -0x58(%rbp), %rdi
callq 0x3100
movl $0x1, %edi
movl $0x48, %esi
callq 0x3220
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movl $0x48, %edx
callq 0x3280
movq -0x88(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)