// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: format_chooser
static s7_pointer format_chooser(s7_scheme *sc, s7_pointer f, int32_t args, s7_pointer expr, bool ops)
                {
                    if (args > 1)
                    {
                        s7_pointer port, str_arg;
                        port = cadr(expr);
                        str_arg = caddr(expr);
                        if (is_string(str_arg))
                        {
                            if ((ops) && ((args == 2) || (args == 3)))
                            {
                                s7_int len;
                                char *orig;
                                const char *p;

                                orig = string_value(str_arg);
                                p = strchr((const char *)orig, (int)'~');
                                if (!p)
                                {
                                    if (args == 2)
                                        return(sc->format_just_control_string);
                                    return(f);
                                }

                                len = string_length(str_arg);
                                if ((args == 2) &&
                                        (len > 1) &&
                                        (orig[len - 1] == '%') &&
                                        ((p - orig) == len - 2))
                                {
                                    orig[len - 2] = '\n';
                                    orig[len - 1] = '\0';
                                    string_length(str_arg) = len - 1;
                                    return(sc->format_just_control_string);
                                }

                                if ((args == 3) &&
                                        (len == 2) &&
                                        (port == sc->F) &&
                                        (orig[0] == '~') &&
                                        ((orig[1] == 'A') || (orig[1] == 'a')))
                                    return(sc->format_as_objstr);
                            }

                            /* this used to worry about optimized expr and particular cases -- why? I can't find a broken case */
                            if (!is_columnizing(string_value(str_arg)))
                                return(sc->format_allg_no_column);
                        }
                        if (port == sc->F)
                            return(sc->format_f);
                    }
                    return(f);
                }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpl $0x2, %edx
jl 0x10c720
movq %rdi, %r14
movq 0x10(%rcx), %rax
movq 0x8(%rax), %r12
movq 0x10(%rax), %rax
movq 0x8(%rax), %r13
cmpb $0x13, (%r13)
jne 0x10c706
testb %r8b, %r8b
je 0x10c5e6
movl %edx, %ebp
movl %edx, %ecx
andl $0x7ffffffe, %ecx       # imm = 0x7FFFFFFE
cmpl $0x2, %ecx
jne 0x10c5e6
movq 0x10(%r13), %r15
movq %r15, %rdi
movl $0x7e, %esi
callq 0x91d0
testq %rax, %rax
je 0x10c5c7
movq 0x8(%r13), %rdx
cmpl $0x2, %ebp
jne 0x10c597
cmpq $0x2, %rdx
jl 0x10c597
cmpb $0x25, -0x1(%r15,%rdx)
jne 0x10c597
subq %r15, %rax
leaq -0x2(%rdx), %rcx
cmpq %rcx, %rax
jne 0x10c597
decq %rdx
movb $0xa, (%r15,%rcx)
movb $0x0, (%r15,%rdx)
movq %rdx, 0x8(%r13)
movl $0x1bc0, %eax           # imm = 0x1BC0
jmp 0x10c5d1
movb $0x1, %cl
cmpl $0x3, %ebp
jne 0x10c5c5
cmpq $0x2, %rdx
jne 0x10c5c5
cmpq 0x120(%r14), %r12
jne 0x10c5c5
cmpb $0x7e, (%r15)
jne 0x10c5c5
movzbl 0x1(%r15), %edx
movl $0x1bc8, %eax           # imm = 0x1BC8
orl $0x20, %edx
cmpl $0x61, %edx
je 0x10c5d1
jmp 0x10c5de
movl $0x1bc0, %eax           # imm = 0x1BC0
cmpl $0x2, %ebp
jne 0x10c5d9
movq (%r14,%rax), %rax
xorl %ecx, %ecx
jmp 0x10c5de
xorl %ecx, %ecx
movq %rbx, %rax
testb %cl, %cl
je 0x10c71a
movq 0x10(%r13), %rdx
movb (%rdx), %dil
movl $0x1bb8, %ecx           # imm = 0x1BB8
testb %dil, %dil
je 0x10c716
cmpb $0x7e, %dil
jne 0x10c620
movb 0x1(%rdx), %dil
addq $0x2, %rdx
movl %edi, %r8d
andb $-0x21, %r8b
cmpb $0x54, %r8b
jne 0x10c628
xorl %edi, %edi
movb $0x1, %sil
jmp 0x10c6ed
incq %rdx
jmp 0x10c6f2
movzbl %dil, %r9d
testl %r9d, %r9d
je 0x10c6e9
cmpl $0x2c, %r9d
je 0x10c658
leal -0x30(%rdi), %r9d
cmpb $0xa, %r9b
setae %r9b
cmpb $0x4e, %r8b
setne %r10b
testb %r10b, %r9b
jne 0x10c6e4
leal -0x30(%rdi), %r9d
cmpb $0xa, %r9b
setae %r9b
cmpb $0x4e, %r8b
setne %r10b
testb %r10b, %r9b
jne 0x10c697
movb (%rdx), %dil
incq %rdx
leal -0x30(%rdi), %r8d
cmpb $0xa, %r8b
setb %r9b
movl %edi, %r8d
andb $-0x21, %r8b
cmpb $0x4e, %r8b
sete %r10b
orb %r9b, %r10b
jne 0x10c671
cmpb $0x54, %r8b
je 0x10c616
testb %dil, %dil
je 0x10c6e9
movzbl %dil, %edi
cmpl $0x2c, %edi
jne 0x10c6e4
movb (%rdx), %dil
incq %rdx
leal -0x30(%rdi), %r8d
cmpb $0xa, %r8b
setb %r9b
movl %edi, %r8d
andb $-0x21, %r8b
cmpb $0x4e, %r8b
sete %r10b
orb %r9b, %r10b
jne 0x10c6af
cmpb $0x54, %r8b
je 0x10c616
testb %dil, %dil
je 0x10c6e9
movb $0x1, %dil
jmp 0x10c6ed
xorl %esi, %esi
xorl %edi, %edi
testb %dil, %dil
je 0x10c700
movb (%rdx), %dil
testb %dil, %dil
jne 0x10c5fb
jmp 0x10c716
testb $0x1, %sil
je 0x10c716
movb $0x1, %cl
cmpq 0x120(%r14), %r12
jne 0x10c71c
movl $0x1bb0, %ecx           # imm = 0x1BB0
movq (%r14,%rcx), %rax
xorl %ecx, %ecx
testb %cl, %cl
je 0x10c723
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq