// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: sam_read1
int sam_read1(htsFile *fp, sam_hdr_t *h, bam1_t *b)
{
    int ret, pass_filter;

    do {
        switch (fp->format.format) {
        case bam:
            ret = sam_read1_bam(fp, h, b);
            break;

        case cram:
            ret = sam_read1_cram(fp, h, &b);
            break;

        case sam:
            ret = sam_read1_sam(fp, h, b);
            break;

        case fasta_format:
        case fastq_format: {
            fastq_state *x = (fastq_state *)fp->state;
            if (!x) {
                if (!(fp->state = fastq_state_init(fp->format.format
                                                   == fastq_format ? '@' : '>')))
                    return -2;
            }

            return fastq_parse1(fp, b);
        }

        case empty_format:
            errno = EPIPE;
            return -3;

        default:
            errno = EFTYPE;
            return -3;
        }

        pass_filter = (ret >= 0 && fp->filter)
            ? sam_passes_filter(h, b, fp->filter)
            : 1;
    } while (pass_filter == 0);

    return pass_filter < 0 ? -2 : ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0xe, %eax
ja 0x3cb10
movq -0x38(%rbp), %rax
leaq 0xb4a30(%rip), %rcx     # 0xf1478
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x3cba0
movl %eax, -0x24(%rbp)
jmp 0x3cb24
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x3cc30
movl %eax, -0x24(%rbp)
jmp 0x3cb24
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x3ccc0
movl %eax, -0x24(%rbp)
jmp 0x3cb24
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x3cae7
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %ecx
movl $0x3e, %edi
movl $0x40, %eax
cmpl $0x11, %ecx
cmovel %eax, %edi
callq 0x3c630
movq -0x10(%rbp), %rcx
movq %rax, 0x40(%rcx)
cmpq $0x0, %rax
jne 0x3cae5
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x3cb8b
jmp 0x3cae7
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3d0f0
movl %eax, -0x4(%rbp)
jmp 0x3cb8b
callq 0x4050
movl $0x20, (%rax)
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x3cb8b
callq 0x4050
movl $0x8, (%rax)
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x3cb8b
cmpl $0x0, -0x24(%rbp)
jl 0x3cb55
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x3cb55
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdx
callq 0x35980
movl %eax, -0x3c(%rbp)
jmp 0x3cb5f
movl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3cb5f
movl -0x3c(%rbp), %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x3ca24
cmpl $0x0, -0x28(%rbp)
jge 0x3cb7f
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl %eax, -0x40(%rbp)
jmp 0x3cb85
movl -0x24(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)