// File: /workspace/github_c_makefile_star2_O2/BernardTatin[P]s7sh/s7.c
// Function: load_shared_object
static bool load_shared_object(s7_scheme *sc, const char *fname, s7_pointer env)
    {
        /* if fname ends in .so, try loading it as a c shared object
         *   (load "/home/bil/cl/m_j0.so" (inlet 'init_func 'init_m_j0))
         */
        s7_int fname_len;

        fname_len = safe_strlen(fname);
        if ((fname_len > 3) &&
                (local_strcmp((const char *)(fname + (fname_len - 3)), ".so")))
        {
            void *library;
            char *pwd_name;
            block_t *pname = NULL;

            if (fname[0] != '/')
            {
                block_t *searched;
                searched = search_load_path(sc, fname); /* returns NULL if *load-path* is nil, or if nothing matches */
                if (searched)
                {
                    if (((const char *)block_data(searched))[0] == '/')
                        pname = searched;
                    else
                    {
                        pname = full_filename(sc, (const char *)block_data(searched)); /* this is necessary, at least in Linux -- we can't blithely dlopen whatever is passed to us */
                        liberate(sc, searched);
                    }
                    pwd_name = (char *)block_data(pname);
                }
                else /* perhaps no *load-path* entries */
                {
                    pname = full_filename(sc, fname);
                    pwd_name = (char *)block_data(pname);
                }
            }
            /* else pname is NULL, so use fname */
            library = dlopen((pname) ? pwd_name : fname, RTLD_NOW);
            if (library)
            {
                if (env) /* look for 'init_func in env */
                {
                    s7_pointer init;

                    init = s7_let_ref(sc, env, make_symbol(sc, "init_func"));
                    if (is_symbol(init))
                    {
                        const char *init_name;
                        void *init_func;

                        init_name = symbol_name(init);
                        init_func = dlsym(library, init_name);
                        if (init_func)
                        {
                            typedef void *(*dl_func)(s7_scheme *sc);
                            ((dl_func)init_func)(sc);
                            if (pname) liberate(sc, pname);
                            return(true);
                        }
                        s7_warn(sc, 512, "loaded %s, but can't find %s (%s)?\n", fname, init_name, dlerror());
                        dlclose(library);
                    }
                    else s7_warn(sc, 512, "can't load %s: no init function\n", fname);
                    return(false);
                }
            }
            else s7_warn(sc, 512, "load %s failed: %s\n", (pname) ? pwd_name : fname, dlerror());
            if (pname) liberate(sc, pname);
        }
        return(false);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x8d06
cmpq $0x4, %rax
jl 0x2982e
leaq (%r14,%rax), %rdi
addq $-0x3, %rdi
leaq 0xb92e7(%rip), %rsi     # 0xe2a12
callq 0x70b07
testb %al, %al
je 0x2982e
cmpb $0x2f, (%r14)
jne 0x29743
xorl %r15d, %r15d
jmp 0x2978a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7748c
testq %rax, %rax
je 0x29779
movq %rax, %r15
movq (%rax), %rsi
cmpb $0x2f, (%rsi)
je 0x29787
movq %rbx, %rdi
callq 0x77558
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9439
movq %r13, %r15
jmp 0x29787
movq %rbx, %rdi
movq %r14, %rsi
callq 0x77558
movq %rax, %r15
movq (%r15), %rbp
testq %r15, %r15
cmoveq %r14, %rbp
pushq $0x2
popq %rsi
movq %rbp, %rdi
callq 0x8380
testq %rax, %rax
je 0x297fd
testq %r12, %r12
je 0x2981e
movq %rax, %r13
leaq 0xb9266(%rip), %rsi     # 0xe2a16
movq %rbx, %rdi
callq 0x94d4
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xa842
cmpb $0xa, (%rax)
jne 0x29841
movq 0x8(%rax), %rax
movq 0x10(%rax), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x85d0
testq %rax, %rax
je 0x2985e
movq %rbx, %rdi
callq *%rax
movb $0x1, %bpl
testq %r15, %r15
je 0x29830
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9439
jmp 0x29830
callq 0x8040
leaq 0xb925c(%rip), %rdx     # 0xe2a65
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %rbp, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0xd5c7
testq %r15, %r15
je 0x2982e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9439
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb91fc(%rip), %rdx     # 0xe2a44
xorl %ebp, %ebp
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0xd5c7
jmp 0x29830
callq 0x8040
leaq 0xb91b6(%rip), %rdx     # 0xe2a20
xorl %ebp, %ebp
movl $0x200, %esi            # imm = 0x200
movq %rbx, %rdi
movq %r14, %rcx
movq %r12, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0xd5c7
movq %r13, %rdi
callq 0x86d0
jmp 0x29830