// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: test_bam_set1_validate_cigar
static void test_bam_set1_validate_cigar(void)
{
    const uint32_t cigar[] = { 20 << BAM_CIGAR_SHIFT | BAM_CMATCH };
    const char *seq = "TGGACTACGA";

    int r;
    bam1_t *bam = NULL;
    bam = bam_init1();
    VERIFY(bam != NULL, "failed to initialize BAM struct.");

    // mapped query must have a CIGAR
    r = bam_set1(bam, 0, NULL, 0, -1, 0, 0xff, 0, NULL, -1, 0, 0, strlen(seq), seq, NULL, 0);
    VERIFY(r < 0, "call to bam_set1() should have failed.");
    VERIFY(errno == EINVAL, "errno should be set.");

    // pos + ref len from CIGAR should be <= HTS_POS_MAX
    r = bam_set1(bam, 0, NULL, 0, -1, HTS_POS_MAX - 10, 0xff, sizeof(cigar) / 4, cigar, -1, 0, 0, 0, NULL, NULL, 0);
    VERIFY(r < 0, "call to bam_set1() should have failed.");
    VERIFY(errno == EINVAL, "errno should be set.");

    // query len from CIGAR should match the sequence length
    r = bam_set1(bam, 0, NULL, 0, -1, 0, 0xff, sizeof(cigar) / 4, cigar, -1, 0, 0, strlen(seq), seq, NULL, 0);
    VERIFY(r < 0, "call to bam_set1() should have failed.");
    VERIFY(errno == EINVAL, "errno should be set.");

cleanup:
    if (bam != NULL) bam_destroy1(bam);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl 0xe30fb(%rip), %eax     # 0xef00c
movl %eax, -0x4(%rbp)
leaq 0xe6de0(%rip), %rax     # 0xf2cfb
movq %rax, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
callq 0x37e90
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xbf58
leaq 0xe7c79(%rip), %rdi     # 0xf3bb7
leaq 0xe6f19(%rip), %rsi     # 0xf2e5e
leaq 0xe6bd2(%rip), %rdx     # 0xf2b1e
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x41a0
movq -0x28(%rbp), %rdi
movq %rax, %r10
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %r9d
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rsi
movq %r9, %rdx
movl $0xff, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq %r10, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
callq 0x382b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xc005
leaq 0xe7bcc(%rip), %rdi     # 0xf3bb7
leaq 0xe6e6c(%rip), %rsi     # 0xf2e5e
leaq 0xe6e0e(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
callq 0x4050
cmpl $0x16, (%rax)
je 0xc030
leaq 0xe7ba1(%rip), %rdi     # 0xf3bb7
leaq 0xe6e41(%rip), %rsi     # 0xf2e5e
leaq 0xe6e0a(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
movq -0x20(%rbp), %rdi
leaq -0x4(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movabsq $0x7fffffff7ffffff5, %r9 # imm = 0x7FFFFFFF7FFFFFF5
movq %rdx, %rsi
movl $0xff, (%rsp)
movq $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
callq 0x382b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xc0d3
leaq 0xe7afe(%rip), %rdi     # 0xf3bb7
leaq 0xe6d9e(%rip), %rsi     # 0xf2e5e
leaq 0xe6d40(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
callq 0x4050
cmpl $0x16, (%rax)
je 0xc0fe
leaq 0xe7ad3(%rip), %rdi     # 0xf3bb7
leaq 0xe6d73(%rip), %rsi     # 0xf2e5e
leaq 0xe6d3c(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x4(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x41a0
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %r11
movq %rax, %r10
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %r9d
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rsi
movq %r9, %rdx
movl $0xff, (%rsp)
movq $0x1, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl $0xffffffff, 0x18(%rsp) # imm = 0xFFFFFFFF
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq %r10, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
callq 0x382b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xc1b0
leaq 0xe7a1e(%rip), %rdi     # 0xf3bb7
leaq 0xe6cbe(%rip), %rsi     # 0xf2e5e
leaq 0xe6c60(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
callq 0x4050
cmpl $0x16, (%rax)
je 0xc1d8
leaq 0xe79f6(%rip), %rdi     # 0xf3bb7
leaq 0xe6c96(%rip), %rsi     # 0xf2e5e
leaq 0xe6c5f(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc1da
jmp 0xc1da
cmpq $0x0, -0x20(%rbp)
je 0xc1ea
movq -0x20(%rbp), %rdi
callq 0x380d0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)