// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/ext/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 0x4760
cmpq %rbx, (%r14)
je 0x1a44a
movl %eax, %r13d
jmp 0x1a63f
cmpb $0x0, (%rbx)
je 0x1a63f
xorl %r12d, %r12d
leaq 0x37300(%rip), %r14     # 0x5175d
xorl %ebp, %ebp
leaq (%rbx,%rbp), %rax
movq %rax, (%rsp)
movzbl (%rbx,%rbp), %r15d
testl %r15d, %r15d
je 0x1a47c
cmpl $0x2c, %r15d
je 0x1a47c
incq %rbp
jmp 0x1a45f
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x6, %rbp
jne 0x1a49d
movl $0x1, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x372c0(%rip), %rdi     # 0x51764
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0xb, %rbp
jne 0x1a4c2
movl $0x2, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x372a8(%rip), %rdi     # 0x51771
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x5, %rbp
jne 0x1a4e7
movl $0x4, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x37282(%rip), %rdi     # 0x51770
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x6, %rbp
jne 0x1a50c
movl $0x8, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x37265(%rip), %rdi     # 0x51778
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x7, %rbp
jne 0x1a531
movl $0x10, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x3723f(%rip), %rdi     # 0x51777
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x8, %rbp
jne 0x1a556
movl $0x20, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x37223(%rip), %rdi     # 0x51780
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x5, %rbp
jne 0x1a57b
movl $0x40, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x37204(%rip), %rdi     # 0x51786
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x5, %rbp
jne 0x1a5a0
movl $0x80, %ecx
testl %eax, %eax
je 0x1a62a
leaq 0x371e5(%rip), %rdi     # 0x5178c
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x9, %rbp
jne 0x1a5c1
movl $0x100, %ecx            # imm = 0x100
testl %eax, %eax
je 0x1a62a
leaq 0x371ce(%rip), %rdi     # 0x51796
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x6, %rbp
jne 0x1a5e2
movl $0x200, %ecx            # imm = 0x200
testl %eax, %eax
je 0x1a62a
leaq 0x371b4(%rip), %rdi     # 0x5179d
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
cmpq $0x3, %rbp
jne 0x1a603
movl $0x400, %ecx            # imm = 0x400
testl %eax, %eax
je 0x1a62a
leaq 0x37197(%rip), %rdi     # 0x517a1
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x46b0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpq $0xd, %rbp
jne 0x1a63f
movl $0x800, %ecx            # imm = 0x800
testl %eax, %eax
jne 0x1a63f
orl %ecx, %r12d
addq %rbp, %rbx
incq %rbx
movl %r12d, %r13d
testb %r15b, %r15b
jne 0x1a45d
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq