// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
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 0x49a1f
movb %cl, %al
addq %rax, %r15
cmpq %r12, %r15
jl 0x49a1f
je 0x499b3
movq %rdi, %r14
cmpq %r15, 0x50(%rdi)
jae 0x4980e
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)
movq 0x58(%r14), %r9
movabsq $-0x100000000, %r8      # imm = 0xFFFFFFFF00000000
leaq -0x1(%r12), %r10
movq %r10, %rdi
shlq $0x5, %rdi
movslq 0x4(%r9,%rdi), %r11
movl 0x4(%r14), %esi
movq %rsi, %rax
xorl %edx, %edx
idivq %rbx
movq %rsi, %r13
subq %rdx, %r13
movq %r11, %rax
subq %r13, %rax
cqto
idivq %rbx
movq %rax, %rcx
imulq %rbx, %rax
addq %r13, %rax
cmpq %rsi, %rax
cmovleq %rsi, %rax
cmpq %r15, %rcx
jge 0x499e1
movslq (%r9,%rdi), %rdx
cmpq %rdx, %rax
jne 0x499e1
leaq (%r9,%rdi), %rax
cmpq %rcx, %r10
jg 0x499e1
je 0x498a6
movq %rcx, %rdx
shlq $0x5, %rdx
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%r9,%rdx)
movups %xmm0, (%r9,%rdx)
movq 0x58(%r14), %r9
movl 0x4(%r9,%rdi), %r11d
movq %rcx, %rax
shlq $0x5, %rax
leaq (%r9,%rax), %r13
addq $0x3c, %r13
movq %rcx, %rbp
incq %rbp
cmpq %r15, %rbp
jge 0x49923
movq $0x0, -0x4(%r13)
movq $-0x1, -0x14(%r13)
movq %r8, -0xc(%r13)
incl %r11d
movl %r11d, -0x1c(%r13)
movslq %r11d, %rsi
movl 0x8(%r14), %r11d
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 %r11, %rdx
cmovlq %rdx, %r11
movl %r11d, -0x18(%r13)
addq $0x20, %r13
cmpq %rax, %rbp
je 0x498b8
jmp 0x499c2
movq %rcx, %r15
cmpq $0x2, %r12
movq %r10, %r12
jge 0x49820
testq %rcx, %rcx
jle 0x499b3
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 0x49a00
incq %r10
addq $0x20, %r9
cmpq %r10, %rcx
jne 0x49966
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e7e88(%rip), %rdi    # 0x231851
leaq 0x1e7d83(%rip), %rsi    # 0x231753
leaq 0x1e7e09(%rip), %rcx    # 0x2317e0
movl $0x529, %edx            # imm = 0x529
callq 0x2110
leaq 0x1e7e2e(%rip), %rdi    # 0x231816
leaq 0x1e7d64(%rip), %rsi    # 0x231753
leaq 0x1e7dea(%rip), %rcx    # 0x2317e0
movl $0x51f, %edx            # imm = 0x51F
callq 0x2110
leaq 0x1e7e4a(%rip), %rdi    # 0x231851
leaq 0x1e7d45(%rip), %rsi    # 0x231753
leaq 0x1e7dcb(%rip), %rcx    # 0x2317e0
movl $0x537, %edx            # imm = 0x537
callq 0x2110
leaq 0x1e7da7(%rip), %rdi    # 0x2317cd
leaq 0x1e7d26(%rip), %rsi    # 0x231753
leaq 0x1e7dac(%rip), %rcx    # 0x2317e0
movl $0x51a, %edx            # imm = 0x51A
callq 0x2110