// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq 0x90(%rsp), %rdi
callq 0xa430
movq %rax, 0x80(%rsp)
cmpq $0x3, 0x80(%rsp)
jle 0x27dab
movq 0x90(%rsp), %rdi
movq 0x80(%rsp), %rax
subq $0x3, %rax
addq %rax, %rdi
leaq 0x1c6a61(%rip), %rsi    # 0x1ee532
callq 0xc0a00
testb $0x1, %al
jne 0x27adf
jmp 0x27dab
movq $0x0, 0x68(%rsp)
movq 0x90(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x27b9e
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xcf860
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x60(%rsp)
je 0x27b75
movq 0x60(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
jne 0x27b3a
movq 0x60(%rsp), %rax
movq %rax, 0x68(%rsp)
jmp 0x27b66
movq 0x98(%rsp), %rdi
movq 0x60(%rsp), %rax
movq (%rax), %rsi
callq 0xcf9c0
movq %rax, 0x68(%rsp)
movq 0x98(%rsp), %rdi
movq 0x60(%rsp), %rsi
callq 0xb230
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x70(%rsp)
jmp 0x27b9c
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xcf9c0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x70(%rsp)
jmp 0x27b9e
cmpq $0x0, 0x68(%rsp)
je 0x27bb2
movq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x27bbf
movq 0x90(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movl $0x2, %esi
callq 0x9380
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0x27d34
cmpq $0x0, 0x88(%rsp)
je 0x27d32
movq 0x98(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rdi
leaq 0x1c691f(%rip), %rsi    # 0x1ee536
callq 0xb400
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0xe490
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
jne 0x27d02
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x78(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0x95d0
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0x27ca8
movq 0x48(%rsp), %rax
movq 0x98(%rsp), %rdi
callq *%rax
cmpq $0x0, 0x68(%rsp)
je 0x27c9b
movq 0x98(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0xb230
movb $0x1, 0xa7(%rsp)
jmp 0x27db3
movq 0x98(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
callq 0x9040
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
movq %rax, %r9
movl $0x200, %esi            # imm = 0x200
leaq 0x1c6851(%rip), %rdx    # 0x1ee540
movb $0x0, %al
callq 0x14df0
movq 0x78(%rsp), %rdi
callq 0x96d0
jmp 0x27d25
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x1c6846(%rip), %rdx    # 0x1ee564
movb $0x0, %al
callq 0x14df0
movb $0x0, 0xa7(%rsp)
jmp 0x27db3
jmp 0x27d8f
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x27d55
movq 0x70(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x27d62
movq 0x90(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
callq 0x9040
movq 0x10(%rsp), %rdi
movq (%rsp), %rcx
movq %rax, %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x1c67fd(%rip), %rdx    # 0x1ee585
movb $0x0, %al
callq 0x14df0
cmpq $0x0, 0x68(%rsp)
je 0x27da9
movq 0x98(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0xb230
jmp 0x27dab
movb $0x0, 0xa7(%rsp)
movb 0xa7(%rsp), %al
andb $0x1, %al
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)