// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rdi, %rbx
decl %esi
movl %esi, 0x28(%rdi)
leaq 0x8(%rdx), %rax
leaq 0x30(%rdi), %r13
movq %rax, 0x30(%rdi)
movq %rdx, 0x38(%rdi)
movq (%rdi), %r15
movq 0xda74(%rip), %r12      # 0x28ff8
leaq 0x4483(%rip), %r14      # 0x1fa0e
movl (%r15), %edx
leal -0x1(%rdx), %eax
cmpl $0x6, %eax
jae 0x1b59c
addq $0x38, %r15
jmp 0x1b58b
testl %edx, %edx
je 0x1b5b0
movq (%r12), %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2250
jmp 0x1b596
movl 0x28(%rbx), %eax
movq 0x30(%rbx), %rsi
testl %eax, %eax
je 0x1b741
movq %r13, 0x8(%rsp)
movq (%rsi), %rcx
movq %rcx, (%rsp)
cmpb $0x2d, (%rcx)
jne 0x1b5e5
movq (%rsp), %rcx
movzbl 0x1(%rcx), %ecx
cmpl $0x2d, %ecx
je 0x1b60a
testl %ecx, %ecx
jne 0x1b6e5
testb $0x1, 0x10(%rbx)
jne 0x1b743
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%rbx)
movq (%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1b727
movq (%rsp), %rcx
cmpb $0x0, 0x2(%rcx)
je 0x1b781
movq (%rbx), %r15
movl (%r15), %r13d
testl %r13d, %r13d
je 0x1b790
movq (%rsp), %rax
leaq 0x2(%rax), %r12
addq $0x5, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x1b6cf
movq %r14, %rdi
callq 0x2140
movq %rax, %rbp
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2090
testl %eax, %eax
je 0x1b6b3
andl $-0x2, %r13d
cmpl $0x2, %r13d
leaq 0x44b7(%rip), %rdx      # 0x1fb28
jne 0x1b6cf
movl 0x30(%r15), %eax
andl $0x1, %eax
jne 0x1b6cf
movb $0x6e, %cl
xorl %eax, %eax
cmpb %cl, (%r12,%rax)
jne 0x1b6cf
movb 0x1(%rax,%rdx), %cl
incq %rax
cmpq $0x3, %rax
jne 0x1b680
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2090
testl %eax, %eax
jne 0x1b6cf
movl $0x3, %edx
movl $0x5, %eax
jmp 0x1b6bd
movl $0x2, %edx
movl $0x2, %eax
addq (%rsp), %rax
movzbl (%rbp,%rax), %ecx
testl %ecx, %ecx
je 0x1b717
cmpl $0x3d, %ecx
je 0x1b70d
movl 0x38(%r15), %r13d
addq $0x38, %r15
testl %r13d, %r13d
jne 0x1b638
jmp 0x1b790
movq (%rsp), %rax
incq %rax
movq %rax, 0x48(%rbx)
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x1b79d
cmpl $-0x2, %eax
je 0x1b790
cmpq $0x0, 0x48(%rbx)
jne 0x1b6f0
jmp 0x1b727
addq %rbp, %rax
incq %rax
movq %rax, 0x48(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1bbdb
cmpl $-0x2, %eax
je 0x1b790
movl 0x28(%rbx), %eax
movq 0x30(%rbx), %rsi
addq $0x8, %rsi
decl %eax
movl %eax, 0x28(%rbx)
movq %rsi, 0x30(%rbx)
jne 0x1b5c4
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
movq $0x0, (%rcx,%rax,8)
addq $0x18, %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 0x1b743
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x7d08