// File: iibrahimli[P]adsa_project/src/../include/util.hpp
// Function: psf_resize(BMP_image, std::vector<float, std::allocator<float>>, unsigned int)
BMP_image psf_resize(const BMP_image img, std::vector<float> psf, unsigned int th){
    // max psf
    float max_psf = 0;
    for(auto& p : psf) if(p > max_psf) max_psf = p;

    unsigned int width = img.info_h.width;
    unsigned int height = img.info_h.height;
    int new_w = width * max_psf;
    
    BMP_image res(new_w, height);

    // resize each strip and write centered
    for(int i=0; i<psf.size(); ++i){
        x_enlarge_region(img, {0, i*th}, {width-1, std::min((i+1)*th, height)}, res, {(int) floor((new_w - floor(width*psf[i]))/2), i*th}, psf[i]);
    }

    return res;
}

// Assembly:
subq $0xe8, %rsp
movq %rdx, 0x30(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movq %rdi, %rax
movq %rax, 0x48(%rsp)
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movq %rdx, 0xd0(%rsp)
movl %ecx, 0xcc(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0xc8(%rsp)
movq %rdx, 0xc0(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x7fa0
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x7fd0
movq %rax, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x8000
testb $0x1, %al
jne 0x52a6
jmp 0x52f7
leaq 0xb8(%rsp), %rdi
callq 0x8040
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movss (%rax), %xmm0
ucomiss 0xc8(%rsp), %xmm0
jbe 0x52e6
movq 0xa8(%rsp), %rax
movss (%rax), %xmm0
movss %xmm0, 0xc8(%rsp)
jmp 0x52e8
leaq 0xb8(%rsp), %rdi
callq 0x8050
jmp 0x528b
movq 0x38(%rsp), %rax
movl 0x12(%rax), %ecx
movl %ecx, 0xa4(%rsp)
movl 0x16(%rax), %eax
movl %eax, 0xa0(%rsp)
movl 0xa4(%rsp), %eax
cvtsi2ss %rax, %xmm0
mulss 0xc8(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x9c(%rsp)
movb $0x0, 0x9b(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x2c(%rsp)
leaq 0x97(%rsp), %rdi
movl $0xff, %r8d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
callq 0x8070
movq 0x40(%rsp), %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movl 0x97(%rsp), %ecx
movl $0x1, %r8d
callq 0x80b0
movl $0x0, 0x90(%rsp)
movq 0x30(%rsp), %rdi
movslq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x7e60
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x5557
movl $0x0, 0x84(%rsp)
movl 0x90(%rsp), %eax
movl 0xcc(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x84(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x7c50
jmp 0x53fe
movl 0xa4(%rsp), %eax
decl %eax
movl %eax, 0x68(%rsp)
movl 0x90(%rsp), %eax
incl %eax
movl 0xcc(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x64(%rsp)
leaq 0x64(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x7c80
movq %rax, 0x18(%rsp)
jmp 0x543b
movq 0x18(%rsp), %rdx
leaq 0x6c(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7cc0
jmp 0x5451
movq 0x30(%rsp), %rdi
cvtsi2sdl 0x9c(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0xa4(%rsp), %eax
cvtsi2ss %rax, %xmm0
movss %xmm0, 0xc(%rsp)
movslq 0x90(%rsp), %rsi
callq 0x7ea0
movss 0xc(%rsp), %xmm0
movss (%rax), %xmm1
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x3420
movaps %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd 0x8b70(%rip), %xmm1     # 0xe020
mulsd %xmm1, %xmm0
callq 0x3420
cvttsd2si %xmm0, %eax
movl %eax, 0x58(%rsp)
movl 0x90(%rsp), %eax
movl 0xcc(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x54(%rsp)
leaq 0x5c(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x54(%rsp), %rdx
callq 0x7c50
jmp 0x54ec
movq 0x30(%rsp), %rdi
movslq 0x90(%rsp), %rsi
callq 0x7ea0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rcx
movss (%rax), %xmm0
movq 0x88(%rsp), %rsi
movq 0x6c(%rsp), %rdx
movq 0x5c(%rsp), %r8
callq 0x4ab0
jmp 0x5525
jmp 0x5527
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x5394
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
callq 0x8310
jmp 0x5580
movb $0x1, 0x9b(%rsp)
testb $0x1, 0x9b(%rsp)
jne 0x5573
movq 0x40(%rsp), %rdi
callq 0x8310
movq 0x48(%rsp), %rax
addq $0xe8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x3460
nopw (%rax,%rax)