// File: /workspace/github_c_makefile_star2_O0/nh13[P]ksw/src/parasail/src/cigar.c
// Function: parasail_cigar_encode_string
parasail_cigar_t* parasail_cigar_encode_string(const char *cigar)
{
    int sscanf_retcode = 0;
    size_t offset = 0;
    int chars_read = 0;
    unsigned int len = 0;
    char op = 'M';
    int done = 0;
    size_t string_length = 0;
    size_t size = 0;
    parasail_cigar_t *ret = NULL;

    string_length = strlen(cigar);
    size = sizeof(uint32_t)*string_length;
    ret = malloc(sizeof(parasail_cigar_t));
    ret->seq = malloc(size);
    ret->len = 0;

    while (!done) {
        sscanf_retcode = sscanf(
                &cigar[offset], "%u%c%n", &len, &op, &chars_read);
        if (2 != sscanf_retcode) {
            fprintf(stderr, "invalid CIGAR string\n");
            parasail_cigar_free(ret);
            return NULL;
        }
        offset += chars_read;
        ret->len += 1;
        if ((size_t)ret->len >= size) {
            size *= 2;
            ret->seq = realloc(ret->seq, size);
        }
        ret->seq[ret->len-1] = parasail_cigar_encode(len, op);
        if (offset >= string_length) {
            done = 1;
        }
    }

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movb $0x4d, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19e050
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
shlq $0x2, %rax
movq %rax, -0x40(%rbp)
movl $0x18, %edi
callq 0x19e150
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x19e150
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x8(%rax)
cmpl $0x0, -0x30(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b9d13
jmp 0x1b9df7
movq -0x10(%rbp), %rdi
addq -0x20(%rbp), %rdi
leaq 0xad405e(%rip), %rsi    # 0xc8dd80
leaq -0x28(%rbp), %rdx
leaq -0x29(%rbp), %rcx
leaq -0x24(%rbp), %r8
movb $0x0, %al
callq 0x19e0c0
movl %eax, -0x14(%rbp)
movl $0x2, %eax
cmpl -0x14(%rbp), %eax
je 0x1b9d70
movq 0xc6d28f(%rip), %rax    # 0xe26fd8
movq (%rax), %rdi
leaq 0xad4034(%rip), %rsi    # 0xc8dd87
movb $0x0, %al
callq 0x19e180
movq -0x48(%rbp), %rdi
callq 0x1b9e10
movq $0x0, -0x8(%rbp)
jmp 0x1b9dff
movslq -0x24(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rax
movslq 0x8(%rax), %rax
cmpq -0x40(%rbp), %rax
jb 0x1b9dbc
movq -0x40(%rbp), %rax
shlq %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x19e1f0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movl -0x28(%rbp), %edi
movsbl -0x29(%rbp), %esi
callq 0x1b9c40
movl %eax, %edx
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x1b9df2
movl $0x1, -0x30(%rbp)
jmp 0x1b9d01
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)