// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: update_overlap_region(overlap_region*, overlap_region*, long, long)
void update_overlap_region(overlap_region *des, overlap_region *src, int64_t xl, int64_t yl)
{
    kv_resize(uint16_t, des->w_list.c, src->w_list.c.n);
    des->w_list.c.n = src->w_list.c.n;
    memcpy(des->w_list.c.a, src->w_list.c.a, src->w_list.c.n*(sizeof((*(src->w_list.c.a)))));

    kv_resize(window_list, des->w_list, src->w_list.n);
    des->w_list.n = src->w_list.n;
    memcpy(des->w_list.a, src->w_list.a, src->w_list.n*(sizeof((*(src->w_list.a)))));

    if(src->w_list.n) {
        des->x_pos_s = src->w_list.a[0].x_start; des->x_pos_e = src->w_list.a[src->w_list.n-1].x_end; 
        des->y_pos_s = src->w_list.a[0].y_start; des->y_pos_e = src->w_list.a[src->w_list.n-1].y_end;
    }

    int64_t xr, yr; 
    if(des->x_pos_s <= des->y_pos_s) {
        des->y_pos_s -= des->x_pos_s; des->x_pos_s = 0;
    } else {
        des->x_pos_s -= des->y_pos_s; des->y_pos_s = 0;
    }

    xr = xl-des->x_pos_e-1; yr = yl-des->y_pos_e-1;
    if(xr <= yr) {
        des->x_pos_e = xl-1; des->y_pos_e += xr;        
    } else {
        des->y_pos_e = yl-1; des->x_pos_e += yr; 
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movq 0x60(%rsi), %rax
cmpq %rax, 0x68(%rdi)
jae 0x69ade
decq %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, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x68(%rbx)
movq 0x70(%rbx), %rdi
leaq 0x2(,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x70(%rbx)
movq 0x60(%r12), %rax
movq %rax, 0x60(%rbx)
movq 0x70(%rbx), %rdi
movq 0x60(%r12), %rdx
movq 0x70(%r12), %rsi
addq %rdx, %rdx
callq 0x2160
movq 0x48(%r12), %rax
cmpq %rax, 0x50(%rbx)
jae 0x69b54
decq %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(%rbx)
movq 0x58(%rbx), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%r12), %rax
movq %rax, 0x48(%rbx)
movq 0x58(%rbx), %rdi
movq 0x48(%r12), %rdx
movq 0x58(%r12), %rsi
shlq $0x5, %rdx
callq 0x2160
movq 0x48(%r12), %rax
testq %rax, %rax
je 0x69ba0
movq 0x58(%r12), %rcx
movl (%rcx), %edx
movl %edx, 0x4(%rbx)
shlq $0x5, %rax
movl -0x1c(%rcx,%rax), %edx
movl %edx, 0x8(%rbx)
movl 0x8(%rcx), %edx
movl %edx, 0x14(%rbx)
movl -0x14(%rcx,%rax), %eax
movl %eax, 0x18(%rbx)
leaq 0x4(%rbx), %rax
movl 0x4(%rbx), %edx
movl 0x14(%rbx), %esi
leaq 0x14(%rbx), %rcx
movl %edx, %edi
subl %esi, %edi
jbe 0x69bbb
movl %edi, (%rax)
movq %rcx, %rax
jmp 0x69bbf
subl %edx, %esi
movl %esi, (%rcx)
movl $0x0, (%rax)
movl 0x8(%rbx), %edx
movl 0x18(%rbx), %eax
movq %rdx, %rsi
notq %rsi
addq %r14, %rsi
movq %rax, %rcx
notq %rcx
addq %r15, %rcx
xorl %edi, %edi
xorl %r8d, %r8d
cmpq %rcx, %rsi
setle %dil
setg %r8b
cmovlq %rsi, %rcx
cmovgl %edx, %eax
cmovgl %r15d, %r14d
shll $0x4, %r8d
shll $0x4, %edi
decl %r14d
movl %r14d, 0x8(%rbx,%r8)
addl %eax, %ecx
movl %ecx, 0x8(%rbx,%rdi)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq