// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/sam.c
// Function: bam_str2flag
int bam_str2flag(const char *str)
{
    char *end, *beg = (char*) str;
    long int flag = strtol(str, &end, 0);
    if ( end!=str ) return flag;    // the conversion was successful
    flag = 0;
    while ( *str )
    {
        end = beg;
        while ( *end && *end!=',' ) end++;
        if ( !STRNCMP("PAIRED",beg,end-beg) ) flag |= BAM_FPAIRED;
        else if ( !STRNCMP("PROPER_PAIR",beg,end-beg) ) flag |= BAM_FPROPER_PAIR;
        else if ( !STRNCMP("UNMAP",beg,end-beg) ) flag |= BAM_FUNMAP;
        else if ( !STRNCMP("MUNMAP",beg,end-beg) ) flag |= BAM_FMUNMAP;
        else if ( !STRNCMP("REVERSE",beg,end-beg) ) flag |= BAM_FREVERSE;
        else if ( !STRNCMP("MREVERSE",beg,end-beg) ) flag |= BAM_FMREVERSE;
        else if ( !STRNCMP("READ1",beg,end-beg) ) flag |= BAM_FREAD1;
        else if ( !STRNCMP("READ2",beg,end-beg) ) flag |= BAM_FREAD2;
        else if ( !STRNCMP("SECONDARY",beg,end-beg) ) flag |= BAM_FSECONDARY;
        else if ( !STRNCMP("QCFAIL",beg,end-beg) ) flag |= BAM_FQCFAIL;
        else if ( !STRNCMP("DUP",beg,end-beg) ) flag |= BAM_FDUP;
        else if ( !STRNCMP("SUPPLEMENTARY",beg,end-beg) ) flag |= BAM_FSUPPLEMENTARY;
        else return -1;
        if ( !*end ) break;
        beg = end + 1;
    }
    return flag;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq %rsp, %r14
xorl %r13d, %r13d
movq %r14, %rsi
xorl %edx, %edx
callq 0x46d0
cmpq %rbx, (%r14)
je 0x2ff20
movl %eax, %r13d
jmp 0x3011a
movb (%rbx), %r12b
testb %r12b, %r12b
je 0x3011a
xorl %r15d, %r15d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ebp, %ebp
leaq (%rbx,%rbp), %rax
movq %rax, (%rsp)
movzbl (%rbx,%rbp), %r14d
testl %r14d, %r14d
je 0x2ff54
cmpl $0x2c, %r14d
je 0x2ff54
incq %rbp
jmp 0x2ff37
leaq 0x6af0b(%rip), %rdi     # 0x9ae66
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x6, %rbp
jne 0x2ff79
movl $0x1, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6aeed(%rip), %rdi     # 0x9ae6d
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0xb, %rbp
jne 0x2ff9e
movl $0x2, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6aed5(%rip), %rdi     # 0x9ae7a
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x5, %rbp
jne 0x2ffc3
movl $0x4, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6aeaf(%rip), %rdi     # 0x9ae79
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x6, %rbp
jne 0x2ffe8
movl $0x8, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6ae92(%rip), %rdi     # 0x9ae81
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x7, %rbp
jne 0x3000d
movl $0x10, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6ae6c(%rip), %rdi     # 0x9ae80
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x8, %rbp
jne 0x30032
movl $0x20, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6ae50(%rip), %rdi     # 0x9ae89
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x5, %rbp
jne 0x30057
movl $0x40, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6ae31(%rip), %rdi     # 0x9ae8f
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x5, %rbp
jne 0x3007c
movl $0x80, %ecx
testl %eax, %eax
je 0x30100
leaq 0x6ae12(%rip), %rdi     # 0x9ae95
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x9, %rbp
jne 0x3009d
movl $0x100, %ecx            # imm = 0x100
testl %eax, %eax
je 0x30100
leaq 0x6adfb(%rip), %rdi     # 0x9ae9f
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x6, %rbp
jne 0x300be
movl $0x200, %ecx            # imm = 0x200
testl %eax, %eax
je 0x30100
leaq 0x6ade1(%rip), %rdi     # 0x9aea6
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0x3, %rbp
jne 0x300df
movl $0x400, %ecx            # imm = 0x400
testl %eax, %eax
je 0x30100
leaq 0x6adc4(%rip), %rdi     # 0x9aeaa
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x4650
cmpq $0xd, %rbp
jne 0x3011a
movl $0x800, %ecx            # imm = 0x800
testl %eax, %eax
jne 0x3011a
orq %rcx, %r15
testb %r14b, %r14b
je 0x30117
addq %rbp, %rbx
incq %rbx
testb %r12b, %r12b
jne 0x2ff35
movl %r15d, %r13d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq