// File: /workspace/github_c_makefile_star2_O0/BernardTatin[P]s7sh/s7.c
// Function: g_char_position
static s7_pointer g_char_position(s7_scheme *sc, s7_pointer args)
    {
#define H_char_position "(char-position char-or-str str (start 0)) returns the position of the first occurrence of char in str, or #f"
#define Q_char_position s7_make_signature(sc, 4, s7_make_signature(sc, 2, sc->is_integer_symbol, sc->not_symbol), s7_make_signature(sc, 2, sc->is_char_symbol, sc->is_string_symbol), sc->is_string_symbol, sc->is_integer_symbol)

        const char *porig, *pset;
        s7_int start, pos, len; /* not "int" because start arg might be most-negative-fixnum */
        s7_pointer arg1, arg2;

        arg1 = car(args);
        if ((!s7_is_character(arg1)) &&
                (!is_string(arg1)))
            return(method_or_bust(sc, arg1, sc->char_position_symbol, args, T_CHARACTER, 1));

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

        if (is_pair(cddr(args)))
        {
            s7_pointer arg3;
            arg3 = caddr(args);
            if (!s7_is_integer(arg3))
                return(method_or_bust(sc, arg3, sc->char_position_symbol, args, T_INTEGER, 3));
            start = s7_integer(arg3);
            if (start < 0)
                return(wrong_type_argument_with_type(sc, sc->char_position_symbol, 3, arg3, a_non_negative_integer_string));
        }
        else start = 0;

        porig = string_value(arg2);
        len = string_length(arg2);
        if (start >= len) return(sc->F);

        if (s7_is_character(arg1))
        {
            char c;
            const char *p;
            c = character(arg1);
            p = strchr((const char *)(porig + start), (int)c); /* use strchrnul in Gnu C to catch embedded null case */
            if (p)
                return(make_integer(sc, p - porig));
            return(sc->F);
        }

        if (string_length(arg1) == 0)
            return(sc->F);
        pset = string_value(arg1);

        pos = strcspn((const char *)(porig + start), (const char *)pset);
        if ((pos + start) < len)
            return(make_integer(sc, pos + start));

        /* if the string has an embedded null, we can get erroneous results here --
         *   perhaps check for null at pos+start?  What about a searched-for string that also has embedded nulls?
         */
        return(sc->F);
    }

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x14430
testb $0x1, %al
jne 0x8a9e1
movq 0xb0(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x13, %eax
je 0x8a9e1
movq 0xe8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movq 0xe8(%rsp), %rax
movq 0xde0(%rax), %rdx
movq 0xe0(%rsp), %rcx
movl $0x8, %r8d
movl $0x1, %r9d
callq 0x13c50
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x13, %eax
je 0x8aa4e
movq 0xe8(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0xe8(%rsp), %rax
movq 0xde0(%rax), %rdx
movq 0xe0(%rsp), %rcx
movl $0x13, %r8d
movl $0x2, %r9d
callq 0x13c50
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x8ac4b
movq 0xe0(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x11340
testb $0x1, %al
jne 0x8aadc
movq 0xe8(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0xe8(%rsp), %rax
movq 0xde0(%rax), %rdx
movq 0xe0(%rsp), %rcx
movl $0xb, %r8d
movl $0x3, %r9d
callq 0x13c50
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xa0(%rsp), %rdi
callq 0x10790
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0xc8(%rsp)
jge 0x8ac49
movq 0xe8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xe8(%rsp), %rax
movq 0xde0(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
movq $0x3, 0x98(%rsp)
movq 0x98(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x8ab62
movq 0x98(%rsp), %rcx
leaq 0x18b92c(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rsp)
jmp 0x8abfa
jmp 0x8ab64
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x8ab91
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq $0xb, (%rax)
movq 0x98(%rsp), %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x88(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x197af1(%rip), %r9     # 0x222728
callq 0xc560
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
jmp 0x8ac57
movq $0x0, 0xc8(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd8(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xb8(%rsp)
movq 0xc8(%rsp), %rax
cmpq 0xb8(%rsp), %rax
jl 0x8acad
movq 0xe8(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xb0(%rsp), %rdi
callq 0x14430
testb $0x1, %al
jne 0x8acc3
jmp 0x8adf8
movq 0xb0(%rsp), %rax
movb 0x8(%rax), %al
movb %al, 0x7f(%rsp)
movq 0xd8(%rsp), %rdi
addq 0xc8(%rsp), %rdi
movsbl 0x7f(%rsp), %esi
callq 0x91d0
movq %rax, 0x70(%rsp)
cmpq $0x0, 0x70(%rsp)
je 0x8addc
movq 0x70(%rsp), %rax
movq 0xd8(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x8ad3d
movq 0x68(%rsp), %rcx
leaq 0x18b751(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
jmp 0x8adc0
jmp 0x8ad3f
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x8ad6c
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq $0xb, (%rax)
movq 0x68(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x58(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xe8(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x8ae23
movq 0xe8(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xb0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
addq 0xc8(%rsp), %rdi
movq 0xd0(%rsp), %rsi
callq 0x9310
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
addq 0xc8(%rsp), %rax
cmpq 0xb8(%rsp), %rax
jge 0x8af56
movq 0xc0(%rsp), %rax
addq 0xc8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
andq $-0x800, %rax           # imm = 0xF800
cmpq $0x0, %rax
jne 0x8aeba
movq 0x48(%rsp), %rcx
leaq 0x18b5d4(%rip), %rax    # 0x216480
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
jmp 0x8af3d
jmp 0x8aebc
movq 0xe8(%rsp), %rax
movq 0x90(%rax), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x98(%rcx), %rax
ja 0x8aee9
movq 0xe8(%rsp), %rdi
callq 0xc670
movq 0xe8(%rsp), %rcx
movq 0x90(%rcx), %rax
movq %rax, %rdx
addq $-0x8, %rdx
movq %rdx, 0x90(%rcx)
movq -0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq $0xb, (%rax)
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x8af6d
movq 0xe8(%rsp), %rax
movq 0x120(%rax), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
addq $0xf8, %rsp
retq
nopl (%rax)