// File: 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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
xorl %edx, %edx
callq 0x4820
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
je 0x20cad
movq -0x28(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x21090
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x21089
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x29(%rbp)
je 0x20ceb
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x20cf4
jmp 0x20d02
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x20cca
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5aaf3(%rip), %rdi     # 0x7b80b
callq 0x4740
cmpl $0x0, %eax
jne 0x20d48
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x6, %eax
cmpq %rcx, %rax
jne 0x20d48
movq -0x28(%rbp), %rax
orq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x2106d
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5aab4(%rip), %rdi     # 0x7b812
callq 0x4740
cmpl $0x0, %eax
jne 0x20d8e
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0xb, %eax
cmpq %rcx, %rax
jne 0x20d8e
movq -0x28(%rbp), %rax
orq $0x2, %rax
movq %rax, -0x28(%rbp)
jmp 0x2106b
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5aa7b(%rip), %rdi     # 0x7b81f
callq 0x4740
cmpl $0x0, %eax
jne 0x20dd4
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x5, %eax
cmpq %rcx, %rax
jne 0x20dd4
movq -0x28(%rbp), %rax
orq $0x4, %rax
movq %rax, -0x28(%rbp)
jmp 0x21069
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5aa34(%rip), %rdi     # 0x7b81e
callq 0x4740
cmpl $0x0, %eax
jne 0x20e1a
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x6, %eax
cmpq %rcx, %rax
jne 0x20e1a
movq -0x28(%rbp), %rax
orq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x21067
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a9f6(%rip), %rdi     # 0x7b826
callq 0x4740
cmpl $0x0, %eax
jne 0x20e60
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x7, %eax
cmpq %rcx, %rax
jne 0x20e60
movq -0x28(%rbp), %rax
orq $0x10, %rax
movq %rax, -0x28(%rbp)
jmp 0x21065
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a9af(%rip), %rdi     # 0x7b825
callq 0x4740
cmpl $0x0, %eax
jne 0x20ea6
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x8, %eax
cmpq %rcx, %rax
jne 0x20ea6
movq -0x28(%rbp), %rax
orq $0x20, %rax
movq %rax, -0x28(%rbp)
jmp 0x21063
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a972(%rip), %rdi     # 0x7b82e
callq 0x4740
cmpl $0x0, %eax
jne 0x20eec
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x5, %eax
cmpq %rcx, %rax
jne 0x20eec
movq -0x28(%rbp), %rax
orq $0x40, %rax
movq %rax, -0x28(%rbp)
jmp 0x21061
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a932(%rip), %rdi     # 0x7b834
callq 0x4740
cmpl $0x0, %eax
jne 0x20f34
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x5, %eax
cmpq %rcx, %rax
jne 0x20f34
movq -0x28(%rbp), %rax
orq $0x80, %rax
movq %rax, -0x28(%rbp)
jmp 0x2105f
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a8f0(%rip), %rdi     # 0x7b83a
callq 0x4740
cmpl $0x0, %eax
jne 0x20f7c
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x9, %eax
cmpq %rcx, %rax
jne 0x20f7c
movq -0x28(%rbp), %rax
orq $0x100, %rax            # imm = 0x100
movq %rax, -0x28(%rbp)
jmp 0x2105d
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a8b2(%rip), %rdi     # 0x7b844
callq 0x4740
cmpl $0x0, %eax
jne 0x20fc4
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x6, %eax
cmpq %rcx, %rax
jne 0x20fc4
movq -0x28(%rbp), %rax
orq $0x200, %rax            # imm = 0x200
movq %rax, -0x28(%rbp)
jmp 0x2105b
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a871(%rip), %rdi     # 0x7b84b
callq 0x4740
cmpl $0x0, %eax
jne 0x21009
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0x3, %eax
cmpq %rcx, %rax
jne 0x21009
movq -0x28(%rbp), %rax
orq $0x400, %rax            # imm = 0x400
movq %rax, -0x28(%rbp)
jmp 0x21059
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
leaq 0x5a830(%rip), %rdi     # 0x7b84f
callq 0x4740
cmpl $0x0, %eax
jne 0x2104e
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movl $0xd, %eax
cmpq %rcx, %rax
jne 0x2104e
movq -0x28(%rbp), %rax
orq $0x800, %rax            # imm = 0x800
movq %rax, -0x28(%rbp)
jmp 0x21057
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x21090
jmp 0x21059
jmp 0x2105b
jmp 0x2105d
jmp 0x2105f
jmp 0x21061
jmp 0x21063
jmp 0x21065
jmp 0x21067
jmp 0x21069
jmp 0x2106b
jmp 0x2106d
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x21078
jmp 0x21089
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x20cb5
movq -0x28(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)