// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/upsample_layer.c
// Function: make_upsample_layer
layer make_upsample_layer(int batch, int w, int h, int c, int stride)
{
    layer l = {0};
    l.type = UPSAMPLE;
    l.batch = batch;
    l.w = w;
    l.h = h;
    l.c = c;
    l.out_w = w*stride;
    l.out_h = h*stride;
    l.out_c = c;
    if(stride < 0){
        stride = -stride;
        l.reverse=1;
        l.out_w = w/stride;
        l.out_h = h/stride;
    }
    l.stride = stride;
    l.outputs = l.out_w*l.out_h*l.out_c;
    l.inputs = l.w*l.h*l.c;
    l.delta =  calloc(l.outputs*batch, sizeof(float));
    l.output = calloc(l.outputs*batch, sizeof(float));;

    l.forward = forward_upsample_layer;
    l.backward = backward_upsample_layer;
    if(l.reverse) fprintf(stderr, "downsample         %2dx  %4d x%4d x%4d   ->  %4d x%4d x%4d\n", stride, w, h, c, l.out_w, l.out_h, l.out_c);
    else fprintf(stderr, "upsample           %2dx  %4d x%4d x%4d   ->  %4d x%4d x%4d\n", stride, w, h, c, l.out_w, l.out_h, l.out_c);
    return l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x20(%rbp)
movq %rdi, %rax
movq %rax, -0x28(%rbp)
movl %esi, -0x4(%rbp)
movl %edx, -0x8(%rbp)
movl %ecx, -0xc(%rbp)
movl %r8d, -0x10(%rbp)
movl %r9d, -0x14(%rbp)
xorl %esi, %esi
movl $0x4a0, %edx            # imm = 0x4A0
callq 0x3190
movq -0x20(%rbp), %rdi
movl $0x1a, (%rdi)
movl -0x4(%rbp), %eax
movl %eax, 0x48(%rdi)
movl -0x8(%rbp), %eax
movl %eax, 0x70(%rdi)
movl -0xc(%rbp), %eax
movl %eax, 0x6c(%rdi)
movl -0x10(%rbp), %eax
movl %eax, 0x74(%rdi)
movl -0x8(%rbp), %eax
imull -0x14(%rbp), %eax
movl %eax, 0x7c(%rdi)
movl -0xc(%rbp), %eax
imull -0x14(%rbp), %eax
movl %eax, 0x78(%rdi)
movl -0x10(%rbp), %eax
movl %eax, 0x80(%rdi)
cmpl $0x0, -0x14(%rbp)
jge 0x4459b
movq -0x20(%rbp), %rax
xorl %ecx, %ecx
subl -0x14(%rbp), %ecx
movl %ecx, -0x14(%rbp)
movl $0x1, 0x9c(%rax)
movl -0x8(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x7c(%rax)
movl -0xc(%rbp), %eax
cltd
idivl -0x14(%rbp)
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x78(%rax)
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, 0x98(%rax)
movl 0x7c(%rax), %ecx
imull 0x78(%rax), %ecx
imull 0x80(%rax), %ecx
movl %ecx, 0x58(%rax)
movl 0x70(%rax), %ecx
imull 0x6c(%rax), %ecx
imull 0x74(%rax), %ecx
movl %ecx, 0x54(%rax)
movl 0x58(%rax), %eax
imull -0x4(%rbp), %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x260(%rax)
movl 0x58(%rax), %eax
imull -0x4(%rbp), %eax
movslq %eax, %rdi
movl $0x4, %esi
callq 0x3220
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x268(%rax)
leaq 0xae(%rip), %rcx        # 0x446c0
movq %rcx, 0x10(%rax)
leaq 0x183(%rip), %rcx       # 0x447a0
movq %rcx, 0x18(%rax)
cmpl $0x0, 0x9c(%rax)
je 0x44671
movq -0x20(%rbp), %rax
movq 0x3e9c3(%rip), %rcx     # 0x82ff8
movq (%rcx), %rdi
movl -0x14(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movl 0x7c(%rax), %r11d
movl 0x78(%rax), %r10d
movl 0x80(%rax), %eax
leaq 0x30adc(%rip), %rsi     # 0x75137
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x3240
jmp 0x446b6
movq -0x20(%rbp), %rax
movq 0x3e97c(%rip), %rcx     # 0x82ff8
movq (%rcx), %rdi
movl -0x14(%rbp), %edx
movl -0x8(%rbp), %ecx
movl -0xc(%rbp), %r8d
movl -0x10(%rbp), %r9d
movl 0x7c(%rax), %r11d
movl 0x78(%rax), %r10d
movl 0x80(%rax), %eax
leaq 0x30ad1(%rip), %rsi     # 0x75173
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x3240
movq -0x28(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq