// File: /workspace/github_c_makefile_star2_O1/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:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0x9090
movq %rax, %r13
movl $0x0, (%rax)
movq %r15, %rdi
movq %r14, %rsi
callq 0x95b0
testq %rax, %rax
je 0x10075
movq %rax, %r12
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xff76
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r14
movq $0x22, (%r14)
movq %rbx, %rdi
callq 0x10332
movq %rax, 0x28(%r14)
movq (%rax), %rax
movq %rax, 0x8(%r14)
movl $0x0, 0x4(%rax)
movq 0x8(%r14), %rax
movb $0x0, 0x2(%rax)
testq %r15, %r15
je 0xffd8
cmpb $0x0, (%r15)
je 0xffd8
movq $-0x1, %rcx
leaq 0x1(%rcx), %rax
cmpb $0x0, 0x1(%r15,%rcx)
movq %rax, %rcx
jne 0xffc7
jmp 0xffda
xorl %eax, %eax
movq 0x8(%r14), %rcx
movq %rax, 0x30(%rcx)
movq 0x8(%r14), %rax
movq 0x30(%rax), %r13
leaq 0x1(%r13), %rsi
movq %rbx, %rdi
callq 0xa305
movq 0x8(%r14), %rcx
movq %rax, 0x18(%rcx)
movq (%rax), %rcx
movq 0x8(%r14), %rdx
movq %rcx, 0x10(%rdx)
movq (%rax), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x93e0
movq 0x8(%r14), %rax
movq 0x10(%rax), %rax
movb $0x0, (%rax,%r13)
movq 0x8(%r14), %rax
movl $0x1, 0x20(%rax)
movq 0x8(%r14), %rax
movl $0x0, 0x24(%rax)
movq 0x8(%r14), %rax
movq %r12, 0x8(%rax)
movq 0x8(%r14), %rax
movb $0x1, (%rax)
movq $0x0, 0x20(%r14)
movq $0x100, 0x18(%r14)      # imm = 0x100
movq 0x878(%rbx), %r15
testq %r15, %r15
je 0x1009b
movq 0x18(%r15), %rax
movq %rax, 0x878(%rbx)
jmp 0x10153
movl (%r13), %edi
cmpl $0x16, %edi
jne 0x101c1
leaq 0x102f1c(%rip), %rsi    # 0x112fa5
leaq 0x102f26(%rip), %rdx    # 0x112fb6
movq %rbx, %rdi
movq %r14, %rcx
jmp 0x101d6
cmpq $0x0, 0x838(%rbx)
jne 0x100e1
movl $0x2800, %edi           # imm = 0x2800
callq 0x9480
movq %rax, 0x838(%rbx)
addq $0x28, %rax
movl $0xff, %ecx
movq %rax, -0x10(%rax)
movl $0x0, -0x20(%rax)
addq $0x28, %rax
decl %ecx
jne 0x100bf
movq $0x0, -0x10(%rax)
movl $0x0, -0x20(%rax)
movq 0x838(%rbx), %r15
movq 0x18(%r15), %rax
movq %rax, 0x838(%rbx)
movl $0x0, 0x8(%r15)
movl $0x100, %ecx            # imm = 0x100
movq 0x8c8(%rbx), %rax
addq %rcx, %rax
cmpq $0x10001, %rax          # imm = 0x10001
jb 0x10133
movl $0x10000, %edi          # imm = 0x10000
callq 0x9480
movq %rax, 0x8d0(%rbx)
movq $0x0, 0x8c8(%rbx)
movl $0x100, %eax            # imm = 0x100
movq 0x8d0(%rbx), %rcx
addq 0x8c8(%rbx), %rcx
movq %rax, 0x8c8(%rbx)
movq %rcx, (%r15)
movl $0x8, 0x8(%r15)
movq $0x100, 0x10(%r15)      # imm = 0x100
movq 0x8(%r14), %rax
movq %r15, 0x38(%rax)
movq (%r15), %rax
movq %rax, 0x10(%r14)
movq 0x8(%r14), %rax
leaq 0x13e24b(%rip), %rcx    # 0x14e3c0
movq %rcx, 0x48(%rax)
movq 0x750(%rbx), %rbx
movq 0x8(%rbx), %rsi
cmpq %rsi, 0x10(%rbx)
jne 0x101a1
leaq (%rsi,%rsi), %rax
movq %rax, 0x8(%rbx)
movq (%rbx), %rdi
shlq $0x4, %rsi
callq 0x9510
movq %rax, (%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x10(%rbx)
movq %r14, (%rax,%rcx,8)
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x96b0
leaq 0x102dd8(%rip), %rsi    # 0x112fa5
movq %rbx, %rdi
movq %rax, %rdx
movq %r15, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x101e1