// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_io.c
// Function: cram_read_container
cram_container *cram_read_container(cram_fd *fd) {
    cram_container c2, *c;
    int i, s;
    size_t rd = 0;
    uint32_t crc = 0;

    fd->err = 0;
    fd->eof = 0;

    memset(&c2, 0, sizeof(c2));
    if (CRAM_MAJOR_VERS(fd->version) == 1) {
        if ((s = fd->vv.varint_decode32_crc(fd, &c2.length, &crc)) == -1) {
            fd->eof = fd->empty_container ? 1 : 2;
            return NULL;
        } else {
            rd+=s;
        }
    } else if (CRAM_MAJOR_VERS(fd->version) < 4) {
        uint32_t len;
        if ((s = int32_decode(fd, &c2.length)) == -1) {
            if (CRAM_MAJOR_VERS(fd->version) == 2 &&
                CRAM_MINOR_VERS(fd->version) == 0)
                fd->eof = 1; // EOF blocks arrived in v2.1
            else
                fd->eof = fd->empty_container ? 1 : 2;
            return NULL;
        } else {
            rd+=s;
        }
        len = le_int4(c2.length);
        crc = crc32(0L, (unsigned char *)&len, 4);
    } else {
        if ((s = fd->vv.varint_decode32_crc(fd, &c2.length, &crc))   == -1) {
            fd->eof = fd->empty_container ? 1 : 2;
            return NULL;
        } else {
            rd+=s;
        }
    }
    if ((s = fd->vv.varint_decode32s_crc(fd, &c2.ref_seq_id, &crc))   == -1) return NULL; else rd+=s;
    if (CRAM_MAJOR_VERS(fd->version) >= 4) {
        int64_t i64;
        if ((s = fd->vv.varint_decode64_crc(fd, &i64, &crc))== -1) return NULL; else rd+=s;
        c2.ref_seq_start = i64;
        if ((s = fd->vv.varint_decode64_crc(fd, &i64, &crc)) == -1) return NULL; else rd+=s;
        c2.ref_seq_span = i64;
    } else {
        int32_t i32;
        if ((s = fd->vv.varint_decode32_crc(fd, &i32, &crc))== -1) return NULL; else rd+=s;
        c2.ref_seq_start = i32;
        if ((s = fd->vv.varint_decode32_crc(fd, &i32, &crc)) == -1) return NULL; else rd+=s;
        c2.ref_seq_span = i32;
    }
    if ((s = fd->vv.varint_decode32_crc(fd, &c2.num_records, &crc))  == -1) return NULL; else rd+=s;

    if (CRAM_MAJOR_VERS(fd->version) == 1) {
        c2.record_counter = 0;
        c2.num_bases = 0;
    } else {
        if (CRAM_MAJOR_VERS(fd->version) >= 3) {
            if ((s = fd->vv.varint_decode64_crc(fd, &c2.record_counter, &crc)) == -1)
                return NULL;
            else
                rd += s;
        } else {
            int32_t i32;
            if ((s = fd->vv.varint_decode32_crc(fd, &i32, &crc)) == -1)
                return NULL;
            else
                rd += s;
            c2.record_counter = i32;
        }

        if ((s = fd->vv.varint_decode64_crc(fd, &c2.num_bases, &crc))== -1)
            return NULL;
        else
            rd += s;
    }
    if ((s = fd->vv.varint_decode32_crc(fd, &c2.num_blocks, &crc))   == -1)
        return NULL;
    else
        rd+=s;
    if ((s = fd->vv.varint_decode32_crc(fd, &c2.num_landmarks, &crc))== -1)
        return NULL;
    else
        rd+=s;

    if (c2.num_landmarks < 0 || c2.num_landmarks >= SIZE_MAX / sizeof(int32_t))
        return NULL;

    if (!(c = calloc(1, sizeof(*c))))
        return NULL;

    *c = c2;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
    if (c->num_landmarks > FUZZ_ALLOC_LIMIT/sizeof(int32_t)) {
        fd->err = errno = ENOMEM;
        cram_free_container(c);
        return NULL;
    }
#endif
    if (c->num_landmarks && !(c->landmark = malloc(c->num_landmarks * sizeof(int32_t)))) {
        fd->err = errno;
        cram_free_container(c);
        return NULL;
    }
    for (i = 0; i < c->num_landmarks; i++) {
        if ((s = fd->vv.varint_decode32_crc(fd, &c->landmark[i], &crc)) == -1) {
            cram_free_container(c);
            return NULL;
        } else {
            rd += s;
        }
    }

    if (CRAM_MAJOR_VERS(fd->version) >= 3) {
        if (-1 == int32_decode(fd, (int32_t *)&c->crc32)) {
            cram_free_container(c);
            return NULL;
        } else {
            rd+=4;
        }

#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
        // Pretend the CRC was OK so the fuzzer doesn't have to get it right
        crc = c->crc32;
#endif

        if (crc != c->crc32) {
            hts_log_error("Container header CRC32 failure");
            cram_free_container(c);
            return NULL;
        }
    }

    c->offset = rd;
    c->slices = NULL;
    c->slice = NULL;
    c->curr_slice = 0;
    c->max_slice = c->num_landmarks;
    c->slice_rec = 0;
    c->curr_rec = 0;
    c->max_rec = 0;

    if (c->ref_seq_id == -2) {
        c->multi_seq = 1;
        fd->multi_seq = 1;
    }

    fd->empty_container =
        (c->num_records == 0 &&
         c->ref_seq_id == -1 &&
         c->ref_seq_start == 0x454f46 /* EOF */) ? 1 : 0;

    return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x10(%rbp)
movq $0x0, -0x2c8(%rbp)
movl $0x0, -0x2cc(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8890(%rax)
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
movl $0x2a0, %edx            # imm = 0x2A0
callq 0x4250
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x1, %eax
jne 0x75334
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x7531a
movq -0x10(%rbp), %rax
movl 0x88ac(%rax), %edx
movl $0x2, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8890(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x75475
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x4, %eax
jge 0x75401
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x6f2b0
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x753c3
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
jne 0x75392
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
cmpl $0x0, %eax
jne 0x75392
movq -0x10(%rbp), %rax
movl $0x1, 0x8890(%rax)
jmp 0x753b6
movq -0x10(%rbp), %rax
movl 0x88ac(%rax), %edx
movl $0x2, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8890(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movl -0x2b0(%rbp), %eax
movl %eax, -0x2d0(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq -0x2d0(%rbp), %rsi
movl $0x4, %edx
callq 0x4310
movl %eax, -0x2cc(%rbp)
jmp 0x75473
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x7545c
movq -0x10(%rbp), %rax
movl 0x88ac(%rax), %edx
movl $0x2, %ecx
movl $0x1, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8890(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x75473
jmp 0x75475
movq -0x10(%rbp), %rax
movq 0x8998(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x4, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x754b0
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x4, %eax
jl 0x75591
movq -0x10(%rbp), %rax
movq 0x89a0(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x7550f
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x2d8(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x10(%rbp), %rax
movq 0x89a0(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75569
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x2d8(%rbp), %rax
movq %rax, -0x2a0(%rbp)
jmp 0x75645
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2dc(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x755c8
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movslq -0x2dc(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2dc(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75622
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movslq -0x2dc(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x28, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75680
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x1, %eax
jne 0x756bf
movq $0x0, -0x298(%rbp)
movq $0x0, -0x290(%rbp)
jmp 0x757cc
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x75720
movq -0x10(%rbp), %rax
movq 0x89a0(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x18, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75709
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x7577a
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75757
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movslq -0x2e0(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x10(%rbp), %rax
movq 0x89a0(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x20, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x757b5
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x757cc
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x2c, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75807
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
addq $0x30, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x75857
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
cmpl $0x0, -0x280(%rbp)
jl 0x7588b
movslq -0x280(%rbp), %rax
movabsq $0x3fffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFFF
cmpq %rcx, %rax
jb 0x75898
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movl $0x1, %edi
movl $0x2a0, %esi            # imm = 0x2A0
callq 0x42f0
movq %rax, -0x2b8(%rbp)
cmpq $0x0, %rax
jne 0x758c1
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movq -0x2b8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
movl $0x2a0, %edx            # imm = 0x2A0
callq 0x43b0
movq -0x2b8(%rbp), %rax
cmpl $0x0, 0x30(%rax)
je 0x75932
movq -0x2b8(%rbp), %rax
movslq 0x30(%rax), %rdi
shlq $0x2, %rdi
callq 0x4650
movq -0x2b8(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0x75932
callq 0x4050
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x2b8(%rbp), %rdi
callq 0x74a70
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movl $0x0, -0x2bc(%rbp)
movl -0x2bc(%rbp), %eax
movq -0x2b8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x759d2
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x2b8(%rbp), %rcx
movq 0x38(%rcx), %rsi
movslq -0x2bc(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rsi
leaq -0x2cc(%rbp), %rdx
callq *%rax
movl %eax, -0x2c0(%rbp)
cmpl $-0x1, %eax
jne 0x759a7
movq -0x2b8(%rbp), %rdi
callq 0x74a70
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movslq -0x2c0(%rbp), %rax
addq -0x2c8(%rbp), %rax
movq %rax, -0x2c8(%rbp)
jmp 0x759be
movl -0x2bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x7593c
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x75a7c
movq -0x10(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
addq $0x280, %rsi            # imm = 0x280
callq 0x6f2b0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x75a20
movq -0x2b8(%rbp), %rdi
callq 0x74a70
movq $0x0, -0x8(%rbp)
jmp 0x75b94
movq -0x2c8(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x2c8(%rbp)
movl -0x2cc(%rbp), %eax
movq -0x2b8(%rbp), %rcx
cmpl 0x280(%rcx), %eax
je 0x75a7a
movl $0x1, %edi
leaq 0x7fedb(%rip), %rsi     # 0xf592e
leaq 0x7fee8(%rip), %rdx     # 0xf5942
movb $0x0, %al
callq 0x1b030
movq -0x2b8(%rbp), %rdi
callq 0x74a70
movq $0x0, -0x8(%rbp)
jmp 0x75b94
jmp 0x75a7c
movq -0x2c8(%rbp), %rcx
movq -0x2b8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x2b8(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x2b8(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x2b8(%rbp), %rax
movl $0x0, 0x5c(%rax)
movq -0x2b8(%rbp), %rax
movl 0x30(%rax), %ecx
movq -0x2b8(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x2b8(%rbp), %rax
movl $0x0, 0x74(%rax)
movq -0x2b8(%rbp), %rax
movl $0x0, 0x68(%rax)
movq -0x2b8(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x2b8(%rbp), %rax
cmpl $-0x2, 0x4(%rax)
jne 0x75b2a
movq -0x2b8(%rbp), %rax
movl $0x1, 0xac(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x889c(%rax)
movq -0x2b8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x28(%rcx)
movb %al, -0x2e1(%rbp)
jne 0x75b6c
movq -0x2b8(%rbp), %rcx
xorl %eax, %eax
cmpl $-0x1, 0x4(%rcx)
movb %al, -0x2e1(%rbp)
jne 0x75b6c
movq -0x2b8(%rbp), %rax
cmpq $0x454f46, 0x8(%rax)    # imm = 0x454F46
sete %al
movb %al, -0x2e1(%rbp)
movb -0x2e1(%rbp), %dl
xorl %ecx, %ecx
movl $0x1, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x88ac(%rax)
movq -0x2b8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
nopw %cs:(%rax,%rax)