// File: /workspace/github_cpp_makefile_star2_O2/iibrahimli[P]adsa_project/src/../include/util.hpp
// Function: merge(std::vector<BMP_image const*, std::allocator<BMP_image const*>>)
BMP_image merge(std::vector<const BMP_image *> imgs){
    // calculate total width
    unsigned int res_width = 0;
    for(auto i : imgs) res_width += i->info_h.width;

    BMP_image res(res_width, imgs[0]->info_h.height);

    int c_width = 0;

    for(int n=0; n<imgs.size(); ++n){
        for(int j=0; j<res.info_h.height; ++j){
            for(int i=0; i<imgs[n]->info_h.width; ++i){
                res(c_width+i, j) = imgs[n]->ploc(i, j);
            }
        }
        c_width += imgs[n]->info_h.width;
    }

    // interpolate touching regions to smooth out stitches
    c_width = imgs[0]->info_h.width;
    for(int n=1; n<imgs.size(); ++n){
        for(int j=0; j<res.info_h.height; ++j){
            res(c_width, j)   = res(c_width-4, j)*0.5       + res(c_width+4, j)*0.5;
            res(c_width-1, j) = res(c_width-4, j)*(5.0/8.0) + res(c_width+4, j)*(3.0/8.0);
            res(c_width+1, j) = res(c_width-4, j)*(3.0/8.0) + res(c_width+4, j)*(5.0/8.0);
            res(c_width-2, j) = res(c_width-4, j)*(6.0/8.0) + res(c_width+4, j)*(2.0/8.0);
            res(c_width+2, j) = res(c_width-4, j)*(2.0/8.0) + res(c_width+4, j)*(6.0/8.0);
            res(c_width-3, j) = res(c_width-4, j)*(7.0/8.0) + res(c_width+4, j)*(1.0/8.0);
            res(c_width+3, j) = res(c_width-4, j)*(1.0/8.0) + res(c_width+4, j)*(7.0/8.0);
            // res(c_width-4, j) = res(c_width-6, j)*(10.0/12.0) + res(c_width+6, j)*(2.0 /12.0);
            // res(c_width+4, j) = res(c_width-6, j)*(2.0 /12.0) + res(c_width+6, j)*(10.0/12.0);
            // res(c_width-5, j) = res(c_width-6, j)*(11.0/12.0) + res(c_width+6, j)*(1.0 /12.0);
            // res(c_width+5, j) = res(c_width-6, j)*(1.0 /12.0) + res(c_width+6, j)*(11.0/12.0);
        }
        c_width += imgs[n]->info_h.width;
    }

    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, 0x18(%rsp)
movq 0x8(%rsi), %rcx
xorl %esi, %esi
movq %rax, %rdx
cmpq %rcx, %rdx
je 0x36fc
movq (%rdx), %rdi
addl 0x12(%rdi), %esi
addq $0x8, %rdx
jmp 0x36eb
movq (%rax), %rax
movl 0x16(%rax), %edx
pushq $-0x1
popq %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
callq 0x48b2
movq 0x18(%rsp), %rax
movq (%rax), %rax
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r13, %rdx
jbe 0x378a
xorl %ebp, %ebp
cmpl 0x16(%rbx), %ebp
jge 0x377d
xorl %r15d, %r15d
movq (%rax,%r13,8), %rdi
cmpl 0x12(%rdi), %r15d
jge 0x3779
movl %r15d, %esi
movl %ebp, %edx
callq 0x42be
movq %rax, %r12
leal (%r14,%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x4602
movl (%r12), %ecx
movl %ecx, (%rax)
incl %r15d
movq 0x18(%rsp), %rax
movq (%rax), %rax
jmp 0x3741
incl %ebp
jmp 0x3739
movq (%rax,%r13,8), %rcx
addl 0x12(%rcx), %r14d
incq %r13
jmp 0x371f
movq (%rax), %rdx
movl 0x12(%rdx), %edx
movq %rdx, 0x10(%rsp)
pushq $0x1
popq %r14
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x3afa
movq 0x10(%rsp), %rax
leal -0x4(%rax), %r15d
leal 0x4(%rax), %r12d
leal -0x1(%rax), %ecx
movl %ecx, 0x34(%rsp)
leal 0x1(%rax), %ecx
movl %ecx, 0x30(%rsp)
leal -0x2(%rax), %ecx
movl %ecx, 0x2c(%rsp)
leal 0x2(%rax), %ecx
movl %ecx, 0x28(%rsp)
leal -0x3(%rax), %ecx
movl %ecx, 0x24(%rsp)
addl $0x3, %eax
movl %eax, 0x20(%rsp)
xorl %r13d, %r13d
cmpl 0x16(%rbx), %r13d
jge 0x3ad5
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f000000, 0xc(%rsp)  # imm = 0x3F000000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f000000, 0x4(%rsp)  # imm = 0x3F000000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movq 0x10(%rsp), %rsi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f200000, 0xc(%rsp)  # imm = 0x3F200000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3ec00000, 0x4(%rsp)  # imm = 0x3EC00000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x34(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3ec00000, 0xc(%rsp)  # imm = 0x3EC00000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f200000, 0x4(%rsp)  # imm = 0x3F200000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x30(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f400000, 0xc(%rsp)  # imm = 0x3F400000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3e800000, 0x4(%rsp)  # imm = 0x3E800000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x2c(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3e800000, 0xc(%rsp)  # imm = 0x3E800000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f400000, 0x4(%rsp)  # imm = 0x3F400000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x28(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f600000, 0xc(%rsp)  # imm = 0x3F600000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3e000000, 0x4(%rsp)  # imm = 0x3E000000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x24(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
movq %rbx, %rdi
movl %r15d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3e000000, 0xc(%rsp)  # imm = 0x3E000000
leaq 0xc(%rsp), %rsi
callq 0x45e5
movl %eax, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x4602
movl (%rax), %edi
movl $0x3f600000, 0x4(%rsp)  # imm = 0x3F600000
leaq 0x4(%rsp), %rsi
callq 0x45e5
movl %eax, 0x8(%rsp)
movl %ebp, %edi
leaq 0x8(%rsp), %rsi
callq 0x45c9
movl %eax, %ebp
movq %rbx, %rdi
movl 0x20(%rsp), %esi
movl %r13d, %edx
callq 0x4602
movl %ebp, (%rax)
incl %r13d
jmp 0x37e3
movq 0x18(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq (%rax,%r14,8), %rdx
movq 0x10(%rsp), %rsi
addl 0x12(%rdx), %esi
movq %rsi, 0x10(%rsp)
incq %r14
jmp 0x3799
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
jmp 0x3b44
movq %rax, %r14
movq %rbx, %rdi
callq 0x4a1a
movq %r14, %rdi
callq 0x2380