// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: open_input_file_1
static s7_pointer open_input_file_1(s7_scheme *sc, const char *name, const char *mode, const char *caller)
    {
        FILE *fp;
        /* see if we can open this file before allocating a port */

        if (is_directory(name))
            return(file_error(sc, caller, "file is a directory:", name));

        errno = 0;
        fp = fopen(name, mode);
        if (!fp)
        {
#if (!MS_WINDOWS)
            if (errno == EINVAL)
                return(file_error(sc, caller, "invalid mode", mode));
#if WITH_GCC
            /* catch one special case, "~/..." */
            if ((name[0] == '~') &&
                    (name[1] == '/'))
            {
                char *home;
                home = getenv("HOME");
                if (home)
                {
                    block_t *b;
                    char *filename;
                    s7_int len;
                    len = safe_strlen(name) + safe_strlen(home) + 1;
                    b = mallocate(sc, len);
                    filename = (char *)block_data(b);
                    filename[0] = '\0';
                    catstrs(filename, len, home, (char *)(name + 1), NULL);
                    fp = fopen(filename, "r");
                    liberate(sc, b);
                    if (fp)
                        return(make_input_file(sc, name, fp));
                }
            }
#endif
#endif
            return(file_error(sc, caller, strerror(errno), name));
        }
        return(make_input_file(sc, name, fp));
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x93d0
testl %eax, %eax
js 0xfdbe
movl $0xf000, %eax           # imm = 0xF000
andl 0x30(%rsp), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0xfdbe
leaq 0x10f961(%rip), %rdx    # 0x11f700
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rcx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x101e1
callq 0x9090
movq %rax, %r12
movl $0x0, (%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x95b0
testq %rax, %rax
je 0xfe07
leaq 0x114ec4(%rip), %r8     # 0x124ca7
movl $0x4c4b40, %ecx         # imm = 0x4C4B40
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x96848
cmpl $0x16, (%r12)
jne 0xfe20
leaq 0x1031a1(%rip), %rdx    # 0x112fb6
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rcx
jmp 0xfda8
cmpb $0x7e, (%rbx)
jne 0xfefe
cmpb $0x2f, 0x1(%rbx)
jne 0xfefe
leaq 0x10f8db(%rip), %rdi    # 0x11f715
callq 0x9030
testq %rax, %rax
je 0xfe7b
movq %rax, %r13
leaq 0x1(%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %eax, %eax
cmpb $0x0, (%rbx,%rax)
leaq 0x1(%rax), %rax
jne 0xfe52
cmpb $0x0, (%r13)
je 0xfe80
movq $-0x1, %rcx
leaq 0x1(%rcx), %rbp
cmpb $0x0, 0x1(%r13,%rcx)
movq %rbp, %rcx
jne 0xfe6a
jmp 0xfe82
movb $0x1, %bpl
jmp 0xfef9
xorl %ebp, %ebp
addq %rax, %rbp
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa305
movq %rax, 0x8(%rsp)
movq (%rax), %rdi
movq %rdi, (%rsp)
movb $0x0, (%rdi)
movq %rbp, %rsi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
xorl %r8d, %r8d
xorl %eax, %eax
callq 0xa4d7
leaq 0x11357c(%rip), %rsi    # 0x123437
movq (%rsp), %rdi
callq 0x95b0
movq %rax, %r13
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0xa9a3
testq %r13, %r13
sete %bpl
je 0xfef9
leaq 0x114dc3(%rip), %r8     # 0x124ca7
movl $0x4c4b40, %ecx         # imm = 0x4C4B40
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x96848
jmp 0xfef9
testb %bpl, %bpl
je 0xff15
movl (%r12), %edi
callq 0x96b0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
jmp 0xfda5
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq