// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: append_unmatched_wins(overlap_region*, long)
void append_unmatched_wins(overlap_region *z, int64_t block_s)
{
    int64_t nw, aw = z->w_list.n, k, m, w_id, wn_id, w_s, w_e, idx_e;
    nw = get_num_wins(z->x_pos_s, z->x_pos_e+1, block_s);
    assert(nw >= aw && aw > 0);
    if(nw == aw) return;///done
    kv_resize(window_list, z->w_list, (uint64_t)nw); z->w_list.n = nw;
    for (k = aw-1, idx_e = nw; k >= 0; k--) {
        w_id = get_win_id_by_e(z, z->w_list.a[k].x_end, block_s, &w_s);
        assert(w_s == z->w_list.a[k].x_start && w_id < idx_e && k <= w_id);
        if(k != w_id) z->w_list.a[w_id] = z->w_list.a[k];
        for (m = w_id+1, w_e = z->w_list.a[k].x_end; m < idx_e; m++) {
            z->w_list.a[m].cidx = z->w_list.a[m].clen = 0;
            z->w_list.a[m].y_start = z->w_list.a[m].y_end = -1;
            z->w_list.a[m].error = z->w_list.a[m].error_threshold = -1;
            z->w_list.a[m].extra_begin = z->w_list.a[m].extra_end = 0;
            z->w_list.a[m].x_start = w_e + 1;
            wn_id = get_win_id_by_s(z, z->w_list.a[m].x_start, block_s, &w_e);
            z->w_list.a[m].x_end = w_e;
            assert(wn_id == m);
        }
        idx_e = w_id;
    }

    if(idx_e > 0) {
        for (m = 0, w_e = (int64_t)z->x_pos_s-1; m < idx_e; m++) {
            z->w_list.a[m].cidx = z->w_list.a[m].clen = 0;
            z->w_list.a[m].y_start = z->w_list.a[m].y_end = -1;
            z->w_list.a[m].error = z->w_list.a[m].error_threshold = -1;
            z->w_list.a[m].extra_begin = z->w_list.a[m].extra_end = 0;
            z->w_list.a[m].x_start = w_e + 1;
            wn_id = get_win_id_by_s(z, z->w_list.a[m].x_start, block_s, &w_e);
            z->w_list.a[m].x_end = w_e;
            assert(wn_id == m);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq 0x48(%rdi), %r12
movl 0x4(%rdi), %ecx
movl 0x8(%rdi), %esi
incl %esi
movq %rcx, %rax
xorl %edx, %edx
idivq %rbx
subq %rcx, %rdx
addq %rdx, %rsi
movq %rsi, %rax
cqto
idivq %rbx
movq %rax, %r15
xorl %eax, %eax
testq %rdx, %rdx
setg %cl
testq %r12, %r12
jle 0x4a33a
movb %cl, %al
addq %rax, %r15
cmpq %r12, %r15
jl 0x4a33a
je 0x4a2d3
movq %rdi, %r14
cmpq %r15, 0x50(%rdi)
jae 0x4a12e
leaq -0x1(%r15), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x50(%r14)
movq 0x58(%r14), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, 0x58(%r14)
movq %r15, 0x48(%r14)
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
leaq -0x1(%r12), %r9
movq 0x58(%r14), %r10
movq %r9, %rdi
shlq $0x5, %rdi
movslq 0x4(%r10,%rdi), %rcx
movl 0x4(%r14), %esi
movq %rsi, %rax
xorl %edx, %edx
idivq %rbx
movq %rsi, %r11
subq %rdx, %r11
subq %r11, %rcx
movq %rcx, %rax
cqto
idivq %rbx
movq %rax, %rcx
imulq %rbx, %rax
addq %r11, %rax
cmpq %rsi, %rax
cmovleq %rsi, %rax
cmpq %r15, %rcx
jge 0x4a2fc
movslq (%r10,%rdi), %rdx
cmpq %rdx, %rax
jne 0x4a2fc
leaq (%r10,%rdi), %rax
cmpq %rcx, %r9
jg 0x4a2fc
je 0x4a1bd
movq %rcx, %rdx
shlq $0x5, %rdx
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%r10,%rdx)
movups %xmm0, (%r10,%rdx)
movq 0x58(%r14), %rax
movl 0x4(%rax,%rdi), %r10d
movq %rcx, %rdx
shlq $0x5, %rdx
leaq (%rax,%rdx), %r11
addq $0x3c, %r11
movq %rcx, %r13
incq %r13
cmpq %r15, %r13
jge 0x4a243
movq $0x0, -0x4(%r11)
movq $-0x1, -0x14(%r11)
movq %r8, -0xc(%r11)
incl %r10d
movl %r10d, -0x1c(%r11)
movslq %r10d, %rsi
movl 0x8(%r14), %r10d
movl 0x4(%r14), %edi
movq %rdi, %rax
xorl %edx, %edx
idivq %rbx
subq %rdx, %rdi
subq %rdi, %rsi
movq %rsi, %rax
cqto
idivq %rbx
leaq 0x1(%rax), %rdx
imulq %rbx, %rdx
addq %rdi, %rdx
decq %rdx
cmpq %r10, %rdx
cmovlq %rdx, %r10
movl %r10d, -0x18(%r11)
addq $0x20, %r11
cmpq %rax, %r13
je 0x4a1d8
jmp 0x4a2dd
movq %rcx, %r15
cmpq $0x2, %r12
movq %r9, %r12
jge 0x4a13c
testq %rcx, %rcx
jle 0x4a2d3
movl 0x8(%r14), %edi
movl 0x4(%r14), %esi
leaq -0x1(%rsi), %r11
movq 0x58(%r14), %r9
xorl %r10d, %r10d
movq %rsi, %rax
xorl %edx, %edx
idivq %rbx
movq %rsi, %r14
subq %rdx, %r14
negq %rdx
addq %rdx, %rsi
decq %rsi
addq $0x1c, %r9
movq $0x0, -0x4(%r9)
movq $-0x1, -0x14(%r9)
movq %r8, -0xc(%r9)
incl %r11d
movl %r11d, -0x1c(%r9)
movslq %r11d, %rax
subq %r14, %rax
cqto
idivq %rbx
leaq 0x1(%rax), %r11
imulq %rbx, %r11
addq %rsi, %r11
cmpq %rdi, %r11
cmovgeq %rdi, %r11
movl %r11d, -0x18(%r9)
cmpq %rax, %r10
jne 0x4a31b
incq %r10
addq $0x20, %r9
cmpq %r10, %rcx
jne 0x4a286
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x1db45d(%rip), %rdi    # 0x225741
leaq 0x1db358(%rip), %rsi    # 0x225643
leaq 0x1db3de(%rip), %rcx    # 0x2256d0
movl $0x529, %edx            # imm = 0x529
callq 0x2110
leaq 0x1db403(%rip), %rdi    # 0x225706
leaq 0x1db339(%rip), %rsi    # 0x225643
leaq 0x1db3bf(%rip), %rcx    # 0x2256d0
movl $0x51f, %edx            # imm = 0x51F
callq 0x2110
leaq 0x1db41f(%rip), %rdi    # 0x225741
leaq 0x1db31a(%rip), %rsi    # 0x225643
leaq 0x1db3a0(%rip), %rcx    # 0x2256d0
movl $0x537, %edx            # imm = 0x537
callq 0x2110
leaq 0x1db37c(%rip), %rdi    # 0x2256bd
leaq 0x1db2fb(%rip), %rsi    # 0x225643
leaq 0x1db381(%rip), %rcx    # 0x2256d0
movl $0x51a, %edx            # imm = 0x51A
callq 0x2110