// File: /workspace/github_cpp_makefile_star2_O3/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 0x3edd
movq %rax, %rdx
movq (%rdx), %rdi
addl 0x12(%rdi), %esi
addq $0x8, %rdx
cmpq %rcx, %rdx
jne 0x3ece
movq (%rax), %rax
movl 0x16(%rax), %edx
movq %rbx, %rdi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0x1, %r8d
callq 0x5792
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rcx, %rsi
subq %rax, %rsi
je 0x3f8f
movl 0x16(%rbx), %edx
xorl %r13d, %r13d
xorl %r14d, %r14d
testl %edx, %edx
jle 0x3f72
xorl %ebp, %ebp
movq (%rax,%r13,8), %rdi
cmpl $0x0, 0x12(%rdi)
jle 0x3f63
xorl %r15d, %r15d
movl %r15d, %esi
movl %ebp, %edx
callq 0x4f24
movq %rax, %r12
leal (%r14,%r15), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x53ea
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 0x3f2a
movl 0x16(%rbx), %edx
incl %ebp
cmpl %edx, %ebp
jl 0x3f1d
movq 0x10(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq (%rax,%r13,8), %rsi
addl 0x12(%rsi), %r14d
incq %r13
movq %rcx, %rsi
subq %rax, %rsi
movq %rsi, %rdi
sarq $0x3, %rdi
cmpq %r13, %rdi
ja 0x3f17
cmpq $0x9, %rsi
jb 0x454e
movq (%rax), %rdx
movl 0x12(%rdx), %r14d
movl 0x16(%rbx), %edx
movl $0x1, %edi
testl %edx, %edx
jle 0x4530
movq %rdi, 0x30(%rsp)
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 0x53ea
movl (%rax), %edi
movl $0x3f000000, 0x8(%rsp)  # imm = 0x3F000000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3f000000, 0x4(%rsp)  # imm = 0x3F000000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3f200000, 0x8(%rsp)  # imm = 0x3F200000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3ec00000, 0x4(%rsp)  # imm = 0x3EC00000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x2c(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3ec00000, 0x8(%rsp)  # imm = 0x3EC00000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3f200000, 0x4(%rsp)  # imm = 0x3F200000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x28(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3f400000, 0x8(%rsp)  # imm = 0x3F400000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3e800000, 0x4(%rsp)  # imm = 0x3E800000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x24(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3e800000, 0x8(%rsp)  # imm = 0x3E800000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3f400000, 0x4(%rsp)  # imm = 0x3F400000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x20(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3f600000, 0x8(%rsp)  # imm = 0x3F600000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3e000000, 0x4(%rsp)  # imm = 0x3E000000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x1c(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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 0x53ea
movl (%rax), %edi
movl $0x3e000000, 0x8(%rsp)  # imm = 0x3E000000
leaq 0x8(%rsp), %rsi
callq 0x5364
movl %eax, %r13d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x53ea
movl (%rax), %edi
movl $0x3f600000, 0x4(%rsp)  # imm = 0x3F600000
leaq 0x4(%rsp), %rsi
callq 0x5364
movl %eax, %ebp
movq %rbx, %rdi
movl 0x18(%rsp), %esi
movl %r12d, %edx
callq 0x53ea
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
movl 0x16(%rbx), %edx
cmpl %edx, %r12d
jl 0x3ff4
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq 0x30(%rsp), %rdi
movq (%rax,%rdi,8), %rsi
addl 0x12(%rsi), %r14d
incq %rdi
movq %rcx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
cmpq %rdi, %rsi
ja 0x3fa8
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 0x593c
movq %r14, %rdi
callq 0x23a0