// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/cram/cram_index.c
// Function: cram_index_slice
int cram_index_slice(cram_fd *fd,
                     cram_container *c,
                     cram_slice *s,
                     BGZF *fp,
                     off_t cpos,
                     off_t spos, // relative to cpos
                     off_t sz) {
    int ret;
    char buf[1024];

    if (sz > INT_MAX) {
        hts_log_error("CRAM slice is too big (%"PRId64" bytes)",
                      (int64_t) sz);
        return -1;
    }

    if (s->hdr->ref_seq_id == -2) {
        ret = cram_index_build_multiref(fd, c, s, fp, cpos, spos, sz);
    } else {
        snprintf(buf, sizeof(buf),
                 "%d\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%d\t%d\n",
                 s->hdr->ref_seq_id, s->hdr->ref_seq_start,
                 s->hdr->ref_seq_span, (int64_t)cpos, (int)spos, (int)sz);
        ret = (bgzf_write(fp, buf, strlen(buf)) >= 0)? 0 : -4;
    }

    return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq 0x460(%rsp), %r12
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %r12
jl 0x4ca10
leaq 0x50639(%rip), %rsi     # 0x9d029
leaq 0x50643(%rip), %rdx     # 0x9d03a
movl $0x1, %edi
movq %r12, %rcx
xorl %eax, %eax
callq 0x14378
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4cc5e
movq %r9, %r15
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r13
movq (%rdx), %rax
movl 0x4(%rax), %ecx
cmpl $-0x2, %ecx
jne 0x4cb78
cmpl $0x77, 0x8(%rdi)
je 0x4ca4c
movq 0x18(%rdi), %rcx
movq %r13, %rdx
callq 0x3a564
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4cc5e
movq (%r13), %rax
cmpl $0x0, 0x18(%rax)
jle 0x4cbd3
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movq $-0x80000000, %rax      # imm = 0x80000000
movl $0xfffffff7, %r12d      # imm = 0xFFFFFFF7
movq $-0x9, %rbx
movl $0x8, %ebp
xorl %r14d, %r14d
xorl %edx, %edx
xorl %r8d, %r8d
movl %r12d, %edi
movq 0x30(%r13), %rsi
movl (%rsi,%rbp), %r12d
cmpl %edi, %r12d
jne 0x4caad
movslq %ebx, %rdi
cmpq %rdi, 0x10(%rsi,%rbp)
jl 0x4cc3f
movq 0x10(%rsi,%rbp), %rbx
cmpl %ecx, %r12d
jne 0x4cac5
movq 0x70(%rsi,%rbp), %rdx
cmpq %rdx, %rax
cmovleq %rdx, %rax
jmp 0x4cb35
cmpl $-0x2, %ecx
je 0x4cb24
leaq (%rdx,%rax), %r9
incq %r9
subq $0x8, %rsp
movl $0x400, %esi            # imm = 0x400
leaq 0x28(%rsp), %r15
movq %r15, %rdi
leaq 0x50573(%rip), %rdx     # 0x9d05c
xorl %eax, %eax
pushq 0x468(%rsp)
pushq 0x18(%rsp)
pushq 0x28(%rsp)
callq 0x4800
addq $0x20, %rsp
movq %r15, %rdi
callq 0x41d0
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xd0bb
testq %rax, %rax
js 0x4cc38
movq 0x30(%r13), %rax
movl (%rax,%rbp), %ecx
movq 0x10(%rax,%rbp), %r8
movq 0x70(%rax,%rbp), %rax
incq %r14
movq %r8, %rdx
negq %rdx
movq (%r13), %rsi
movslq 0x18(%rsi), %rsi
addq $0x90, %rbp
cmpq %rsi, %r14
jl 0x4ca8f
movl $0x1, %r9d
subq %r8, %r9
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x460(%rsp), %r12
movq 0x8(%rsp), %r15
jmp 0x4cbe8
movq 0x8(%rax), %r8
movq 0x10(%rax), %r9
subq $0x8, %rsp
leaq 0x504d1(%rip), %rdx     # 0x9d05c
leaq 0x28(%rsp), %r13
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
xorl %eax, %eax
pushq %r12
pushq %r15
pushq %r14
callq 0x4800
addq $0x20, %rsp
movq %r13, %rdi
callq 0x41d0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xd0bb
xorl %ecx, %ecx
testq %rax, %rax
setns %cl
leal -0x4(,%rcx,4), %eax
jmp 0x4cc5e
movl $0x1, %r9d
movq $-0x80000000, %rax      # imm = 0x80000000
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
xorl %r8d, %r8d
cmpl $-0x2, %ecx
je 0x4cc34
addq %rax, %r9
subq $0x8, %rsp
leaq 0x50461(%rip), %rdx     # 0x9d05c
leaq 0x28(%rsp), %r13
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
xorl %eax, %eax
pushq %r12
pushq %r15
pushq %r14
callq 0x4800
addq $0x20, %rsp
movq %r13, %rdi
callq 0x41d0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xd0bb
testq %rax, %rax
js 0x4cc38
xorl %eax, %eax
jmp 0x4cc5e
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x4cc5e
leaq 0x50557(%rip), %rsi     # 0x9d19d
leaq 0x504ce(%rip), %rdx     # 0x9d11b
movl $0x1, %edi
xorl %eax, %eax
callq 0x14378
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq