// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movl %esi, 0x2c(%rsp)
movq %rdx, 0x20(%rsp)
movl 0x2c(%rsp), %ecx
subl $0x1, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x20(%rsp), %rcx
addq $0x8, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x20(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rdi
callq 0x28920
movq 0x30(%rsp), %rax
cmpl $0x0, 0x28(%rax)
je 0x288ab
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x28726
movq 0x18(%rsp), %rax
cmpb $0x0, 0x1(%rax)
jne 0x2876c
movq 0x30(%rsp), %rax
movl 0x10(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2873b
jmp 0x288ad
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rdx
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x30(%rsp), %rsi
movl 0x40(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x40(%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x28887
movq 0x18(%rsp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
je 0x287f5
movq 0x18(%rsp), %rcx
incq %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x30(%rsp), %rdi
movq (%rdi), %rsi
callq 0x28970
movl %eax, %ecx
movl %ecx, 0x14(%rsp)
subl $-0x2, %eax
je 0x287b2
jmp 0x287a5
movl 0x14(%rsp), %eax
subl $-0x1, %eax
jne 0x287b7
jmp 0x287b0
jmp 0x287b7
jmp 0x2884f
jmp 0x287b9
movq 0x30(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0x287f0
movq 0x30(%rsp), %rdi
movq (%rdi), %rsi
callq 0x28970
movl %eax, %ecx
movl %ecx, 0x10(%rsp)
subl $-0x2, %eax
je 0x287ec
jmp 0x287df
movl 0x10(%rsp), %eax
subl $-0x1, %eax
jne 0x287ee
jmp 0x287ea
jmp 0x287ee
jmp 0x2884f
jmp 0x287b9
jmp 0x28887
movq 0x18(%rsp), %rax
cmpb $0x0, 0x2(%rax)
jne 0x28824
movq 0x30(%rsp), %rax
movl 0x28(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x30(%rax)
jmp 0x288ab
movq 0x30(%rsp), %rdi
movq (%rdi), %rsi
callq 0x28a20
movl %eax, %ecx
movl %ecx, 0xc(%rsp)
subl $-0x2, %eax
je 0x2884b
jmp 0x2883e
movl 0xc(%rsp), %eax
subl $-0x1, %eax
jne 0x2884d
jmp 0x28849
jmp 0x2884d
jmp 0x2884f
jmp 0x28887
movq 0xa7a2(%rip), %rax      # 0x32ff8
movq (%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rdx
leaq 0x5233(%rip), %rsi      # 0x2da9f
movb $0x0, %al
callq 0x2240
movq 0x30(%rsp), %rdi
callq 0x28b80
movl $0x1, %edi
callq 0x2360
movq 0x30(%rsp), %rax
movl 0x28(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0x30(%rax)
jmp 0x286ee
jmp 0x288ad
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x30(%rsp), %rax
movslq 0x40(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq 0x30(%rsp), %rax
movq 0x30(%rax), %rsi
movq 0x30(%rsp), %rax
movslq 0x28(%rax), %rdx
shlq $0x3, %rdx
callq 0x22f0
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x30(%rsp), %rcx
movl 0x40(%rcx), %ecx
movq 0x30(%rsp), %rdx
addl 0x28(%rdx), %ecx
movslq %ecx, %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x30(%rsp), %rax
movl 0x40(%rax), %eax
movq 0x30(%rsp), %rcx
addl 0x28(%rcx), %eax
addq $0x38, %rsp
retq
nopw (%rax,%rax)