// File: /workspace/github_c_makefile_star2_O1/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), %rcx
movq %rcx, 0x8(%rsp)
movq %rax, 0x30(%rdi)
movq %rdx, 0x38(%rdi)
movq (%rdi), %r14
movq 0xdbe9(%rip), %r12      # 0x29ff8
leaq 0x45c4(%rip), %r15      # 0x209da
movl (%r14), %edx
leal -0x1(%rdx), %eax
cmpl $0x6, %eax
jae 0x1c427
addq $0x38, %r14
jmp 0x1c416
testl %edx, %edx
je 0x1c43b
movq (%r12), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2250
jmp 0x1c421
movl 0x28(%rbx), %eax
testl %eax, %eax
je 0x1c5e4
movq %rbx, (%rsp)
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
movq (%rdx), %rcx
cmpb $0x2d, (%rcx)
jne 0x1c46b
movzbl 0x1(%rcx), %esi
cmpl $0x2d, %esi
je 0x1c48c
testl %esi, %esi
jne 0x1c5a1
testb $0x1, 0x10(%rbx)
jne 0x1c5e4
movq 0x38(%rbx), %rax
movslq 0x40(%rbx), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x40(%rbx)
movq %rcx, (%rax,%rdx,8)
jmp 0x1c5d1
cmpb $0x0, 0x2(%rcx)
je 0x1c627
movq (%rbx), %r15
movl (%r15), %r14d
testl %r14d, %r14d
je 0x1c636
movq 0x8(%r15), %r12
movb $0x1, %al
testq %r12, %r12
je 0x1c583
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rbx
leaq 0x2(%rbx), %rbp
movq %r12, %rdi
callq 0x2140
movq %rax, %r13
movq %rbp, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2090
leaq (%rbx,%r13), %rcx
addq $0x2, %rcx
testl %eax, %eax
movl $0x0, %eax
cmovneq %rax, %rcx
je 0x1c554
andl $-0x2, %r14d
cmpl $0x2, %r14d
leaq 0x45f4(%rip), %rdx      # 0x20af4
jne 0x1c54c
movl 0x30(%r15), %eax
andl $0x1, %eax
jne 0x1c54c
movq %rbx, %rsi
movb $0x6e, %al
xorl %ecx, %ecx
cmpb %al, (%rbp,%rcx)
jne 0x1c54c
movb 0x1(%rcx,%rdx), %al
incq %rcx
cmpq $0x3, %rcx
jne 0x1c512
movq %rsi, %r14
leaq 0x5(%rsi), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2090
leaq (%r14,%r13), %rcx
addq $0x5, %rcx
testl %eax, %eax
movl $0x0, %eax
cmovneq %rax, %rcx
je 0x1c59a
movb $0x1, %al
movq (%rsp), %rbx
jmp 0x1c583
movl $0x2, %edx
movq (%rsp), %rbx
movzbl (%rcx), %eax
testl %eax, %eax
je 0x1c572
cmpl $0x3d, %eax
movb $0x1, %al
jne 0x1c583
incq %rcx
movq %rcx, 0x48(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ca98
movl %eax, 0x14(%rsp)
xorl %eax, %eax
testb %al, %al
je 0x1c5c1
movl 0x38(%r15), %r14d
addq $0x38, %r15
testl %r14d, %r14d
jne 0x1c4a5
jmp 0x1c5c7
movl $0x3, %edx
jmp 0x1c559
incq %rcx
movq %rcx, 0x48(%rbx)
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x1c643
cmpl $-0x2, %eax
je 0x1c636
cmpq $0x0, 0x48(%rbx)
jne 0x1c5a8
jmp 0x1c5d1
movl 0x14(%rsp), %eax
jmp 0x1c5cc
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpl $-0x2, %eax
je 0x1c636
movl 0x28(%rbx), %eax
addq $0x8, 0x30(%rbx)
decl %eax
movl %eax, 0x28(%rbx)
jne 0x1c44a
movslq 0x40(%rbx), %rdi
shlq $0x3, %rdi
addq 0x38(%rbx), %rdi
movq 0x30(%rbx), %rsi
movslq 0x28(%rbx), %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, %rdx
movq %rdx, 0x30(%rbx)
jmp 0x1c5e4
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x7dc3