// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: append_aligned_integer_seq(ma_ug_t*, uc_block_t*, poa_g_t*, long, unsigned long*, long, unsigned long, unsigned int*, unsigned int*, long)
void append_aligned_integer_seq(ma_ug_t *ug, uc_block_t *raw, poa_g_t *g, int64_t g_occ, uint64_t *str, int64_t str_occ, uint64_t is_rev,
uint32_t *match_g, uint32_t *match_str, int64_t match_occ)
{
    if(str_occ <= 0) return;
    int64_t k, p_str, p_g;
    
    if(is_rev == 0) {
        for (k = match_occ-1, p_str = 0, p_g = -1; k >= 0; k--) {
            fprintf(stderr, "+[M::%s::] match_str[%ld]::%u, match_occ::%ld, p_g::%ld\n", 
            __func__, k, match_str[k], match_occ, p_g);
            assert(((int64_t)match_str[k]) >= p_str); 
            // append_integer_seq_frag(ug, raw, g, p_g, match_g[k], str+p_str, match_str[k]+1-p_str, is_rev);
            p_str = match_str[k]; p_g = match_g[k]; 
        }
        // append_integer_seq_frag(ug, raw, g, p_g, -1, str+p_str, str_occ-p_str, is_rev);
    } else {
        for (k = match_occ-1, p_str = str_occ-1, p_g = -1; k >= 0; k--) {
            fprintf(stderr, "-[M::%s::] match_str[%ld]::%u, match_occ::%ld\n", 
            __func__, k, match_str[k], match_occ);
            assert(((int64_t)match_str[k]) <= p_str); 
            // append_integer_seq_frag(ug, raw, g, p_g, match_g[k], str+match_str[k], p_str+1-match_str[k], is_rev);
            p_str = match_str[k]; p_g = match_g[k];  
        }
        // append_integer_seq_frag(ug, raw, g, p_g, -1, str, p_str+1, is_rev);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jg 0x330b4c
jmp 0x330ce0
cmpq $0x0, 0x10(%rbp)
jne 0x330c1f
movq 0x28(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $-0x1, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
jl 0x330c1a
movq 0x9345b(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rcx
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rdx
movl (%rax,%rdx,4), %r8d
movq 0x28(%rbp), %r9
movq -0x48(%rbp), %rax
leaq 0x66eb6(%rip), %rsi     # 0x397a5d
leaq 0x66ee8(%rip), %rdx     # 0x397a96
movq %rax, (%rsp)
movb $0x0, %al
callq 0x22a0
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpq -0x40(%rbp), %rax
jl 0x330bcc
jmp 0x330beb
leaq 0x66ede(%rip), %rdi     # 0x397ab1
leaq 0x655df(%rip), %rsi     # 0x3961b9
movl $0x15f9, %edx           # imm = 0x15F9
leaq 0x66eec(%rip), %rcx     # 0x397ad2
callq 0x2130
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x40(%rbp)
movq 0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x330b73
jmp 0x330ce0
movq 0x28(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
movq $-0x1, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
jl 0x330cde
movq 0x9338f(%rip), %rax     # 0x3c3fe0
movq (%rax), %rdi
movq -0x38(%rbp), %rcx
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rdx
movl (%rax,%rdx,4), %r8d
movq 0x28(%rbp), %r9
leaq 0x66ef0(%rip), %rsi     # 0x397b5f
leaq 0x66e20(%rip), %rdx     # 0x397a96
movb $0x0, %al
callq 0x22a0
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpq -0x40(%rbp), %rax
jg 0x330c90
jmp 0x330caf
leaq 0x66ef7(%rip), %rdi     # 0x397b8e
leaq 0x6551b(%rip), %rsi     # 0x3961b9
movl $0x1602, %edx           # imm = 0x1602
leaq 0x66e28(%rip), %rcx     # 0x397ad2
callq 0x2130
movq 0x20(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x40(%rbp)
movq 0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x330c3f
jmp 0x330ce0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)