// File: /workspace/github_c_makefile_star2_O2/atomlang[P]atomlang/cli/thirdparty/argparse/argparse.c
// Function: argparse_parse
int
argparse_parse(struct argparse *self, int argc, const char **argv)
{
    self->argc = argc - 1;
    self->argv = argv + 1;
    self->out  = argv;

    argparse_options_check(self->options);

    for (; self->argc; self->argc--, self->argv++) {
        const char *arg = self->argv[0];
        if (arg[0] != '-' || !arg[1]) {
            if (self->flags & ARGPARSE_STOP_AT_NON_OPTION) {
                goto end;
            }
            // if it's not option or is a single char '-', copy verbatim
            self->out[self->cpidx++] = self->argv[0];
            continue;
        }
        // short option
        if (arg[1] != '-') {
            self->optvalue = arg + 1;
            switch (argparse_short_opt(self, self->options)) {
            case -1:
                break;
            case -2:
                goto unknown;
            }
            while (self->optvalue) {
                switch (argparse_short_opt(self, self->options)) {
                case -1:
                    break;
                case -2:
                    goto unknown;
                }
            }
            continue;
        }
        // if '--' presents
        if (!arg[2]) {
            self->argc--;
            self->argv++;
            break;
        }
        // long option
        switch (argparse_long_opt(self, self->options)) {
        case -1:
            break;
        case -2:
            goto unknown;
        }
        continue;

unknown:
        fprintf(stderr, "error: unknown option `%s`\n", self->argv[0]);
        argparse_usage(self);
        exit(EXIT_FAILURE);
    }

end:
    memmove((void*)(self->out + self->cpidx), (void*)(self->argv),
            self->argc * sizeof(*self->out));
/* -------------------------------------------------- */
    self->out[self->cpidx + self->argc] = NULL;

    return self->cpidx + self->argc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
decl %esi
movl %esi, 0x28(%rdi)
leaq 0x8(%rdx), %rax
movq %rax, 0x30(%rdi)
movq %rdx, 0x38(%rdi)
movq (%rdi), %r15
movq 0xc4e9(%rip), %r12      # 0x22ff8
leaq 0x4ef8(%rip), %r14      # 0x1ba0e
movl (%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x6, %eax
jae 0x16b27
addq $0x38, %r15
jmp 0x16b16
testl %edx, %edx
je 0x16b3b
movq (%r12), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2250
jmp 0x16b21
movl 0x28(%rbx), %eax
movq 0x30(%rbx), %rsi
testl %eax, %eax
je 0x16c6b
movq (%rsi), %r14
cmpb $0x2d, (%r14)
jne 0x16b65
movzbl 0x1(%r14), %ecx
cmpl $0x2d, %ecx
je 0x16b86
testl %ecx, %ecx
jne 0x16c17
testb $0x1, 0x10(%rbx)
jne 0x16c6d
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%rbx)
movq %r14, (%rax,%rcx,8)
jmp 0x16c52
cmpb $0x0, 0x2(%r14)
je 0x16ca8
leaq 0x2(%r14), %r12
movq (%rbx), %r15
addq $0x5, %r14
movl (%r15), %ebp
testl %ebp, %ebp
je 0x16cb7
movq 0x8(%r15), %r13
testq %r13, %r13
je 0x16bcf
movq %r12, %rdi
movq %r13, %rsi
callq 0x1731a
testq %rax, %rax
je 0x16bd5
pushq $0x2
popq %rdx
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x16c42
cmpl $0x3d, %ecx
je 0x16c3b
addq $0x38, %r15
jmp 0x16b9c
andl $-0x2, %ebp
cmpl $0x2, %ebp
jne 0x16bcf
movl 0x30(%r15), %eax
andl $0x1, %eax
jne 0x16bcf
xorl %eax, %eax
cmpq $0x3, %rax
je 0x16c03
movb (%r12,%rax), %cl
leaq 0x4f2f(%rip), %rdx      # 0x1bb28
cmpb (%rax,%rdx), %cl
jne 0x16bcf
incq %rax
jmp 0x16be8
movq %r14, %rdi
movq %r13, %rsi
callq 0x1731a
testq %rax, %rax
je 0x16bcf
pushq $0x3
jmp 0x16bc2
incq %r14
movq %r14, 0x48(%rbx)
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x16ce6
cmpl $-0x2, %eax
je 0x16cb7
cmpq $0x0, 0x48(%rbx)
jne 0x16c1e
jmp 0x16c52
incq %rax
movq %rax, 0x48(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x170cd
cmpl $-0x2, %eax
je 0x16cb7
movl 0x28(%rbx), %eax
decl %eax
movl %eax, 0x28(%rbx)
movq 0x30(%rbx), %rsi
addq $0x8, %rsi
movq %rsi, 0x30(%rbx)
jmp 0x16b42
xorl %eax, %eax
movslq 0x40(%rbx), %rdi
shlq $0x3, %rdi
addq 0x38(%rbx), %rdi
movslq %eax, %rdx
shlq $0x3, %rdx
callq 0x2300
movq 0x38(%rbx), %rcx
movslq 0x40(%rbx), %rdx
movslq 0x28(%rbx), %rax
addq %rdx, %rax
andq $0x0, (%rcx,%rax,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
decl %eax
movl %eax, 0x28(%rbx)
addq $0x8, %rsi
movq %rsi, 0x30(%rbx)
jmp 0x16c6d
movq 0xc33a(%rip), %rax      # 0x22ff8
movq (%rax), %rdi
movq 0x30(%rbx), %rax
movq (%rax), %rdx
leaq 0x4c80(%rip), %rsi      # 0x1b94f
xorl %eax, %eax
callq 0x2250
movq %rbx, %rdi
callq 0x16d19
pushq $0x1
popq %rdi
callq 0x2370