// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/sam.c
// Function: test_bam_set1_validate_size_limits
static void test_bam_set1_validate_size_limits(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.");

    // very long sequence. each base counts for 1/2 byte of sequence data and
    // 1 byte of sequence quality data. the sum of all components may not exceed
    // INT32_MAX, which is the maximum possible value that can be stored in l_data.
    // In this case the 4 bytes of qname will cause it to overflow.
    r = bam_set1(bam, 0, NULL, BAM_FUNMAP, -1, 0, 0xff, 0, NULL, -1, 0, 0, 2 * (size_t)INT32_MAX / 3, seq, NULL, 0);
    VERIFY(r < 0, "call to bam_set1() should have failed.");
    VERIFY(errno == EINVAL, "errno should be set.");

    // very long CIGAR
    r = bam_set1(bam, 0, NULL, BAM_FUNMAP, -1, 0, 0xff, (size_t)INT32_MAX / 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.");

    // very long aux
    r = bam_set1(bam, 0, NULL, BAM_FUNMAP, -1, 0, 0xff, 0, NULL, -1, 0, 0, 0, NULL, NULL, INT32_MAX);
    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 $0x70, %rsp
movl 0xe2dfe(%rip), %eax     # 0xef00c
movl %eax, -0x4(%rbp)
leaq 0xe6ae3(%rip), %rax     # 0xf2cfb
movq %rax, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
callq 0x37e90
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xc255
leaq 0xe797c(%rip), %rdi     # 0xf3bb7
leaq 0xe6c39(%rip), %rsi     # 0xf2e7b
leaq 0xe68d5(%rip), %rdx     # 0xf2b1e
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %r9d
movl $0x4, %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 $0x55555554, 0x30(%rsp) # imm = 0x55555554
movq %rax, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
callq 0x382b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xc2f5
leaq 0xe78dc(%rip), %rdi     # 0xf3bb7
leaq 0xe6b99(%rip), %rsi     # 0xf2e7b
leaq 0xe6b1e(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
callq 0x4050
cmpl $0x16, (%rax)
je 0xc320
leaq 0xe78b1(%rip), %rdi     # 0xf3bb7
leaq 0xe6b6e(%rip), %rsi     # 0xf2e7b
leaq 0xe6b1a(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
movq -0x20(%rbp), %rdi
leaq -0x4(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %r9d
movl $0x4, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rsi
movq %r9, %rdx
movl $0xff, (%rsp)
movq $0x1fffffff, 0x8(%rsp)  # imm = 0x1FFFFFFF
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 0xc3c0
leaq 0xe7811(%rip), %rdi     # 0xf3bb7
leaq 0xe6ace(%rip), %rsi     # 0xf2e7b
leaq 0xe6a53(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
callq 0x4050
cmpl $0x16, (%rax)
je 0xc3eb
leaq 0xe77e6(%rip), %rdi     # 0xf3bb7
leaq 0xe6aa3(%rip), %rsi     # 0xf2e7b
leaq 0xe6a4f(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r9d
movl $0x4, %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 $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x7fffffff, 0x48(%rsp) # imm = 0x7FFFFFFF
callq 0x382b0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0xc488
leaq 0xe7746(%rip), %rdi     # 0xf3bb7
leaq 0xe6a03(%rip), %rsi     # 0xf2e7b
leaq 0xe6988(%rip), %rdx     # 0xf2e07
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
callq 0x4050
cmpl $0x16, (%rax)
je 0xc4b0
leaq 0xe771e(%rip), %rdi     # 0xf3bb7
leaq 0xe69db(%rip), %rsi     # 0xf2e7b
leaq 0xe6987(%rip), %rdx     # 0xf2e2e
movb $0x0, %al
callq 0x5b50
jmp 0xc4b2
jmp 0xc4b2
cmpq $0x0, -0x20(%rbp)
je 0xc4c2
movq -0x20(%rbp), %rdi
callq 0x380d0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)