// File: /workspace/github_c_makefile_star2_O3/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, %r14
cmpl $0x2, %edx
jl 0x1032be
movq %rdi, %rbx
movq 0x10(%rcx), %rax
movq 0x8(%rax), %r12
movq 0x10(%rax), %rax
movq 0x8(%rax), %r13
cmpb $0x13, (%r13)
jne 0x1032ac
testb %r8b, %r8b
je 0x1031c6
movl %edx, %ebp
movl %edx, %eax
andl $0x7ffffffe, %eax       # imm = 0x7FFFFFFE
cmpl $0x2, %eax
jne 0x1031c6
movq 0x10(%r13), %r15
movq %r15, %rdi
movl $0x7e, %esi
callq 0x81d0
testq %rax, %rax
je 0x103183
movq 0x8(%r13), %rcx
cmpl $0x2, %ebp
jne 0x103196
cmpq $0x2, %rcx
jl 0x103196
cmpb $0x25, -0x1(%r15,%rcx)
jne 0x1031c6
subq %r15, %rax
leaq -0x2(%rcx), %rdx
cmpq %rdx, %rax
jne 0x1031c6
decq %rcx
movb $0xa, (%r15,%rax)
movb $0x0, (%r15,%rcx)
movq %rcx, 0x8(%r13)
movl $0x1bc0, %eax           # imm = 0x1BC0
jmp 0x1032ba
movl $0x1bc0, %eax           # imm = 0x1BC0
cmpl $0x2, %ebp
je 0x1032ba
jmp 0x1032be
cmpl $0x3, %ebp
jne 0x1031c6
cmpq $0x2, %rcx
jne 0x1031c6
cmpq 0x120(%rbx), %r12
jne 0x1031c6
cmpb $0x7e, (%r15)
jne 0x1031c6
movzbl 0x1(%r15), %ecx
movl $0x1bc8, %eax           # imm = 0x1BC8
orl $0x20, %ecx
cmpl $0x61, %ecx
je 0x1032ba
movq 0x10(%r13), %rcx
movb (%rcx), %dl
movl $0x1bb8, %eax           # imm = 0x1BB8
testb %dl, %dl
je 0x1032ba
cmpb $0x7e, %dl
jne 0x1032a2
movb 0x1(%rcx), %dl
movl %edx, %esi
andb $-0x21, %sil
cmpb $0x54, %sil
je 0x1032ac
addq $0x2, %rcx
movzbl %dl, %r8d
movb $-0x4, %dil
cmpl $0x2c, %r8d
je 0x103227
testl %r8d, %r8d
je 0x1032ba
leal -0x30(%rdx), %edi
cmpb $0xa, %dil
setae %r8b
cmpb $0x4e, %sil
setne %r9b
testb %r9b, %r8b
jne 0x1032a5
cmpb $0xa, %dil
setae %dil
cmpb $0x4e, %sil
setne %r8b
testb %dil, %r8b
jne 0x10325f
movb (%rcx), %dl
incq %rcx
leal -0x30(%rdx), %esi
cmpb $0xa, %sil
setb %dil
movl %edx, %esi
andb $-0x21, %sil
cmpb $0x4e, %sil
sete %r8b
orb %dil, %r8b
jne 0x10323c
cmpb $0x54, %sil
je 0x1032ac
cmpb $0x2c, %dl
je 0x103273
movzbl %dl, %edx
testl %edx, %edx
jne 0x1032a5
jmp 0x1032ba
movb (%rcx), %dl
incq %rcx
leal -0x30(%rdx), %esi
cmpb $0xa, %sil
setb %dil
movl %edx, %esi
andb $-0x21, %sil
cmpb $0x4e, %sil
sete %r8b
orb %dil, %r8b
jne 0x103273
cmpb $0x54, %sil
je 0x1032ac
testb %dl, %dl
jne 0x1032a5
jmp 0x1032ba
incq %rcx
movb (%rcx), %dl
jmp 0x1031d1
cmpq 0x120(%rbx), %r12
jne 0x1032be
movl $0x1bb0, %eax           # imm = 0x1BB0
movq (%rbx,%rax), %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq