// File: /workspace/github_c_makefile_star2_O0/kyz[P]amostools/./amoslib.c
// Function: AMOS_parse_config
int AMOS_parse_config(uint8_t *src, size_t len,
                      char *slots[AMOS_EXTENSION_SLOTS])
{
    /* AMOSPro_Interpreter_Config format: PId1 / PIdt */
    if (len > 100 && (amos_leek(src) == 0x50496431 ||
                      amos_leek(src) == 0x50496474))
    {
        /* items section: PIt1 / PItx */
        uint32_t idlen = amos_leek(&src[4]);
        if (idlen < (len - 92) && (amos_leek(&src[idlen + 8]) == 0x50497431 ||
                                   amos_leek(&src[idlen + 8]) == 0x50497478))
        {
            uint8_t *p = &src[idlen + 16];
            int i;
            /* config strings 16-41 are extensions 1-25 */
            for (i = 1; i < (16+AMOS_EXTENSION_SLOTS); i++) {
                if (i >= 16) slots[i - 16] = (char *) &p[2];
                p += p[1] + 2;
                if ((p - src) > (int) len) return 1;
            }
            return 0; /* success */
        }
    }

    /* AMOS1_3_Pal.env, etc. format: Amiga code hunk */
    if (len > 300 && amos_leek(src) == 0x3f3 && amos_leek(&src[24]) == 0x3e9) {
        uint32_t dta = amos_leek(&src[32]);
        /* look up config entry 66 */
        uint32_t offset = amos_deek(&src[36 + 65 * 4]) + 36 - dta;
        uint32_t flags  = amos_deek(&src[36 + 65 * 4 + 2]);
        /* entry must be list of strings */
        if (flags & 0x8000 && offset < len) {
            uint8_t *s = &src[offset], *end = &src[len];
            int i;
            for (i = 0; i < AMOS_EXTENSION_SLOTS; i++) {
                if (s >= end) return 1;
                if (*s == 0xFF) break; /* end of list */
                slots[i] = (char *) s;
                while (*s++ && s < end); /* skip string */
            }
            for (; i < AMOS_EXTENSION_SLOTS; i++) {
                slots[i] = NULL;
            }
            return 0; /* success */
        }
    }
    return 1; /* failure */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x64, -0x18(%rbp)
jbe 0x252b
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
cmpl $0x50496431, %eax       # imm = 0x50496431
je 0x2399
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
cmpl $0x50496474, %eax       # imm = 0x50496474
jne 0x252b
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x6(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
subq $0x5c, %rcx
cmpq %rcx, %rax
jae 0x2529
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x8, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x1(%rcx,%rdx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x2(%rcx,%rdx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x3(%rcx,%rdx), %ecx
orl %ecx, %eax
cmpl $0x50497431, %eax       # imm = 0x50497431
je 0x2495
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x8, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x1(%rcx,%rdx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x2(%rcx,%rdx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x8, %edx
movl %edx, %edx
movzbl 0x3(%rcx,%rdx), %ecx
orl %ecx, %eax
cmpl $0x50497478, %eax       # imm = 0x50497478
jne 0x2529
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x10, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
cmpl $0x29, -0x34(%rbp)
jge 0x251d
cmpl $0x10, -0x34(%rbp)
jl 0x24d4
movq -0x30(%rbp), %rdx
addq $0x2, %rdx
movq -0x20(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x10, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %ecx
addl $0x2, %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movq -0x18(%rbp), %rcx
movslq %ecx, %rcx
cmpq %rcx, %rax
jle 0x2510
movl $0x1, -0x4(%rbp)
jmp 0x2712
jmp 0x2512
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x24af
movl $0x0, -0x4(%rbp)
jmp 0x2712
jmp 0x252b
cmpq $0x12c, -0x18(%rbp)     # imm = 0x12C
jbe 0x270b
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
cmpl $0x3f3, %eax            # imm = 0x3F3
jne 0x270b
movq -0x10(%rbp), %rax
movzbl 0x18(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x19(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1a(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x1b(%rcx), %ecx
orl %ecx, %eax
cmpl $0x3e9, %eax            # imm = 0x3E9
jne 0x270b
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %eax
shll $0x18, %eax
movq -0x10(%rbp), %rcx
movzbl 0x21(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x22(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rbp), %rcx
movzbl 0x23(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x128(%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x129(%rcx), %ecx
orl %ecx, %eax
addl $0x24, %eax
subl -0x38(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x12a(%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x12b(%rcx), %ecx
orl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x2709
movl -0x3c(%rbp), %eax
cmpq -0x18(%rbp), %rax
jae 0x2709
movq -0x10(%rbp), %rax
movl -0x3c(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
cmpl $0x19, -0x54(%rbp)
jge 0x26dd
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jb 0x267b
movl $0x1, -0x4(%rbp)
jmp 0x2712
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
jne 0x268b
jmp 0x26dd
movq -0x48(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x55(%rbp)
je 0x26c5
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
setb %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x26ce
jmp 0x26d0
jmp 0x269b
jmp 0x26d2
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x265f
jmp 0x26df
cmpl $0x19, -0x54(%rbp)
jge 0x2700
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x26df
movl $0x0, -0x4(%rbp)
jmp 0x2712
jmp 0x270b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)