// File: /workspace/github_c_makefile_star2_O1/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 0x69192
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1460(%rbx), %rax
movq 0x10(%rax), %rax
cmpq 0x10(%rax), %rsi
je 0x691e4
cmpb $0x26, (%rsi)
jb 0x691b8
movq %rbx, %rdi
xorl %edx, %edx
callq 0x41fac
testb %al, %al
je 0x691b8
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10305b
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x1032ab
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 0xf1ae
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1688(%rbx), %rdx
movq 0xf1162(%rip), %r8      # 0x15a330
movq %rbx, %rdi
movq %r14, %rcx
movl $0x2, %r9d
popq %rbx
popq %r14
popq %r15
jmp 0xf3da
cmpq $0x0, 0x8(%r15)
je 0x692de
movq 0x170(%rbx), %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10305b
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 0x180(%rbx), %esi
cmpl %esi, 0x184(%rbx)
jb 0x69270
addl %esi, %esi
movl %esi, 0x180(%rbx)
movq 0x178(%rbx), %rdi
shlq $0x3, %rsi
callq 0x9510
movq %rax, 0x178(%rbx)
leaq 0x170(%rbx), %rax
movq 0x170(%rbx), %rcx
movq 0x178(%rbx), %rdx
movl 0x184(%rbx), %esi
leal 0x1(%rsi), %edi
movl %edi, 0x184(%rbx)
movq %rcx, (%rdx,%rsi,8)
movq %r14, 0x170(%rbx)
movq 0x8(%rbx), %rcx
movq 0x50(%rbx), %rdx
movq %rcx, 0x8(%rdx)
movq 0x50(%rbx), %rcx
movq $0x1dc, 0x18(%rcx)      # imm = 0x1DC
movq 0x8(%rbx), %rcx
movq 0x50(%rbx), %rdx
leaq 0x20(%rdx), %rsi
movq %rsi, 0x50(%rbx)
movq %rcx, 0x28(%rdx)
movq 0x50(%rbx), %rcx
movq $0x190, 0x18(%rcx)      # imm = 0x190
addq $0x20, 0x50(%rbx)
jmp 0x692e5
leaq 0xe547b(%rip), %rax     # 0x14e760
movq (%rax), %rax
popq %rbx
popq %r14
popq %r15
retq