// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x23a53(%rip), %rsi     # 0x57445
movq %rax, %rdi
callq 0x34e40
movq %rax, %r12
movq %rax, %rdi
callq 0x3150
movq %rax, %r15
testq %r12, %r12
jne 0x33a19
leaq 0x23a12(%rip), %rdi     # 0x57426
callq 0xe956
movq %rbx, 0x20(%rsp)
leaq 0x60(%rsp), %rbx
movl $0x1, %ebp
testl %r15d, %r15d
jle 0x33a4a
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %eax, %eax
xorl %ecx, %ecx
cmpb $0x2c, (%r12,%rax)
sete %cl
addl %ecx, %ebp
incq %rax
cmpq %rax, %r15
jne 0x33a36
movslq %ebp, %r14
movl $0x4, %esi
movq %r14, %rdi
callq 0x3260
movq %rax, 0x10(%rsp)
movl $0x4, %esi
movq %r14, %rdi
callq 0x3260
movq %rax, 0x8(%rsp)
movl 0x14(%rbx), %eax
movl %eax, 0x4(%rsp)
movq %r13, 0x18(%rsp)
movq 0x20(%r13), %r15
cmpl $0x2, %r14d
movl $0x1, %ebx
cmovgel %ebp, %ebx
xorl %r13d, %r13d
movq %r12, %rdi
callq 0x3410
movl %eax, %r14d
movq %r12, %rdi
movl $0x2c, %esi
callq 0x3160
movq %rax, %r12
incq %r12
movl %r14d, %eax
sarl $0x1f, %eax
andl 0x4(%rsp), %eax
addl %r14d, %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r13,4)
cltq
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
movl 0x58(%r15,%rax), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
cmpq %r13, %rbx
jne 0x33a90
leaq 0x60(%rsp), %rax
movl (%rax), %esi
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
movq 0x10(%rsp), %r14
movq %r14, %rcx
movq 0x8(%rsp), %r8
callq 0x6c92
movq 0x18(%rsp), %rax
movq 0x20(%rax), %rax
movslq (%r14), %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)
cmpl $0x2, %ebp
jl 0x33b89
movl %ebp, %edi
movl $0x1, %r8d
movslq (%r14,%r8,4), %r9
imulq $0x4a0, %r9, %r9        # imm = 0x4A0
cmpl %edx, 0x7c(%rax,%r9)
jne 0x33b6d
leaq (%rax,%r9), %r10
cmpl %ecx, 0x78(%r10)
jne 0x33b6d
addl 0x80(%rax,%r9), %esi
movl %esi, 0x80(%rbx)
jmp 0x33b81
movl $0x0, 0x80(%rbx)
movq $0x0, 0x78(%rbx)
xorl %esi, %esi
incq %r8
cmpq %r8, %rdi
jne 0x33b41
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq