// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_with_output_to_file
static s7_pointer g_with_output_to_file(s7_scheme *sc, s7_pointer args)
    {
#define H_with_output_to_file "(with-output-to-file filename thunk) opens filename as the temporary current-output-port and calls thunk"
#define Q_with_output_to_file sc->pl_sf
        s7_pointer old_output_port, file, proc;

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

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

        if ((is_continuation(proc)) || (is_goto(proc)))
            return(wrong_type_argument_with_type(sc, sc->with_output_to_file_symbol, 1, proc, a_normal_procedure_string));

        old_output_port = sc->output_port;
        sc->output_port = s7_open_output_file(sc, string_value(file), "w");
        push_stack(sc, OP_UNWIND_OUTPUT, old_output_port, sc->output_port);
        push_stack(sc, OP_APPLY, sc->nil, proc);
        return(sc->F);
    }

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x13, %eax
je 0x6f15f
movq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x58(%rsp), %rax
movq 0x1690(%rax), %rdx
movq 0x50(%rsp), %rcx
movl $0x13, %r8d
movl $0x1, %r9d
callq 0x13c50
movq %rax, 0x60(%rsp)
jmp 0x6f401
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x26, %eax
jl 0x6f195
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x3cbf0
testb $0x1, %al
jne 0x6f1cc
movq 0x58(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rax
movq 0x1690(%rax), %rdx
movq 0x50(%rsp), %rcx
movq 0x1b2cd1(%rip), %r8     # 0x221e88
movl $0x2, %r9d
callq 0x14130
movq %rax, 0x60(%rsp)
jmp 0x6f401
movq 0x38(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x25, %eax
je 0x6f1ea
movq 0x38(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x26, %eax
jne 0x6f2ee
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rax
movq 0x1690(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq $0x1, 0x30(%rsp)
movq 0x30(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x6f239
movq 0x30(%rsp), %rcx
leaq 0x1a7251(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
jmp 0x6f2af
jmp 0x6f23b
movq 0x58(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x58(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x6f25f
movq 0x58(%rsp), %rdi
callq 0xc670
movq 0x58(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq $0xb, (%rax)
movq 0x30(%rsp), %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq (%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq 0x58(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x1b5ed9(%rip), %r9     # 0x2251b8
callq 0xc560
movq %rax, 0x60(%rsp)
jmp 0x6f401
movq 0x58(%rsp), %rax
movq 0x188(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x58(%rsp), %rdi
movq 0x40(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x184ac1(%rip), %rdx    # 0x1f3dd5
callq 0x15250
movq %rax, %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x188(%rax)
movq 0x58(%rsp), %rax
movq 0x188(%rax), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, (%rax)
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x10(%rax)
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movl $0x1ef, %ecx            # imm = 0x1EF
movq %rcx, 0x18(%rax)
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x50(%rax)
jmp 0x6f38d
movq 0x38(%rsp), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, (%rax)
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x58(%rsp), %rax
movq 0x110(%rax), %rcx
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movq %rcx, 0x10(%rax)
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rax
movl $0x198, %ecx            # imm = 0x198
movq %rcx, 0x18(%rax)
movq 0x58(%rsp), %rax
movq 0x50(%rax), %rcx
addq $0x20, %rcx
movq %rcx, 0x50(%rax)
movq 0x58(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
addq $0x68, %rsp
retq
nopl (%rax,%rax)