// File: /workspace/github_c_makefile_star2_O3/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 $0x418, %rsp            # imm = 0x418
movq 0x450(%rsp), %r10
movl $0x80000000, %eax       # imm = 0x80000000
cmpq %rax, %r10
jl 0x4a1fa
leaq 0x4feaf(%rip), %rsi     # 0x9a089
leaq 0x4feb9(%rip), %rdx     # 0x9a09a
movl $0x1, %edi
movq %r10, %rcx
xorl %eax, %eax
callq 0x13de5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4a403
movq %r9, %r15
movq %r8, %r11
movq %rcx, %rbx
movq %rdx, %r12
movq (%rdx), %rax
movl 0x4(%rax), %ecx
cmpl $-0x2, %ecx
jne 0x4a3ad
cmpl $0x77, 0x8(%rdi)
je 0x4a240
movq %r11, %r14
movq 0x18(%rdi), %rcx
movq %r12, %rdx
callq 0x38fa2
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0x4a403
movq (%r12), %rax
movq %r14, %r11
cmpl $0x0, 0x18(%rax)
jle 0x4a3a9
movq %rbx, (%rsp)
movq %r12, 0x8(%rsp)
movq 0x30(%r12), %rdx
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
movq $-0x80000000, %r9       # imm = 0x80000000
movl $0xfffffff7, %ebx       # imm = 0xFFFFFFF7
movq $-0x9, %rdi
movl $0x8, %ebp
xorl %r12d, %r12d
xorl %esi, %esi
xorl %r8d, %r8d
movl %ebx, %r10d
movl (%rdx,%rbp), %ebx
movq 0x10(%rdx,%rbp), %r14
cmpl %r10d, %ebx
jne 0x4a299
movslq %edi, %rdi
cmpq %rdi, %r14
jl 0x4a415
cmpl %ecx, %ebx
jne 0x4a2ab
movq 0x70(%rdx,%rbp), %rsi
cmpq %rsi, %r9
cmovleq %rsi, %r9
jmp 0x4a32a
cmpl $-0x2, %ecx
je 0x4a31d
addq %rsi, %r9
incq %r9
subq $0x8, %rsp
movl $0x400, %esi            # imm = 0x400
leaq 0x18(%rsp), %rdi
leaq 0x4fdf1(%rip), %rdx     # 0x9a0bc
xorl %eax, %eax
pushq 0x458(%rsp)
movq %r15, %r13
pushq %r15
movq %r11, %r15
pushq %r11
callq 0x4800
addq $0x20, %rsp
leaq 0x10(%rsp), %rdi
callq 0x41d0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %rax, %rdx
callq 0xd005
testq %rax, %rax
js 0x4a436
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq 0x30(%rcx), %rdx
movq %r15, %r11
movq %r13, %r15
movl (%rdx,%rbp), %ecx
movq 0x10(%rdx,%rbp), %r8
movq 0x70(%rdx,%rbp), %r9
movq %r8, %rsi
negq %rsi
incq %r12
movslq 0x18(%rax), %r10
addq $0x90, %rbp
movq %r14, %rdi
cmpq %r10, %r12
jl 0x4a27d
cmpl $-0x2, %ecx
movq (%rsp), %rbx
movq 0x450(%rsp), %r10
je 0x4a3a9
subq %r8, %r9
incq %r9
subq $0x8, %rsp
leaq 0x4fd50(%rip), %rdx     # 0x9a0bc
leaq 0x18(%rsp), %r13
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
xorl %eax, %eax
pushq %r10
pushq %r15
pushq %r11
callq 0x4800
addq $0x20, %rsp
movq %r13, %rdi
callq 0x41d0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xd005
testq %rax, %rax
js 0x4a436
xorl %eax, %eax
jmp 0x4a403
movq 0x8(%rax), %r8
movq 0x10(%rax), %r9
subq $0x8, %rsp
leaq 0x4fcfc(%rip), %rdx     # 0x9a0bc
leaq 0x18(%rsp), %r13
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdi
xorl %eax, %eax
pushq %r10
pushq %r15
pushq %r11
callq 0x4800
addq $0x20, %rsp
movq %r13, %rdi
callq 0x41d0
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0xd005
xorl %ecx, %ecx
testq %rax, %rax
setns %cl
leal -0x4(,%rcx,4), %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4fde1(%rip), %rsi     # 0x9a1fd
leaq 0x4fd58(%rip), %rdx     # 0x9a17b
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x4a403
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x4a403