// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/lsd.c
// Function: test_lsd
void test_lsd(char *cfg, char *weights, char *filename, int gray)
{
    network *net = load_network(cfg, weights, 0);
    set_batch_network(net, 1);
    srand(2222222);

    clock_t time;
    char buff[256];
    char *input = buff;
    int i, imlayer = 0;

    for (i = 0; i < net->n; ++i) {
        if (net->layers[i].out_c == 3) {
            imlayer = i;
            printf("%d\n", i);
            break;
        }
    }

    while(1){
        if(filename){
            strncpy(input, filename, 256);
        }else{
            printf("Enter Image Path: ");
            fflush(stdout);
            input = fgets(input, 256, stdin);
            if(!input) return;
            strtok(input, "\n");
        }
        image im = load_image_color(input, 0, 0);
        image resized = resize_min(im, net->w);
        image crop = crop_image(resized, (resized.w - net->w)/2, (resized.h - net->h)/2, net->w, net->h);
        if(gray) grayscale_image_3c(crop);

        float *X = crop.data;
        time=clock();
        network_predict(net, X);
        image out = get_network_image_layer(net, imlayer);
        //yuv_to_rgb(out);
        constrain_image(out);
        printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
        save_image(out, "out");
        show_image(out, "out", 1);
        show_image(crop, "crop", 0);

        free_image(im);
        free_image(resized);
        free_image(crop);
        if (filename) break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movl %ecx, 0x24(%rsp)
movq %rdx, %r14
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x22658
movq %rax, %r15
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x22f00
movl $0x21e88e, %edi         # imm = 0x21E88E
callq 0x3220
movl (%r15), %eax
testl %eax, %eax
movl $0x0, %ecx
movq %rcx, 0x28(%rsp)
cmovlel %ebx, %eax
movl $0x80, %ecx
xorl %r13d, %r13d
cmpq %r13, %rax
je 0x375b9
movq 0x20(%r15), %rdx
cmpl $0x3, (%rdx,%rcx)
je 0x375a3
incq %r13
addq $0x4a0, %rcx            # imm = 0x4A0
jmp 0x37588
leaq 0x19ea7(%rip), %rdi     # 0x51451
movl %r13d, %esi
xorl %eax, %eax
callq 0x3160
movq %r13, 0x28(%rsp)
leaq 0x90(%rsp), %rbp
leaq 0x1ac0e(%rip), %r13     # 0x521d6
testq %r14, %r14
je 0x375df
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3080
jmp 0x3762e
leaq 0x19a5c(%rip), %rdi     # 0x51042
xorl %eax, %eax
callq 0x3160
movq 0x2c9dc(%rip), %rax     # 0x63fd0
movq (%rax), %rdi
callq 0x3310
movq 0x2c9d5(%rip), %rax     # 0x63fd8
movq (%rax), %rdx
movq %rbp, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x3230
testq %rax, %rax
je 0x377e5
movq %rax, %rbp
movq %rax, %rdi
leaq 0x19ef0(%rip), %rsi     # 0x51519
callq 0x33b0
leaq 0x78(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xbf36
movl 0x94(%r15), %esi
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x78(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x60(%rsp), %rdi
callq 0xe96d
movl 0x90(%r15), %r8d
movl 0x94(%r15), %ecx
movl 0x60(%rsp), %eax
movl 0x64(%rsp), %esi
subl %ecx, %eax
cltd
pushq $0x2
popq %rdi
idivl %edi
movl %eax, %r9d
subl %r8d, %esi
movl %esi, %eax
cltd
idivl %edi
movq 0x70(%rsp), %rdx
movq %rdx, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x30(%rsp), %rdi
movl %r9d, %esi
movl %eax, %edx
callq 0xdba7
cmpl $0x0, 0x24(%rsp)
je 0x376d0
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xf504
movq 0x40(%rsp), %rbx
callq 0x3120
movq %rax, %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x233e2
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
callq 0x232a7
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xd231
callq 0x3120
subq %r12, %rax
movq %rax, %rdi
callq 0x437c
cvtss2sd %xmm0, %xmm0
leaq 0x198ef(%rip), %rdi     # 0x5101c
movq %rbp, %rsi
movb $0x1, %al
callq 0x3160
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
callq 0xd514
movq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x48(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0xd4c7
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18dba(%rip), %rdi     # 0x50544
xorl %esi, %esi
callq 0xd4c7
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x78(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xba88
testq %r14, %r14
je 0x375c8
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq