// File: /workspace/github_cpp_makefile_star2_O3/Alcaro[P]bridges/arlib/argparse.cpp
// Function: argparse::parse(char const* const*)
void argparse::parse(const char * const * argv)
{
	parse_pre(argv);
	
	argv++;
	while (*argv)
	{
		const char * arg = *argv;
		argv++;
		if (arg[0] == '-')
		{
			if (arg[1] == '-')
			{
				if (arg[2] == '\0')
				{
					// just --
					while (*argv)
					{
						single_arg("", *argv, al_mandatory, NULL);
						argv++;
					}
				}
				else
				{
					// -- followed by something
					
					// +3 to skip the --, and the first actual character, otherwise '--=derp' would derp out
					const char * eq = strchr(arg+3, '=');
					if (eq)
					{
						single_arg(arrayview<char>(arg+2, eq-(arg+2)), eq+1, al_mandatory, NULL);
					}
					else
					{
						bool used;
						single_arg(arg+2, *argv, al_loose, &used);
						if (used) argv++;
					}
				}
			}
			else if (arg[1] == '\0')
			{
				// a lone -
				single_arg("", "-", al_mandatory, NULL);
			}
			else
			{
				// - followed by something
				arg++;
				while (*arg)
				{
					if (arg[1])
					{
						// -ab (*arg is 'a', argument is "b")
						bool used;
						single_arg(*arg, arg+1, al_tight, &used);
						if (used) break;
					}
					else
					{
						// -a b (*arg is 'a', next is "b")
						bool used;
						single_arg(*arg, *argv, al_loose, &used);
						if (used) argv++;
					}
					arg++;
				}
			}
		}
		else
		{
			// no leading -
			single_arg("", arg, al_mandatory, NULL);
			if (m_early_stop)
			{
				while (*argv)
				{
					single_arg("", *argv, al_mandatory, NULL);
					argv++;
				}
			}
		}
	}
	
	parse_post();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x5572
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x5894
addq $0x8, %r15
leaq 0x2ce47(%rip), %r13     # 0x3246c
leaq 0x7(%rsp), %rbp
leaq 0x8(%r15), %r14
cmpb $0x2d, (%r12)
jne 0x56b9
movzbl 0x1(%r12), %eax
testl %eax, %eax
je 0x56fa
cmpl $0x2d, %eax
jne 0x5735
cmpb $0x0, 0x2(%r12)
je 0x5843
leaq 0x2(%r12), %r13
addq $0x3, %r12
movq %r12, %rdi
movl $0x3d, %esi
callq 0x30e0
testq %rax, %rax
je 0x5788
movq %rax, %r12
movq %rax, %rdx
subq %r13, %rdx
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x5990
incq %r12
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x539c
jmp 0x57d1
leaq 0x18(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x539c
cmpb $0x1, 0x38(%rbx)
jne 0x57d8
jmp 0x57ec
leaq 0x28(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
leaq 0x299be(%rip), %rcx     # 0x2f0e0
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x539c
jmp 0x57d8
addq $0x2, %r12
cmpb $0x0, (%r12)
movsbl %al, %esi
je 0x575f
movq %rbx, %rdi
movq %r12, %rdx
movl $0x2, %ecx
movq %rbp, %r8
callq 0x54d0
cmpb $0x0, 0x7(%rsp)
je 0x577b
jmp 0x57d8
movq (%r14), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
movq %rbp, %r8
callq 0x54d0
movzbl 0x7(%rsp), %eax
leaq (%r14,%rax,8), %r14
movb (%r12), %al
incq %r12
testb %al, %al
jne 0x5739
jmp 0x57d8
movq %r13, %rdi
callq 0x30f0
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5990
movq 0x8(%r15), %rcx
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %r8d
movq %rbp, %r9
callq 0x539c
addq $0x10, %r15
cmpb $0x0, 0x7(%rsp)
cmovneq %r15, %r14
leaq 0x2cc94(%rip), %r13     # 0x3246c
movq (%r14), %r12
movq %r14, %r15
testq %r12, %r12
jne 0x562a
jmp 0x5894
cmpq $0x0, (%r14)
je 0x5894
addq $0x10, %r15
leaq 0x2cc6b(%rip), %r14     # 0x3246c
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq -0x8(%r15), %rcx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x539c
cmpq $0x0, (%r15)
leaq 0x8(%r15), %r15
jne 0x5806
jmp 0x5894
cmpq $0x0, (%r14)
je 0x5894
addq $0x10, %r15
leaq 0x2cc18(%rip), %r14     # 0x3246c
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5990
movq -0x8(%r15), %rcx
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rbx, %rdi
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x539c
cmpq $0x0, (%r15)
leaq 0x8(%r15), %r15
jne 0x5859
movq %rbx, %rdi
callq 0x58ac
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop