// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/network.c
// Function: resize_network
int resize_network(network *net, int w, int h)
{
    int i;
    //if(w == net->w && h == net->h) return 0;
    net->w = w;
    net->h = h;
    int inputs = 0;
    size_t workspace_size = 0;
    //fprintf(stderr, "Resizing to %d x %d...\n", w, h);
    //fflush(stderr);
    for (i = 0; i < net->n; ++i){
        layer l = net->layers[i];
        if(l.type == CONVOLUTIONAL){
            resize_convolutional_layer(&l, w, h);
        }else if(l.type == CROP){
            resize_crop_layer(&l, w, h);
        }else if(l.type == MAXPOOL){
            resize_maxpool_layer(&l, w, h);
        }else if(l.type == REGION){
            resize_region_layer(&l, w, h);
        }else if(l.type == YOLO){
            resize_yolo_layer(&l, w, h);
        }else if(l.type == ROUTE){
            resize_route_layer(&l, net);
        }else if(l.type == SHORTCUT){
            resize_shortcut_layer(&l, w, h);
        }else if(l.type == UPSAMPLE){
            resize_upsample_layer(&l, w, h);
        }else if(l.type == REORG){
            resize_reorg_layer(&l, w, h);
        }else if(l.type == AVGPOOL){
            resize_avgpool_layer(&l, w, h);
        }else if(l.type == NORMALIZATION){
            resize_normalization_layer(&l, w, h);
        }else if(l.type == COST){
            resize_cost_layer(&l, inputs);
        }else{
            error("Cannot resize this type of layer");
        }
        if(l.workspace_size > workspace_size) workspace_size = l.workspace_size;
        if(l.workspace_size > 2000000000) assert(0);
        inputs = l.outputs;
        net->layers[i] = l;
        w = l.out_w;
        h = l.out_h;
        if(l.type == AVGPOOL) break;
    }
    layer out = get_network_output_layer(net);
    net->inputs = net->layers[0].inputs;
    net->outputs = out.outputs;
    net->truths = out.outputs;
    if(net->layers[net->n-1].truths) net->truths = net->layers[net->n-1].truths;
    net->output = out.output;
    free(net->input);
    free(net->truth);
    net->input = calloc(net->inputs*net->batch, sizeof(float));
    net->truth = calloc(net->truths*net->batch, sizeof(float));
    free(net->workspace);
    net->workspace = calloc(1, workspace_size);
    //fprintf(stderr, " Done!\n");
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rdi, %r9
movl %esi, 0x94(%rdi)
movl %edx, 0x90(%rdi)
xorl %r12d, %r12d
cmpl $0x0, (%rdi)
jle 0x304c3
movl %esi, %r13d
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r14d, %r14d
movq %r9, (%rsp)
movl %edx, %ebp
movq 0x20(%r9), %rsi
addq %r15, %rsi
movl $0x4a0, %edx            # imm = 0x4A0
leaq 0x8(%rsp), %rdi
callq 0x32c0
movl 0x8(%rsp), %eax
cmpq $0x1a, %rax
ja 0x30446
leaq 0x267a7(%rip), %rcx     # 0x56b0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x1086a
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x3cb76
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x28f69
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x37910
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x36478
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x2945e
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x37b17
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x38660
jmp 0x30452
leaq 0x8(%rsp), %rdi
movq (%rsp), %rsi
callq 0x3621c
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0x31d52
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x3f62b
jmp 0x30452
leaq 0x8(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0x3baac
jmp 0x30452
leaq 0x2688b(%rip), %rdi     # 0x56cd8
callq 0xe956
movq 0x4a0(%rsp), %rax
cmpq $0x77359401, %rax       # imm = 0x77359401
jae 0x305e1
cmpq %r14, %rax
cmovaq %rax, %r14
movq %r14, %rbp
movl 0x60(%rsp), %r12d
movq (%rsp), %r14
movq 0x20(%r14), %rdi
addq %r15, %rdi
movl $0x4a0, %edx            # imm = 0x4A0
leaq 0x8(%rsp), %rsi
callq 0x32c0
cmpl $0xb, 0x8(%rsp)
je 0x304c8
movl 0x84(%rsp), %r13d
movl 0x80(%rsp), %edx
incq %rbx
movslq (%r14), %rax
addq $0x4a0, %r15            # imm = 0x4A0
cmpq %rax, %rbx
movq %r14, %r9
movq %rbp, %r14
jl 0x30338
jmp 0x304ce
xorl %r14d, %r14d
jmp 0x304ce
movq %r14, %r9
movq %rbp, %r14
movl (%r9), %ecx
movslq %ecx, %rax
movl %eax, %edx
sarl $0x1f, %edx
andl %eax, %edx
decl %edx
movq %rcx, %rsi
decq %rsi
testl %ecx, %ecx
jle 0x30503
movq 0x20(%r9), %rdi
movl %esi, %r8d
imulq $0x4a0, %r8, %r8        # imm = 0x4A0
decl %ecx
decq %rsi
cmpl $0x9, (%rdi,%r8)
je 0x304e3
jmp 0x30505
movl %edx, %ecx
movslq %ecx, %rcx
imulq $0x4a0, %rcx, %rcx      # imm = 0x4A0
movq 0x20(%r9), %rdx
movq 0xd8(%r9), %rdi
movl 0x58(%rdx,%rcx), %esi
movq 0x268(%rdx,%rcx), %rcx
movl 0x54(%rdx), %r8d
movl %r8d, 0x80(%r9)
movl %esi, 0x84(%r9)
movl %esi, 0x88(%r9)
imulq $0x4a0, %rax, %rax      # imm = 0x4A0
movl -0x438(%rdx,%rax), %eax
testl %eax, %eax
cmovel %esi, %eax
movl %eax, 0x88(%r9)
movq %rcx, 0x28(%r9)
movq %r9, %r15
callq 0x3040
movq 0xe0(%r15), %rdi
callq 0x3040
movslq 0x80(%r15), %rdi
movslq 0x4(%r15), %rbx
imulq %rbx, %rdi
movl $0x4, %esi
callq 0x3260
movq %rax, 0xd8(%r15)
movslq 0x88(%r15), %rdi
imulq %rbx, %rdi
movl $0x4, %esi
callq 0x3260
movq %rax, 0xe0(%r15)
movq 0xf0(%r15), %rdi
callq 0x3040
movl $0x1, %edi
movq %r14, %rsi
callq 0x3260
movq %rax, 0xf0(%r15)
xorl %eax, %eax
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x266bf(%rip), %rdi     # 0x56ca7
leaq 0x266ba(%rip), %rsi     # 0x56ca9
leaq 0x26703(%rip), %rcx     # 0x56cf9
movl $0x169, %edx            # imm = 0x169
callq 0x31c0