// File: /workspace/github_c_makefile_star2_O2/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_next
int getopt_next(getopt_t *_this)
{
	char	*s, *oname;
	getopt_option_descr_t *odesc;
	int	i;
	int max_scan_arg_count;

	// is it an option?
	if (_this->cur_cline_arg_idx >= _this->argc)
		return GETOPT_STATUS_EOF;

	_this->curtoken = s = _this->argv[_this->cur_cline_arg_idx];
	assert(s);
	assert(*s); // must be non empty



	oname = get_dashed_option_name(s);
	if (oname) {
		// it is an "-option": search options by name
		_this->cur_option = NULL;
		for (i = 0; (odesc = _this->option_descrs[i]); i++)
			if (!getopt_strcmp(_this, oname, odesc->short_name) || !getopt_strcmp(_this, oname, odesc->long_name))
				_this->cur_option = odesc; // found by name
		if (_this->cur_option == NULL) {
			// its an option, but not found in the definitions
			return getopt_parse_error(_this, GETOPT_STATUS_ILLEGALOPTION);
		}
		_this->cur_cline_arg_idx++; // skip -option

		// if an option has no optional arguments, prevent it from
		// parsing into
	}
	else // its not an '-option: so its the "nonoption" rest of cline
		_this->cur_option = _this->nonoption_descr;

	// find the arg at wich to stop parsing args for this option
	// in case of nonoption-args: end of cmdlineor
	// else for options:
	//	it's either the next -option,
	//  or if no -option: collision with trailing non-option args.
	//	   if no variable: amount of fix args
	//		else: line end. So in case
	//		-option fix0 fix1 var0 var 1 nonopt0 nonopt1
	//			all also nonopt0/1 is read, resulting in an error
	//			this is intended to force unambiguous syntax declaration!
	if (_this->cur_option == _this->nonoption_descr)
		max_scan_arg_count = INT_MAX;
	else {
		// search next -option
		i = _this->cur_cline_arg_idx;
		while (i < _this->argc &&  get_dashed_option_name(_this->argv[i]) == NULL)
			i++;
		if (i < _this->argc) // terminating -option found
			max_scan_arg_count = i - _this->cur_cline_arg_idx;
		else if (_this->cur_option->fix_arg_count == _this->cur_option->max_arg_count)
			max_scan_arg_count = _this->cur_option->fix_arg_count;
		else max_scan_arg_count = INT_MAX;
	}

	// option (or rest of cline) valid, parse args
	// parse until
	// - end of commandline
	// - max argument count for option reached
	// - another "-option" is found
	i = 0;
	while (_this->cur_cline_arg_idx < _this->argc
		&& i < max_scan_arg_count) {
		_this->cur_option_argval[i++] = _this->curtoken = _this->argv[_this->cur_cline_arg_idx];
		_this->cur_option_argval[i] = NULL;
		assert(i < GETOPT_MAX_OPTION_ARGS);
		_this->cur_option_argvalcount = i;
		_this->cur_cline_arg_idx++;
	}

	if (i < _this->cur_option->fix_arg_count)
		return getopt_parse_error(_this, GETOPT_STATUS_MINARGCOUNT);
	if (i > _this->cur_option->max_arg_count)
		return getopt_parse_error(_this, GETOPT_STATUS_MAXARGCOUNT);
	return GETOPT_STATUS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x11c0(%rdi), %eax
movslq 0xb70(%rdi), %r15
xorl %ebp, %ebp
cmpl %r15d, %eax
jge 0x54ab
movq %rdi, %rbx
movslq %eax, %r12
movq 0xb78(%rdi,%r12,8), %rcx
movq %rcx, 0x678(%rdi)
testq %rcx, %rcx
je 0x54fc
movzbl (%rcx), %edx
cmpl $0x2d, %edx
je 0x53e8
testl %edx, %edx
je 0x551b
movq 0x8(%rbx), %rdi
movq %rdi, 0x338(%rbx)
movslq %eax, %r12
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movslq %eax, %rcx
leaq (%rbx,%r12,8), %rdx
addq $0xb78, %rdx            # imm = 0xB78
xorl %eax, %eax
leaq (%r12,%rax), %rsi
cmpq %r15, %rsi
jge 0x53d5
cmpq %rcx, %rax
jge 0x53d5
movq (%rdx,%rax,8), %rsi
movq %rsi, 0x678(%rbx)
movq %rsi, 0x348(%rbx,%rax,8)
andq $0x0, 0x350(%rbx,%rax,8)
cmpq $0x63, %rax
je 0x54dd
leal (%r12,%rax), %esi
incl %esi
incq %rax
movl %eax, 0x670(%rbx)
movl %esi, 0x11c0(%rbx)
jmp 0x538a
cmpl %eax, 0x678(%rdi)
jle 0x548d
pushq $-0x2
jmp 0x54a0
xorl %eax, %eax
cmpb $0x2d, 0x1(%rcx)
sete %al
andq $0x0, 0x338(%rbx)
leaq (%rcx,%rax), %r14
incq %r14
leaq 0x10(%rbx), %rbp
movq $0x0, (%rsp)
movq (%rbp), %r13
testq %r13, %r13
je 0x544c
movq 0x8(%r13), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x52f7
testl %eax, %eax
je 0x543b
movq 0x10(%r13), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x52f7
testl %eax, %eax
jne 0x5446
movq %r13, 0x338(%rbx)
movq %r13, (%rsp)
addq $0x8, %rbp
jmp 0x540c
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x549e
incq %r12
movl %r12d, 0x11c0(%rbx)
cmpq 0x8(%rbx), %rdi
je 0x54bc
leaq (%rbx,%r12,8), %rcx
addq $0xb78, %rcx            # imm = 0xB78
xorl %eax, %eax
leaq (%r12,%rax), %rdx
cmpq %r15, %rdx
jge 0x54c4
movq (%rcx,%rax,8), %rdx
cmpb $0x2d, (%rdx)
je 0x537a
incq %rax
jmp 0x5472
cmpl %eax, 0x67c(%rdi)
jge 0x5499
pushq $-0x3
jmp 0x54a0
pushq $0x1
popq %rbp
jmp 0x54ab
pushq $-0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x553a
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, %eax
jmp 0x5372
movl 0x678(%rdi), %ecx
cmpl 0x67c(%rdi), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovel %ecx, %eax
jmp 0x537a
leaq 0xdf35(%rip), %rdi      # 0x13419
leaq 0xde69(%rip), %rsi      # 0x13354
leaq 0xdf08(%rip), %rcx      # 0x133fa
movl $0x19e, %edx            # imm = 0x19E
callq 0x3200
leaq 0xd39d(%rip), %rdi      # 0x128a0
leaq 0xde4a(%rip), %rsi      # 0x13354
leaq 0xdee9(%rip), %rcx      # 0x133fa
movl $0x164, %edx            # imm = 0x164
callq 0x3200
leaq 0xdef4(%rip), %rdi      # 0x13416
leaq 0xde2b(%rip), %rsi      # 0x13354
leaq 0xdeca(%rip), %rcx      # 0x133fa
movl $0x165, %edx            # imm = 0x165
callq 0x3200