// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rsi), %r15
cmpb $0x13, (%r15)
jne 0x4feb7
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1460(%rbx), %rax
movq 0x10(%rax), %rax
cmpq 0x10(%rax), %rsi
je 0x4fedf
cmpb $0x26, (%rsi)
jb 0x4ff94
movq %rbx, %rdi
xorl %edx, %edx
callq 0x32378
testb %al, %al
je 0x4ff8c
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc73c7
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xc7520
movq 0x1688(%rbx), %rdx
pushq $0x13
popq %r8
pushq $0x1
popq %r9
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xcd70
cmpq $0x0, 0x8(%r15)
je 0x4ffbc
leaq 0x170(%rbx), %r14
movq 0x170(%rbx), %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc73c7
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 %r12, 0x10(%rax)
movq 0x50(%rbx), %rax
movq $0x1ee, 0x18(%rax)      # imm = 0x1EE
addq $0x20, 0x50(%rbx)
movq 0x170(%rbx), %rsi
movq %rbx, %rdi
callq 0xe138
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
movq %rax, 0x8(%rcx)
movq 0x50(%rbx), %rax
movq $0x1dc, 0x18(%rax)      # imm = 0x1DC
movq 0x8(%rbx), %rax
movq 0x50(%rbx), %rcx
leaq 0x20(%rcx), %rdx
movq %rdx, 0x50(%rbx)
movq %rax, 0x28(%rcx)
movq 0x50(%rbx), %rax
movq $0x190, 0x18(%rax)      # imm = 0x190
addq $0x20, 0x50(%rbx)
jmp 0x4ffc3
movq 0x10(%r14), %rax
movq 0x8(%rax), %rsi
movq 0x1688(%rbx), %rdx
movq 0xd138e(%rip), %r8      # 0x121330
pushq $0x2
popq %r9
movq %rbx, %rdi
movq %r14, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xcf9a
leaq 0xc579d(%rip), %r14     # 0x115760
movq (%r14), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq