// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq 0x60(%rsi), %rax
cmpq %rax, 0x68(%rdi)
jae 0x38319
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(%r14)
movq 0x70(%r14), %rdi
leaq 0x2(,%rcx,2), %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x70(%r14)
movq 0x60(%r12), %rax
jmp 0x3831d
movq 0x70(%r14), %rdi
movq %rax, 0x60(%r14)
movq 0x60(%r12), %rdx
movq 0x70(%r12), %rsi
addq %rdx, %rdx
callq 0x2160
movq 0x48(%r12), %rax
cmpq %rax, 0x50(%r14)
jae 0x38394
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(%r14)
movq 0x58(%r14), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x58(%r14)
movq 0x48(%r12), %rax
jmp 0x38398
movq 0x58(%r14), %rdi
movq %rax, 0x48(%r14)
movq 0x48(%r12), %rdx
movq 0x58(%r12), %rsi
shlq $0x5, %rdx
callq 0x2160
movq 0x48(%r12), %rdx
testq %rdx, %rdx
je 0x383d9
movq 0x58(%r12), %rsi
movl (%rsi), %eax
shlq $0x5, %rdx
movl -0x1c(%rsi,%rdx), %ecx
movl %ecx, 0x8(%r14)
movl 0x8(%rsi), %ecx
movl -0x14(%rsi,%rdx), %edx
movl %edx, 0x18(%r14)
jmp 0x383e1
movl 0x4(%r14), %eax
movl 0x14(%r14), %ecx
xorl %edx, %edx
movl %eax, %esi
subl %ecx, %esi
cmovbl %edx, %esi
subl %eax, %ecx
cmovbl %edx, %ecx
movl %esi, 0x4(%r14)
movl %ecx, 0x14(%r14)
movl 0x8(%r14), %eax
movl 0x18(%r14), %ecx
movq %rcx, %rdx
notq %rdx
addq %r15, %rdx
leal (%rdx,%rax), %esi
notq %rax
addq %rbx, %rax
decl %r15d
decl %ebx
addl %eax, %ecx
cmpq %rdx, %rax
cmovgl %r15d, %ecx
cmovgl %esi, %ebx
movl %ecx, 0x18(%r14)
movl %ebx, 0x8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq