// File: /workspace/github_cpp_makefile_star2_O1/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, 0x10(%rsp)
movq 0x8(%rsi), %rcx
xorl %esi, %esi
cmpq %rcx, %rax
je 0x3ed6
movq %rax, %rdx
movq (%rdx), %rdi
addl 0x12(%rdi), %esi
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x3ec7
movq (%rax), %rax
movl 0x16(%rax), %edx
movq %rbx, %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0x1, %r8d
callq 0x577a
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x3f84
xorl %r13d, %r13d
xorl %r14d, %r14d
cmpl $0x0, 0x16(%rbx)
jle 0x3f61
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rdi
cmpl $0x0, 0x12(%rdi)
jle 0x3f5a
xorl %r15d, %r15d
movl %r15d, %esi
movl %ebp, %edx
callq 0x4f20
movq %rax, %r12
leal (%r14,%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x53f2
movl (%r12), %ecx
movl %ecx, (%rax)
incl %r15d
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r13,8), %rdi
cmpl 0x12(%rdi), %r15d
jl 0x3f24
incl %ebp
cmpl 0x16(%rbx), %ebp
jl 0x3f0f
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq (%rax,%r13,8), %rdx
addl 0x12(%rdx), %r14d
incq %r13
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
ja 0x3f07
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
cmpq $0x9, %rcx
jb 0x454e
movq (%rax), %rax
movl 0x12(%rax), %r14d
movl $0x1, %eax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x16(%rbx)
jle 0x451d
leal -0x4(%r14), %eax
movl %eax, 0xc(%rsp)
leal 0x4(%r14), %r15d
leal -0x1(%r14), %eax
movl %eax, 0x2c(%rsp)
leal 0x1(%r14), %eax
movl %eax, 0x28(%rsp)
leal -0x2(%r14), %eax
movl %eax, 0x24(%rsp)
leal 0x2(%r14), %eax
movl %eax, 0x20(%rsp)
leal -0x3(%r14), %eax
movl %eax, 0x1c(%rsp)
leal 0x3(%r14), %eax
movl %eax, 0x18(%rsp)
xorl %r12d, %r12d
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f000000, 0x8(%rsp)  # imm = 0x3F000000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f000000, 0x4(%rsp)  # imm = 0x3F000000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x406b
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x4085
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x4097
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f200000, 0x8(%rsp)  # imm = 0x3F200000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3ec00000, 0x4(%rsp)  # imm = 0x3EC00000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x2c(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x4126
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x4140
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x4152
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3ec00000, 0x8(%rsp)  # imm = 0x3EC00000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f200000, 0x4(%rsp)  # imm = 0x3F200000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x28(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x41e1
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x41fb
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x420d
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f400000, 0x8(%rsp)  # imm = 0x3F400000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3e800000, 0x4(%rsp)  # imm = 0x3E800000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x24(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x429c
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x42b6
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x42c8
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3e800000, 0x8(%rsp)  # imm = 0x3E800000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f400000, 0x4(%rsp)  # imm = 0x3F400000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x20(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x4357
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x4371
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x4383
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f600000, 0x8(%rsp)  # imm = 0x3F600000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3e000000, 0x4(%rsp)  # imm = 0x3E000000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x4412
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x442c
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x443e
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
movq %rbx, %rdi
movl 0xc(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3e000000, 0x8(%rsp)  # imm = 0x3E000000
leaq 0x8(%rsp), %rsi
callq 0x536c
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53f2
movl (%rax), %edi
movl $0x3f600000, 0x4(%rsp)  # imm = 0x3F600000
leaq 0x4(%rsp), %rsi
callq 0x536c
movl %eax, %ebp
movq %rbx, %rdi
movl 0x18(%rsp), %esi
movl %r12d, %edx
callq 0x53f2
movl %r13d, %esi
shrl $0x10, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
shrl $0x10, %ecx
andl %edx, %ecx
addl %esi, %ecx
cmpl %edx, %ecx
jb 0x44cd
movl $0xff, %ecx
movl %r13d, %edi
shrl $0x8, %edi
andl %edx, %edi
movl %ebp, %esi
shrl $0x8, %esi
andl %edx, %esi
addl %edi, %esi
cmpl %edx, %esi
jb 0x44e7
movl $0xff, %esi
movl %r13d, %edi
andl %edx, %edi
andl %edx, %ebp
addl %edi, %ebp
cmpl %edx, %ebp
jb 0x44f9
movl $0xff, %ebp
shll $0x10, %ecx
andl $0xff000000, %r13d      # imm = 0xFF000000
orl %ecx, %r13d
shll $0x8, %esi
orl %ebp, %esi
orl %r13d, %esi
movl %esi, (%rax)
incl %r12d
cmpl 0x16(%rbx), %r12d
jl 0x3ff4
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq 0x30(%rsp), %rsi
movq (%rax,%rsi,8), %rdx
addl 0x12(%rdx), %r14d
incq %rsi
subq %rax, %rcx
sarq $0x3, %rcx
movq %rsi, 0x30(%rsp)
cmpq %rsi, %rcx
ja 0x3fab
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
jmp 0x4598
movq %rax, %r14
movq %rbx, %rdi
callq 0x5926
movq %r14, %rdi
callq 0x23a0