// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
movq -0x10(%rbp), %rdx
callq 0x340c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x59(%rbp)
jl 0x34b0a
cmpq $0x0, -0x20(%rbp)
setg %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x34b13
jmp 0x34b15
jmp 0x34b34
leaq 0x34d879(%rip), %rdi    # 0x382395
leaq 0x34d7f8(%rip), %rsi    # 0x38231b
movl $0x51a, %edx            # imm = 0x51A
leaq 0x34d879(%rip), %rcx    # 0x3823a8
callq 0x2130
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x34b43
jmp 0x35090
jmp 0x34b45
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
cmpq -0x18(%rbp), %rax
jae 0x34c1e
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shrq %rcx
movq -0x8(%rbp), %rax
orq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shrq $0x2, %rcx
movq -0x8(%rbp), %rax
orq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shrq $0x4, %rcx
movq -0x8(%rbp), %rax
orq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shrq $0x8, %rcx
movq -0x8(%rbp), %rax
orq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
shrq $0x10, %rcx
movq -0x8(%rbp), %rax
orq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x50(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x58(%rax)
jmp 0x34c20
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x28(%rbp)
jl 0x34eee
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rsi
movq -0x10(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x9e250
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x28(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movslq (%rax), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x5a(%rbp)
jne 0x34cb8
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x58(%rbp), %rcx
movb %al, -0x5a(%rbp)
jge 0x34cb8
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
setle %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
testb $0x1, %al
jne 0x34cc1
jmp 0x34cc3
jmp 0x34ce2
leaq 0x34d714(%rip), %rdi    # 0x3823de
leaq 0x34d64a(%rip), %rsi    # 0x38231b
movl $0x51f, %edx            # imm = 0x51F
leaq 0x34d6cb(%rip), %rcx    # 0x3823a8
callq 0x2130
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x34d30
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rcx
movq -0x28(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x34ed5
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x16(%rax)     # imm = 0xFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0x0, 0x12(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0x0, 0x10(%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
movq -0x10(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x9e2e0
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x34ea3
jmp 0x34ec2
leaq 0x34d56f(%rip), %rdi    # 0x382419
leaq 0x34d46a(%rip), %rsi    # 0x38231b
movl $0x529, %edx            # imm = 0x529
leaq 0x34d4eb(%rip), %rcx    # 0x3823a8
callq 0x2130
jmp 0x34ec4
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x34d57
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x34c40
cmpq $0x0, -0x58(%rbp)
jle 0x35090
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
subq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x3508e
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x0, 0x1c(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0xc(%rax)  # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x16(%rax)     # imm = 0xFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0xffff, 0x14(%rax)     # imm = 0xFFFF
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0x0, 0x12(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movw $0x0, 0x10(%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rsi
movq -0x10(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0x9e2e0
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0x3505c
jmp 0x3507b
leaq 0x34d3b6(%rip), %rdi    # 0x382419
leaq 0x34d2b1(%rip), %rsi    # 0x38231b
movl $0x537, %edx            # imm = 0x537
leaq 0x34d332(%rip), %rcx    # 0x3823a8
callq 0x2130
jmp 0x3507d
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x34f10
jmp 0x35090
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)