// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/lib/linefile.c
// Function: lineFileTabixAndIndexMayOpen
struct lineFile *lineFileTabixAndIndexMayOpen(char *fileOrUrl, char *tbiFileOrUrl, bool zTerm)
/* Wrap a line file around a data file that has been compressed and indexed
 * by the tabix command line program. tbiFileOrUrl can be NULL, it defaults to <fileOrUrl>.tbi.
 * It must be readable in addition to fileOrUrl. If there's a problem, warn & return NULL.
 * This works only if kent/src has been compiled with USE_TABIX=1 and linked
 * with the tabix C library. */
{
if (fileOrUrl == NULL)
    errAbort("lineFileTabixMayOpen: fileOrUrl is NULL");

char tbiName[4096];
if (tbiFileOrUrl==NULL)
    safef(tbiName, sizeof(tbiName), "%s.tbi", fileOrUrl);
else
    safef(tbiName, sizeof(tbiName), "%s", tbiFileOrUrl);

htsFile *htsFile = hts_open(fileOrUrl, "r");
if (htsFile == NULL)
    {
    warn("Unable to open \"%s\"", fileOrUrl);
    return NULL;
    }
tbx_t *tabix;
if ((tabix = tbx_index_load2(fileOrUrl, tbiName)) == NULL)
    {
    warn("Unable to load tabix index from \"%s\"", tbiName);
    if (tabix)
        ti_close(tabix);
    tabix = NULL;
    return NULL;
    }
struct lineFile *lf = needMem(sizeof(struct lineFile));
lf->fileName = cloneString(fileOrUrl);
lf->fd = -1;
lf->bufSize = 64 * 1024;
lf->buf = needMem(lf->bufSize);
lf->zTerm = zTerm;
lf->tabix = tabix;
lf->htsFile = htsFile;
kstring_t *kline;
AllocVar(kline);
kline->s = malloc(8192);
lf->kline = kline;
lf->tabixIter = tbx_itr_queryi(tabix, HTS_IDX_REST, 0, 0);
return lf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1000, %rsp           # imm = 0x1000
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
testq %rdi, %rdi
jne 0x29f70
leaq 0x66f26(%rip), %rdi     # 0x90e8f
xorl %eax, %eax
callq 0x26b6f
testq %r15, %r15
je 0x29f89
leaq 0x6621d(%rip), %rdx     # 0x90199
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r15, %rcx
jmp 0x29f9b
leaq 0x66f27(%rip), %rdx     # 0x90eb7
movq %rsp, %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rcx
xorl %eax, %eax
callq 0x23c18
leaq 0x6be80(%rip), %rsi     # 0x95e29
movq %r14, %rdi
callq 0x4de6c
testq %rax, %rax
je 0x2a057
movq %rax, %r13
movq %rsp, %rsi
movq %r14, %rdi
callq 0x52faa
testq %rax, %rax
je 0x2a066
movq %rax, %r12
movl $0xc8, %edi
callq 0x2dc95
movq %rax, %r15
movq %r14, %rdi
callq 0x1f9f6
movq %rax, 0x8(%r15)
movabsq $0x10000ffffffff, %rax  # imm = 0x10000FFFFFFFF
movq %rax, 0x10(%r15)
movl $0x10000, %edi          # imm = 0x10000
callq 0x2dc95
movq %rax, 0x40(%r15)
movb %bl, 0x34(%r15)
movq %r12, 0x70(%r15)
movq %r13, 0x68(%r15)
movl $0x18, %edi
callq 0x2dc95
movq %rax, %rbx
movl $0x2000, %edi           # imm = 0x2000
callq 0x69d0
movq %rax, 0x10(%rbx)
movq %rbx, 0x80(%r15)
movq 0x18(%r12), %rdi
leaq 0x2896e(%rip), %r8      # 0x529b1
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x50c5b
movq %rax, 0x78(%r15)
jmp 0x2a07a
leaq 0x66e60(%rip), %rdi     # 0x90ebe
xorl %r15d, %r15d
movq %r14, %rsi
jmp 0x2a073
leaq 0x66e65(%rip), %rdi     # 0x90ed2
xorl %r15d, %r15d
movq %rsp, %rsi
xorl %eax, %eax
callq 0x268ca
movq %r15, %rax
addq $0x1000, %rsp           # imm = 0x1000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq