// File: /workspace/github_cpp_makefile_star2_O1/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, %rbp
movq %rdi, %rbx
callq 0x4c2c
movq 0x8(%rbp), %r15
testq %r15, %r15
je 0x4f4c
addq $0x8, %rbp
leaq 0x2d6ed(%rip), %r14     # 0x323cc
leaq 0x18(%rsp), %r12
leaq 0x8(%rbp), %r13
cmpb $0x2d, (%r15)
jne 0x4d64
movzbl 0x1(%r15), %eax
testl %eax, %eax
je 0x4df1
cmpl $0x2d, %eax
jne 0x4e2c
cmpb $0x0, 0x2(%r15)
je 0x4e9c
leaq 0x2(%r15), %rax
movq %rax, 0x10(%rsp)
addq $0x3, %r15
movq %r15, %rdi
movl $0x3d, %esi
callq 0x30e0
testq %rax, %rax
je 0x4eec
movq %rax, %r15
movq %rax, %rdx
movq 0x10(%rsp), %rsi
subq %rsi, %rdx
leaq 0x58(%rsp), %rdi
xorl %ecx, %ecx
callq 0x5040
incq %r15
movq 0x58(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
jmp 0x4e19
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rcx
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x4a26
cmpb $0x1, 0x38(%rbx)
jne 0x4f3c
cmpq $0x0, (%r13)
je 0x4f3c
movq %r13, %r15
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq (%r15), %rcx
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x4a26
leaq 0x8(%r15), %r13
cmpq $0x0, 0x8(%r15)
movq %r13, %r15
jne 0x4dae
jmp 0x4f3c
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbx, %rdi
leaq 0x2a2c7(%rip), %rcx     # 0x2f0e0
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x4a26
jmp 0x4f3c
cmpb $0x0, 0x1(%r15)
leaq 0xf(%rsp), %rbp
je 0x4f3c
addq $0x2, %r15
cmpb $0x0, (%r15)
je 0x4e6a
movsbl -0x1(%r15), %esi
movq %rbx, %rdi
movq %r15, %rdx
movl $0x2, %ecx
movq %rbp, %r8
callq 0x4b70
cmpb $0x0, 0xf(%rsp)
je 0x4e8d
jmp 0x4f3c
movsbl -0x1(%r15), %esi
movq (%r13), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
movq %rbp, %r8
callq 0x4b70
movzbl 0xf(%rsp), %eax
leaq (%r13,%rax,8), %r13
cmpb $0x0, (%r15)
leaq 0x1(%r15), %r15
jne 0x4e40
jmp 0x4f3c
cmpq $0x0, (%r13)
je 0x4f3c
movq %r13, %r15
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x5040
movq (%r15), %rcx
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbx, %rdi
movl $0x3, %r8d
xorl %r9d, %r9d
callq 0x4a26
leaq 0x8(%r15), %r13
cmpq $0x0, 0x8(%r15)
movq %r13, %r15
jne 0x4eaa
jmp 0x4f3c
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x30f0
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
movq %rax, %rdx
movl $0x1, %ecx
callq 0x5040
movq 0x8(%rbp), %rcx
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %r8d
leaq 0xf(%rsp), %r9
callq 0x4a26
addq $0x10, %rbp
cmpb $0x0, 0xf(%rsp)
cmovneq %rbp, %r13
movq (%r13), %r15
movq %r13, %rbp
testq %r15, %r15
jne 0x4ce4
movq %rbx, %rdi
callq 0x4f64
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop