// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/parser.c
// Function: parse_route
route_layer parse_route(list *options, size_params params, network *net)
{
    char *l = option_find(options, "layers");
    int len = strlen(l);
    if(!l) error("Route Layer must specify input layers");
    int n = 1;
    int i;
    for(i = 0; i < len; ++i){
        if (l[i] == ',') ++n;
    }

    int *layers = calloc(n, sizeof(int));
    int *sizes = calloc(n, sizeof(int));
    for(i = 0; i < n; ++i){
        int index = atoi(l);
        l = strchr(l, ',')+1;
        if(index < 0) index = params.index + index;
        layers[i] = index;
        sizes[i] = net->layers[index].outputs;
    }
    int batch = params.batch;

    route_layer layer = make_route_layer(batch, n, layers, sizes);

    convolutional_layer first = net->layers[layers[0]];
    layer.out_w = first.out_w;
    layer.out_h = first.out_h;
    layer.out_c = first.out_c;
    for(i = 1; i < n; ++i){
        int index = layers[i];
        convolutional_layer next = net->layers[index];
        if(next.out_w == first.out_w && next.out_h == first.out_h){
            layer.out_c += next.out_c;
        }else{
            layer.out_h = layer.out_w = layer.out_c = 0;
        }
    }

    return layer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, %rax
movq %rdi, 0x18(%rsp)
leaq 0x29c1b(%rip), %rsi     # 0x50495
movq %rax, %rdi
callq 0x2983b
movq %rax, %r13
movq %rax, %rdi
callq 0x3140
movq %rax, %r14
testq %r13, %r13
jne 0x268a1
leaq 0x29bda(%rip), %rdi     # 0x50476
callq 0x43df
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
pushq $0x1
popq %rbp
cmpq %rax, %r14
je 0x268c4
xorl %ecx, %ecx
cmpb $0x2c, (%r13,%rax)
sete %cl
addl %ecx, %ebp
incq %rax
jmp 0x268ad
movl %ebp, %r15d
pushq $0x4
popq %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, %r12
movq %r15, %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, 0x10(%rsp)
leaq 0x60(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x26957
movq %r13, %rdi
callq 0x3400
movl %eax, %ebx
movq %r13, %rdi
pushq $0x2c
popq %rsi
callq 0x3150
movq %rax, %r13
incq %r13
movl %ebx, %eax
sarl $0x1f, %eax
andl 0x4(%rsp), %eax
addl %ebx, %eax
movl %eax, (%r12,%r15,4)
cltq
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
movq 0x20(%rsp), %rcx
movl 0x58(%rcx,%rax), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
jmp 0x26908
leaq 0x60(%rsp), %rax
movl (%rax), %esi
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
movq %r12, %rcx
movq 0x10(%rsp), %r8
callq 0x2a884
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movslq (%r12), %rcx
imulq $0x4a0, %rcx, %rsi      # imm = 0x4A0
movl 0x78(%rax,%rsi), %ecx
movl 0x7c(%rax,%rsi), %edx
movl 0x80(%rax,%rsi), %esi
movl %edx, 0x7c(%rbx)
movl %ecx, 0x78(%rbx)
movl %esi, 0x80(%rbx)
pushq $0x1
popq %rdi
cmpq %r14, %rdi
jae 0x269eb
movslq (%r12,%rdi,4), %r8
imulq $0x4a0, %r8, %r8        # imm = 0x4A0
cmpl %edx, 0x7c(%rax,%r8)
jne 0x269d8
leaq (%rax,%r8), %r9
cmpl %ecx, 0x78(%r9)
jne 0x269d8
addl 0x80(%rax,%r8), %esi
movl %esi, 0x80(%rbx)
jmp 0x269e6
andl $0x0, 0x80(%rbx)
andq $0x0, 0x78(%rbx)
xorl %esi, %esi
incq %rdi
jmp 0x269a7
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq