// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: s7_open_output_file
s7_pointer s7_open_output_file(s7_scheme *sc, const char *name, const char *mode)
    {
        FILE *fp;
        s7_pointer x;
        block_t *block, *b;
        /* see if we can open this file before allocating a port */

        errno = 0;
        fp = fopen(name, mode);
        if (!fp)
        {
#if (!MS_WINDOWS)
            if (errno == EINVAL)
                return(file_error(sc, "open-output-file", "invalid mode", mode));
#endif
            return(file_error(sc, "open-output-file", strerror(errno), name));
        }

        new_cell(sc, x, T_OUTPUT_PORT);
        b = mallocate_port(sc);
        port_block(x) = b;
        port_port(x) = (port_t *)block_data(b);
        port_type(x) = FILE_PORT;
        port_set_closed(x, false);
        port_filename_length(x) = safe_strlen(name);
        port_set_filename(sc, x, name, port_filename_length(x));
        port_line_number(x) = 1;
        port_file_number(x) = 0;
        port_file(x) = fp;
        port_needs_free(x) = true;  /* hmm -- I think these are freed via s7_close_output_port -> close_output_port */
        port_position(x) = 0;
        port_data_size(x) = PORT_DATA_SIZE;
        block = mallocate(sc, PORT_DATA_SIZE);
        port_data_block(x) = block;
        port_data(x) = (uint8_t *)(block_data(block));
        port_port(x)->pf = &output_file_functions;
        add_output_port(sc, x);
        return(x);
    }

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
callq 0x9090
movl $0x0, (%rax)
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x95b0
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x152f2
callq 0x9090
cmpl $0x16, (%rax)
jne 0x152bb
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rcx
leaq 0x1cc8f8(%rip), %rsi    # 0x1e1b9d
leaq 0x1cc902(%rip), %rdx    # 0x1e1bae
callq 0x154a0
movq %rax, 0x40(%rsp)
jmp 0x15490
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
callq 0x9090
movl (%rax), %edi
callq 0x96b0
movq (%rsp), %rdi
movq %rax, %rdx
movq 0x30(%rsp), %rcx
leaq 0x1cc8ba(%rip), %rsi    # 0x1e1b9d
callq 0x154a0
movq %rax, 0x40(%rsp)
jmp 0x15490
jmp 0x152f4
movq 0x38(%rsp), %rax
movq 0x90(%rax), %rax
movq 0x38(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x15318
movq 0x38(%rsp), %rdi
callq 0xc670
movq 0x38(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq $0x22, (%rax)
movq 0x38(%rsp), %rdi
callq 0x15570
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x4(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movb $0x0, 0x2(%rax)
movq 0x30(%rsp), %rdi
callq 0xa430
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x30(%rax)
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x30(%rax), %rcx
callq 0x15600
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl $0x1, 0x20(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movl $0x0, 0x24(%rax)
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movb $0x1, (%rax)
movq 0x18(%rsp), %rax
movq $0x0, 0x20(%rax)
movq 0x18(%rsp), %rax
movq $0x100, 0x18(%rax)      # imm = 0x100
movq 0x38(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0xaa80
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x38(%rax)
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rax
leaq 0x1fff54(%rip), %rcx    # 0x2153c0
movq %rcx, 0x48(%rax)
movq 0x38(%rsp), %rax
movq 0x750(%rax), %rdi
movq 0x18(%rsp), %rsi
callq 0x11230
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw (%rax,%rax)