// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_crypt4gh_redirect
static int hts_crypt4gh_redirect(const char *fn, const char *mode,
                                 hFILE **hfile_ptr, htsFile *fp) {
    hFILE *hfile1 = *hfile_ptr;
    hFILE *hfile2 = NULL;
    char fn_buf[512], *fn2 = fn_buf;
    char mode2[102]; // Size set by sizeof(simple_mode) in hts_hopen()
    const char *prefix = "crypt4gh:";
    size_t fn2_len = strlen(prefix) + strlen(fn) + 1;
    int ret = -1;

    if (fn2_len > sizeof(fn_buf)) {
        if (fn2_len >= INT_MAX) // Silence gcc format-truncation warning
            return -1;
        fn2 = malloc(fn2_len);
        if (!fn2) return -1;
    }

    // Reopen fn using the crypt4gh plug-in (if available)
    snprintf(fn2, fn2_len, "%s%s", prefix, fn);
    snprintf(mode2, sizeof(mode2), "%s%s", mode, strchr(mode, ':') ? "" : ":");
    hfile2 = hopen(fn2, mode2, "parent", hfile1, NULL);
    if (hfile2) {
        // Replace original hfile with the new one.  The original is now
        // enclosed within hfile2
        *hfile_ptr = hfile2;
        ret = 0;
    }

    if (fn2 != fn_buf)
        free(fn2);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x240(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq 0xd27c1(%rip), %rax     # 0xef724
movq %rax, -0x2b8(%rbp)
movq -0x2b8(%rbp), %rdi
callq 0x41b0
movq %rax, -0x2d0(%rbp)
movq -0x10(%rbp), %rdi
callq 0x41b0
movq %rax, %rcx
movq -0x2d0(%rbp), %rax
addq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x2c0(%rbp)
movl $0xffffffff, -0x2c4(%rbp) # imm = 0xFFFFFFFF
cmpq $0x200, -0x2c0(%rbp) # imm = 0x200
jbe 0x1cff9
cmpq $0x7fffffff, -0x2c0(%rbp) # imm = 0x7FFFFFFF
jb 0x1cfce
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d0ee
movq -0x2c0(%rbp), %rdi
callq 0x4650
movq %rax, -0x248(%rbp)
cmpq $0x0, -0x248(%rbp)
jne 0x1cff7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1d0ee
jmp 0x1cff9
movq -0x248(%rbp), %rdi
movq -0x2c0(%rbp), %rsi
movq -0x2b8(%rbp), %rcx
movq -0x10(%rbp), %r8
leaq 0xd312f(%rip), %rdx     # 0xf0148
movb $0x0, %al
callq 0x47e0
leaq -0x2b0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x2d8(%rbp)
movq -0x18(%rbp), %rdi
movl $0x3a, %esi
callq 0x4170
movq -0x2e0(%rbp), %rdi
movq -0x2d8(%rbp), %rcx
movq %rax, %rdx
leaq 0xd2f6b(%rip), %r8      # 0xeffca
leaq 0xd2f0f(%rip), %rax     # 0xeff75
cmpq $0x0, %rdx
cmovneq %rax, %r8
movl $0x66, %esi
leaq 0xd30ce(%rip), %rdx     # 0xf0148
movb $0x0, %al
callq 0x47e0
movq -0x248(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq 0xd3bcf(%rip), %rdx     # 0xf0c69
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x158b0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x1d0c6
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x2c4(%rbp)
movq -0x248(%rbp), %rax
leaq -0x240(%rbp), %rcx
cmpq %rcx, %rax
je 0x1d0e5
movq -0x248(%rbp), %rdi
callq 0x45a0
movl -0x2c4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
nopw (%rax,%rax)