// File: /workspace/github_c_makefile_star2_O3/BernardTatin[P]s7sh/s7.c
// Function: g_with_input_from_string
static s7_pointer g_with_input_from_string(s7_scheme *sc, s7_pointer args)
    {
#define H_with_input_from_string "(with-input-from-string str thunk) opens str as the temporary current-input-port and calls thunk"
#define Q_with_input_from_string sc->pl_sf
        s7_pointer str;

        str = car(args);
        if (!is_string(str))
            return(method_or_bust(sc, str, sc->with_input_from_string_symbol, args, T_STRING, 1));

        if (cadr(args) == slot_value(global_slot(sc->read_symbol)))
        {
            s7_pointer old_input_port;
            if (string_length(str) == 0)
                return(eof_object);

            old_input_port = sc->input_port;
            sc->input_port = open_and_protect_input_string(sc, str);
            port_original_input_string(sc->input_port) = str;
            push_stack(sc, OP_UNWIND_INPUT, old_input_port, sc->input_port);

            push_input_port(sc, sc->input_port);
            push_stack_op_let(sc, OP_READ_DONE);
            push_stack_op_let(sc, OP_READ_INTERNAL);
            return(sc->input_port);
        }

        if (!is_thunk(sc, cadr(args)))
            return(method_or_bust_with_type(sc, cadr(args), sc->with_input_from_string_symbol, args, a_thunk_string, 2));

        /* since the arguments are evaluated before we get here, we can get some confusing situations:
         *   (with-input-from-string "#x2.1" (read))
         *     (read) -> whatever it can get from the current input port!
         *     ";with-input-from-string argument 2, #<eof>, is untyped but should be a thunk"
         *   (with-input-from-string "" (read-line)) -> hangs awaiting stdin input
         */
        return(with_input(sc, open_and_protect_input_string(sc, str), args));
    }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rsi), %r15
cmpb $0x13, (%r15)
jne 0x64126
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1460(%rbx), %rax
movq 0x10(%rax), %rax
cmpq 0x10(%rax), %rsi
je 0x6414c
cmpb $0x26, (%rsi)
jb 0x641cf
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3f86f
testb %al, %al
je 0x641c7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfa2bb
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0xfa500
movq 0x1688(%rbx), %rdx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
movl $0x13, %r8d
movl $0x1, %r9d
popq %rbx
popq %r14
popq %r15
jmp 0xe42d
cmpq $0x0, 0x8(%r15)
je 0x641f3
movq 0x170(%rbx), %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfa2bb
movq %rax, 0x170(%rbx)
movq 0x8(%rax), %rcx
movq %r15, 0x40(%rcx)
movq 0x50(%rbx), %rcx
movq %rax, (%rcx)
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x50(%rbx), %rax
movq %r14, 0x10(%rax)
movq 0x50(%rbx), %rax
movq $0x1ee, 0x18(%rax)      # imm = 0x1EE
addq $0x20, 0x50(%rbx)
movq 0x170(%rbx), %r14
movl 0x184(%rbx), %edx
movl 0x180(%rbx), %esi
cmpl %esi, %edx
jae 0x641ff
movq 0x178(%rbx), %rax
movq %r14, %rsi
jmp 0x6422b
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1688(%rbx), %rdx
movq 0xee153(%rip), %r8      # 0x152330
movq %rbx, %rdi
movq %r14, %rcx
movl $0x2, %r9d
popq %rbx
popq %r14
popq %r15
jmp 0xe659
leaq 0xe2566(%rip), %rcx     # 0x146760
jmp 0x64285
addl %esi, %esi
movl %esi, 0x180(%rbx)
movq 0x178(%rbx), %rdi
shlq $0x3, %rsi
callq 0x8510
movq %rax, 0x178(%rbx)
movl 0x184(%rbx), %edx
movq 0x170(%rbx), %rsi
leaq 0x170(%rbx), %rcx
leal 0x1(%rdx), %edi
movl %edi, 0x184(%rbx)
movl %edx, %edx
movq %rsi, (%rax,%rdx,8)
movq %r14, 0x170(%rbx)
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq 0x50(%rbx), %rax
movq $0x1dc, 0x18(%rax)      # imm = 0x1DC
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rdx
leaq 0x20(%rdx), %rsi
movq %rsi, 0x50(%rbx)
movq %rax, 0x28(%rdx)
movq 0x50(%rbx), %rax
movq $0x190, 0x18(%rax)      # imm = 0x190
addq $0x20, 0x50(%rbx)
movq (%rcx), %rax
popq %rbx
popq %r14
popq %r15
retq