// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: get_uncorrected_read_from_cigar(Cigar_record*, char*, int, char*, int*)
void get_uncorrected_read_from_cigar(Cigar_record* cigar, char* new_read, int new_length, char* pre_read, int* pre_length)
{
    int i, j;
    int pre_i, new_i;
    int operation, operation_length;
    pre_i = new_i = 0;
    int diff_char_i = 0;


    for (i = 0; i < (long long)cigar->length; i++)
    {
        operation = Get_Cigar_Type(cigar->record[i]);
        operation_length = Get_Cigar_Length(cigar->record[i]);


        if (operation == 0)
        {
            memcpy(pre_read + pre_i, new_read + new_i, operation_length);
            pre_i = pre_i + operation_length;
            new_i = new_i + operation_length;
        }
        else if (operation == 1)
        {

            for (j = 0; j < operation_length; j++)
            {
                pre_read[pre_i] = Get_Match_Base(cigar->lost_base[diff_char_i]);
                pre_i++;
                diff_char_i++;
            }
            new_i = new_i + operation_length;
        }
        else if (operation == 3)
        {
            memcpy(pre_read + pre_i, cigar->lost_base + diff_char_i, operation_length);
            pre_i = pre_i + operation_length;
            diff_char_i = diff_char_i + operation_length;
        }
        else if (operation == 2)
        {
            new_i = new_i + operation_length;
            diff_char_i = diff_char_i + operation_length;
        }
    }

    *pre_length = pre_i;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x8(%rsp)
movq %rcx, (%rsp)
movq %rsi, 0x10(%rsp)
cmpq $0x0, 0x18(%rdi)
jle 0x380ff
movq %rdi, %r12
xorl %ebp, %ebp
leaq 0x1f8b6d(%rip), %r8     # 0x230b80
leaq 0x25d716(%rip), %rbx    # 0x295730
xorl %r15d, %r15d
xorl %r10d, %r10d
xorl %r14d, %r14d
movq 0x8(%r12), %rax
movl (%rax,%rbp,4), %eax
movl %eax, %ecx
andl $0x3, %ecx
movl %eax, %r13d
shrl $0x2, %r13d
movslq (%r8,%rcx,4), %rcx
addq %r8, %rcx
jmpq *%rcx
movslq %r14d, %rdi
addq (%rsp), %rdi
movslq %r10d, %rsi
addq 0x10(%rsp), %rsi
movq %r13, %rdx
movl %r10d, %ebx
callq 0x2160
leaq 0x1f8b1f(%rip), %r8     # 0x230b80
addl %r13d, %r14d
addl %ebx, %r13d
leaq 0x25d6c2(%rip), %rbx    # 0x295730
jmp 0x380ec
addl %r13d, %r10d
addl %r13d, %r15d
jmp 0x380ef
movslq %r14d, %rdi
addq (%rsp), %rdi
movslq %r15d, %rsi
addq 0x28(%r12), %rsi
movl %r13d, %edx
movl %r10d, %ebx
callq 0x2160
movl %ebx, %r10d
leaq 0x25d694(%rip), %rbx    # 0x295730
leaq 0x1f8add(%rip), %r8     # 0x230b80
addl %r13d, %r14d
addl %r15d, %r13d
movl %r13d, %r15d
jmp 0x380ef
cmpl $0x4, %eax
jb 0x380e9
movslq %r15d, %rax
movslq %r14d, %rcx
addq (%rsp), %rcx
movl %r13d, %esi
negl %esi
xorl %edx, %edx
movq 0x28(%r12), %rdi
movzbl (%rdi,%rax), %edi
andl $0x7, %edi
movb (%rbx,%rdi), %dil
movb %dil, (%rcx)
incq %rax
incq %rcx
decl %edx
cmpl %edx, %esi
jne 0x380c4
subl %edx, %r14d
subl %edx, %r15d
addl %r10d, %r13d
movl %r13d, %r10d
incq %rbp
cmpq %rbp, 0x18(%r12)
jg 0x38023
jmp 0x38102
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movl %r14d, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq