// File: /workspace/github_cpp_makefile_star2_O2/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 $0x78, %rsp
movq %rsi, %r13
movq %rdi, %rbx
callq 0x3e6c
addq $0x8, %r13
leaq 0x274f5(%rip), %r14     # 0x2b3d9
pushq $0x3
popq %rbp
movq (%r13), %r12
testq %r12, %r12
je 0x40ea
leaq 0x8(%r13), %r15
cmpb $0x2d, (%r12)
jne 0x3f74
movzbl 0x1(%r12), %eax
testl %eax, %eax
je 0x3fe0
cmpl $0x2d, %eax
jne 0x4014
cmpb $0x0, 0x2(%r12)
je 0x4073
leaq 0x2(%r12), %rax
movq %rax, 0x10(%rsp)
addq $0x3, %r12
movq %r12, %rdi
pushq $0x3d
popq %rsi
callq 0x30e0
testq %rax, %rax
je 0x40aa
movq %rax, %r12
movq %rax, %rdx
movq 0x10(%rsp), %rsi
subq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x423a
incq %r12
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
jmp 0x4001
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x42ce
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rcx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x3d26
cmpb $0x1, 0x38(%rbx)
movq %r15, %r13
jne 0x3ee7
leaq 0x18(%rsp), %r12
cmpq $0x0, (%r15)
je 0x400c
movq %r12, %rdi
movq %r14, %rsi
callq 0x42ce
movq (%r15), %rcx
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x3d26
addq $0x8, %r15
jmp 0x3fae
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x42ce
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
leaq 0x240e4(%rip), %rcx     # 0x280e5
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x3d26
movq %r15, %r13
jmp 0x3ee7
addq $0x2, %r12
movq %r15, %r13
testb %al, %al
je 0x3ee7
cmpb $0x0, (%r12)
movsbl %al, %esi
je 0x404c
movq %rbx, %rdi
movq %r12, %rdx
pushq $0x2
popq %rcx
leaq 0xf(%rsp), %r8
callq 0x3e00
cmpb $0x0, 0xf(%rsp)
je 0x406a
jmp 0x3ee7
movq (%r13), %rdx
movq %rbx, %rdi
pushq $0x1
popq %rcx
leaq 0xf(%rsp), %r8
callq 0x3e00
movzbl 0xf(%rsp), %eax
leaq (%r13,%rax,8), %r13
movb (%r12), %al
incq %r12
jmp 0x401b
leaq 0x68(%rsp), %r12
cmpq $0x0, (%r15)
je 0x400c
movq %r12, %rdi
movq %r14, %rsi
callq 0x42ce
movq (%r15), %rcx
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x3d26
addq $0x8, %r15
jmp 0x4078
leaq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x42ce
movq 0x8(%r13), %rcx
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
pushq $0x1
popq %r8
leaq 0xf(%rsp), %r9
callq 0x3d26
addq $0x10, %r13
cmpb $0x0, 0xf(%rsp)
cmoveq %r15, %r13
jmp 0x3ee7
movq %rbx, %rdi
callq 0x4102
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop