// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x9a0, %rsp            # imm = 0x9A0
movq %rdi, -0x9a0(%rbp)
movq %rdi, -0x998(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x990(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3570a(%rip), %rsi     # 0x74d01
callq 0x42ad0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3110
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x3f61f
leaq 0x356c8(%rip), %rdi     # 0x74ce2
callq 0x4c50
movl $0x1, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x3f65c
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
jne 0x3f64f
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3f651
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3f62d
movslq -0x20(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x30(%rbp)
movslq -0x20(%rbp), %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, -0x38(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3f704
movq -0x18(%rbp), %rdi
callq 0x33d0
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
movl $0x2c, %esi
callq 0x3120
addq $0x1, %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x3c(%rbp)
jge 0x3f6c7
movq -0x990(%rbp), %rax
movl 0x14(%rax), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edx
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x4a0, %rcx, %rcx      # imm = 0x4A0
addq %rcx, %rax
movl 0x58(%rax), %edx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3f687
movq -0x9a0(%rbp), %rdi
movq -0x990(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %esi
movl -0x20(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x43f40
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x30(%rbp), %rax
movslq (%rax), %rax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x4e0(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movq -0x9a0(%rbp), %rax
movl -0x464(%rbp), %ecx
movl %ecx, 0x7c(%rax)
movl -0x468(%rbp), %ecx
movl %ecx, 0x78(%rax)
movl -0x460(%rbp), %ecx
movl %ecx, 0x80(%rax)
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x3f82d
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4e4(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x4e4(%rbp), %rax
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
addq %rax, %rsi
leaq -0x988(%rbp), %rdi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3280
movl -0x90c(%rbp), %eax
cmpl -0x464(%rbp), %eax
jne 0x3f7fe
movl -0x910(%rbp), %eax
cmpl -0x468(%rbp), %eax
jne 0x3f7fe
movq -0x9a0(%rbp), %rax
movl -0x908(%rbp), %ecx
addl 0x80(%rax), %ecx
movl %ecx, 0x80(%rax)
jmp 0x3f81d
movq -0x9a0(%rbp), %rax
movl $0x0, 0x80(%rax)
movl $0x0, 0x7c(%rax)
movl $0x0, 0x78(%rax)
jmp 0x3f81f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x3f780
movq -0x998(%rbp), %rax
addq $0x9a0, %rsp            # imm = 0x9A0
popq %rbp
retq
nopl (%rax)