// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: g_format
static s7_pointer g_format(s7_scheme *sc, s7_pointer args)
    {
#define H_format "(format out str . args) substitutes args into str sending the result to out. Most of \
        s7's format directives are taken from CL: ~% = newline, ~& = newline if the preceding output character was \
        no a newline, ~~ = ~, ~<newline> trims white space, ~* skips an argument, ~^ exits {} iteration if the arg list is exhausted, \
        ~nT spaces over to column n, ~A prints a representation of any object, ~S is the same, but puts strings in double quotes, \
        ~C prints a character, numbers are handled by ~F, ~E, ~G, ~B, ~O, ~D, and ~X with preceding numbers giving \
        spacing (and spacing character) and precision.  ~{ starts an embedded format directive which is ended by ~}: \n\
        \n\
        >(format #f \"dashed: ~{~A~^-~}\" '(1 2 3))\n\
        \"dashed: 1-2-3\"\n\
        \n\
        ~P inserts \"s\" if the current it is not 1 or 1.0 (use ~@P for \"ies\" or \"y\").\n\
        ~B is number->string in base 2, ~O in base 8, ~D base 10, ~X base 16,\n\
        ~E: (format #f \"~E\" 100.1) -&gt; \"1.001000e+02\" (%e in C)\n\
        ~F: (format #f \"~F\" 100.1) -&gt; \"100.100000\"   (%f in C)\n\
        ~G: (format #f \"~G\" 100.1) -&gt; \"100.1\"        (%g in C)\n\
        \n\
        If the 'out' it is not an output port, the resultant string is returned.  If it \
        is #t, the string is also sent to the current-output-port."

#define Q_format s7_make_circular_signature(sc, 2, 3, s7_make_signature(sc, 2, sc->is_string_symbol, sc->not_symbol), s7_make_signature(sc, 3, sc->is_output_port_symbol, sc->is_boolean_symbol, sc->is_null_symbol), sc->T)

        s7_pointer pt, str;
        sc->format_column = 0;
        pt = car(args);
        if (is_null(pt))
        {
            pt = sc->output_port;                  /* () -> (current-output-port) */
            if (pt == sc->F)                       /*   otherwise () -> #f so we get a returned string, which is confusing */
                return(pt);                          /*   but this means some error checks are skipped? */
        }

        if (!((s7_is_boolean(pt)) ||               /* #f or #t */
                    ((is_output_port(pt)) &&             /* (current-output-port) or call-with-open-file arg, etc */
                     (!port_is_closed(pt)))))
            return(method_or_bust_with_type(sc, pt, sc->format_symbol, args, an_output_port_string, 1));

        str = cadr(args);
        if (!is_string(str))
            return(method_or_bust(sc, str, sc->format_symbol, args, T_STRING, 2));

        return(format_to_port_1(sc, (pt == sc->T) ? sc->output_port : pt,
                    string_value(str), cddr(args), NULL, !is_output_port(pt), true, string_length(str), str));
    }

// Assembly:
movq %rsi, %rcx
movl $0x0, 0x238(%rdi)
movq 0x8(%rsi), %rsi
cmpq 0x110(%rdi), %rsi
jne 0x3a661
movq 0x188(%rdi), %rsi
cmpq 0x120(%rdi), %rsi
je 0x3a6f8
movzbl (%rsi), %r8d
cmpl $0x7, %r8d
je 0x3a694
cmpl $0x22, %r8d
jne 0x3a67b
movq 0x8(%rsi), %rax
cmpb $0x1, 0x2(%rax)
jne 0x3a694
movq 0xf20(%rdi), %rdx
movq 0x11fc3f(%rip), %r8     # 0x15a2c8
movl $0x1, %r9d
jmp 0xf3da
movq 0x10(%rcx), %r9
movq 0x8(%r9), %rax
cmpb $0x13, (%rax)
jne 0x3a6dd
cmpq 0x118(%rdi), %rsi
jne 0x3a6b1
movq 0x188(%rdi), %rsi
pushq %rax
movq 0x10(%rax), %rdx
movq 0x10(%r9), %rcx
xorl %r9d, %r9d
cmpb $0x22, %r8b
setne %r9b
subq $0x8, %rsp
xorl %r8d, %r8d
pushq %rax
pushq 0x8(%rax)
pushq $0x1
callq 0x9d135
addq $0x20, %rsp
popq %rcx
retq
movq 0xf20(%rdi), %rdx
movq %rax, %rsi
movl $0x13, %r8d
movl $0x2, %r9d
jmp 0xf1ae
movq %rsi, %rax
retq