// File: /workspace/github_c_makefile_star2_O2/atomlang[P]atomlang/cli/thirdparty/argparse/argparse.c
// Function: argparse_usage
void
argparse_usage(struct argparse *self)
{
    if (self->usages) {
        fprintf(stdout, "Usage: %s\n", *self->usages++);
        while (*self->usages && **self->usages)
            fprintf(stdout, "   or: %s\n", *self->usages++);
    } else {
        fprintf(stdout, "Usage:\n");
    }

    // print description
    if (self->description)
        fprintf(stdout, "%s\n", self->description);


    const struct argparse_option *options;

    // figure out best width
    size_t usage_opts_width = 0;
    size_t len;
    options = self->options;
    for (; options->type != ARGPARSE_OPT_END; options++) {
        len = 0;
        if ((options)->short_name) {
            len += 2;
        }
        if ((options)->short_name && (options)->long_name) {
            len += 2;           // separator ", "
        }
        if ((options)->long_name) {
            len += strlen((options)->long_name) + 2;
        }
        if (options->type == ARGPARSE_OPT_INTEGER) {
            len += strlen("=<int>");
        }
        if (options->type == ARGPARSE_OPT_FLOAT) {
            len += strlen("=<flt>");
        } else if (options->type == ARGPARSE_OPT_STRING) {
            len += strlen("=<str>");
        }
        len = (len + 3) - ((len + 3) & 3);
        if (usage_opts_width < len) {
            usage_opts_width = len;
        }
    }
    usage_opts_width += 4;      // 4 spaces prefix

    options = self->options;
    for (; options->type != ARGPARSE_OPT_END; options++) {
        size_t pos = 0;
        size_t pad = 0;
        if (options->type == ARGPARSE_OPT_GROUP) {
            fputc('\n', stdout);
            fprintf(stdout, "%s", options->help);
            fputc('\n', stdout);
            continue;
        }
        pos = fprintf(stdout, "    ");
        if (options->short_name) {
            pos += fprintf(stdout, "-%c", options->short_name);
        }
        if (options->long_name && options->short_name) {
            pos += fprintf(stdout, ", ");
        }
        if (options->long_name) {
            pos += fprintf(stdout, "--%s", options->long_name);
        }
        if (options->type == ARGPARSE_OPT_INTEGER) {
            pos += fprintf(stdout, "=<int>");
        } else if (options->type == ARGPARSE_OPT_FLOAT) {
            pos += fprintf(stdout, "=<flt>");
        } else if (options->type == ARGPARSE_OPT_STRING) {
            pos += fprintf(stdout, "=<str>");
        }
        if (pos <= usage_opts_width) {
            pad = usage_opts_width - pos;
        } else {
            fputc('\n', stdout);
            pad = usage_opts_width;
        }
        fprintf(stdout, "%*s%s\n", (int)pad + 2, "", options->help);
    }

    // print epilog
    if (self->epilog)
        fprintf(stdout, "%s\n", self->epilog);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq 0xc29e(%rip), %r13      # 0x22fd0
movq (%r13), %rcx
testq %rax, %rax
je 0x16d8a
leaq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq (%rax), %rdx
leaq 0x4c1e(%rip), %rsi      # 0x1b96b
movq %rcx, %rdi
xorl %eax, %eax
callq 0x2250
leaq 0x4c18(%rip), %r14      # 0x1b976
movq 0x8(%rbx), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x16d9c
cmpb $0x0, (%rcx)
je 0x16d9c
movq (%r13), %rdi
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movq (%rax), %rdx
movq %r14, %rsi
xorl %eax, %eax
callq 0x2250
jmp 0x16d5e
leaq 0x4bf0(%rip), %rdi      # 0x1b981
pushq $0x7
popq %rsi
pushq $0x1
popq %rdx
callq 0x2380
movq 0x18(%rbx), %rdx
testq %rdx, %rdx
je 0x16db7
movq (%r13), %rdi
leaq 0x4bc2(%rip), %rsi      # 0x1b972
xorl %eax, %eax
callq 0x2250
movq %rbx, (%rsp)
movq (%rbx), %rbx
xorl %r14d, %r14d
movq %rbx, %r15
movl (%r15), %ebp
testl %ebp, %ebp
je 0x16e2a
movq 0x8(%r15), %rdi
xorl %eax, %eax
testq %rdi, %rdi
setne %al
cmpb $0x0, 0x4(%r15)
leaq 0x2(%rax,%rax), %rax
movl $0x0, %r12d
cmovneq %rax, %r12
testq %rdi, %rdi
je 0x16dfc
callq 0x2140
addq %rax, %r12
addq $0x2, %r12
leaq 0x6(%r12), %rax
cmpl $0x4, %ebp
cmoveq %rax, %r12
cmpl $0x6, %ebp
je 0x16e12
cmpl $0x5, %ebp
jne 0x16e15
movq %rax, %r12
addq $0x3, %r12
andq $-0x4, %r12
cmpq %r12, %r14
cmovbeq %r12, %r14
addq $0x38, %r15
jmp 0x16dc4
addq $0x4, %r14
pushq $0xa
popq %rbp
leaq 0x3344(%rip), %r12      # 0x1a17c
movl (%rbx), %eax
cmpl $0x1, %eax
je 0x16f23
testl %eax, %eax
je 0x16f4f
movq (%r13), %rdi
leaq 0x1d14(%rip), %rsi      # 0x18b6a
xorl %eax, %eax
callq 0x2250
movslq %eax, %r15
movsbl 0x4(%rbx), %edx
testl %edx, %edx
je 0x16e7f
movq (%r13), %rdi
leaq 0x4b16(%rip), %rsi      # 0x1b989
xorl %eax, %eax
callq 0x2250
cltq
addq %rax, %r15
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
je 0x16ec5
cmpb $0x0, 0x4(%rbx)
je 0x16eae
movq (%r13), %rdi
leaq 0x156a(%rip), %rsi      # 0x18403
xorl %eax, %eax
callq 0x2250
cltq
addq %rax, %r15
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
je 0x16ec5
movq (%r13), %rdi
leaq 0x4ad4(%rip), %rsi      # 0x1b98d
xorl %eax, %eax
callq 0x2250
cltq
addq %rax, %r15
movl (%rbx), %eax
addl $-0x4, %eax
cmpl $0x2, %eax
ja 0x16eef
movl %eax, %eax
leaq 0x499c(%rip), %rcx      # 0x1b874
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq (%r13), %rdi
xorl %eax, %eax
callq 0x2250
cltq
addq %rax, %r15
movq %r14, %rdx
subq %r15, %rdx
jae 0x16f05
movq (%r13), %rsi
movl %ebp, %edi
callq 0x2200
movq %r14, %rdx
movq (%r13), %rdi
addl $0x2, %edx
movq 0x18(%rbx), %r8
leaq 0x4a90(%rip), %rsi      # 0x1b9a7
movq %r12, %rcx
xorl %eax, %eax
callq 0x2250
jmp 0x16f46
movq (%r13), %rsi
movl %ebp, %edi
callq 0x2200
movq (%r13), %rsi
movq 0x18(%rbx), %rdi
callq 0x2180
movq (%r13), %rsi
movl %ebp, %edi
callq 0x2200
addq $0x38, %rbx
jmp 0x16e38
movq (%rsp), %rax
movq 0x20(%rax), %rdx
testq %rdx, %rdx
je 0x16f7c
movq (%r13), %rdi
leaq 0x4a0b(%rip), %rsi      # 0x1b972
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2250
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq