// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movl 0x11c0(%rdi), %esi
movslq 0xb70(%rdi), %r10
xorl %ebp, %ebp
cmpl %r10d, %esi
jge 0x56e0
movq %rdi, %rbx
movslq %esi, %rdx
movq 0xb78(%rdi,%rdx,8), %rcx
movq %rcx, 0x678(%rdi)
testq %rcx, %rcx
je 0x56fb
movzbl (%rcx), %eax
cmpl $0x2d, %eax
je 0x5559
testl %eax, %eax
je 0x571a
movq 0x8(%rbx), %r12
movq %r12, 0x338(%rbx)
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %esi, %r9d
xorl %ecx, %ecx
cmpl %r10d, %r9d
jge 0x5678
testl %eax, %eax
jle 0x5678
movl %eax, %eax
movslq %r9d, %rcx
leaq (%rbx,%rcx,8), %rdx
addq $0xb80, %rdx            # imm = 0xB80
movq -0x8(%rdx), %rsi
movq %rsi, 0x678(%rbx)
movq %rsi, 0x348(%rbx)
movq $0x0, 0x350(%rbx)
incq %rcx
xorl %esi, %esi
leaq (%rcx,%rsi), %rdi
cmpq %r10, %rdi
jge 0x5662
leaq 0x1(%rsi), %rdi
cmpq %rax, %rdi
jae 0x5662
movq (%rdx,%rsi,8), %r8
movq %r8, 0x678(%rbx)
movq %r8, 0x350(%rbx,%rsi,8)
movq $0x0, 0x358(%rbx,%rsi,8)
movq %rdi, %rsi
cmpq $0x63, %rdi
jne 0x54e8
addl %edi, %r9d
movl %edi, 0x670(%rbx)
movl %r9d, 0x11c0(%rbx)
leaq 0xeec6(%rip), %rdi      # 0x14407
leaq 0xedfa(%rip), %rsi      # 0x14342
leaq 0xee99(%rip), %rcx      # 0x143e8
movl $0x19e, %edx            # imm = 0x19E
callq 0x3200
xorl %eax, %eax
cmpb $0x2d, 0x1(%rcx)
sete %sil
movq $0x0, 0x338(%rbx)
movq 0x10(%rbx), %r13
testq %r13, %r13
je 0x56b4
movq %r10, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movb %sil, %al
movq %rcx, (%rsp)
leaq (%rcx,%rax), %r15
incq %r15
movl (%rbx), %ebp
leaq 0x18(%rbx), %r14
xorl %r12d, %r12d
movq 0x8(%r13), %rsi
movq %r15, %rdi
testl %ebp, %ebp
je 0x55be
callq 0x3060
testl %eax, %eax
je 0x55d7
movq 0x10(%r13), %rsi
movq %r15, %rdi
callq 0x3060
jmp 0x55d3
callq 0x32e0
testl %eax, %eax
je 0x55d7
movq 0x10(%r13), %rsi
movq %r15, %rdi
callq 0x32e0
testl %eax, %eax
jne 0x55e1
movq %r13, 0x338(%rbx)
movq %r13, %r12
movq (%r14), %r13
addq $0x8, %r14
testq %r13, %r13
jne 0x559c
testq %r12, %r12
movq 0x10(%rsp), %r9
movq 0x8(%rsp), %r10
movq (%rsp), %rcx
je 0x56b4
incq %r9
movl %r9d, 0x11c0(%rbx)
cmpq 0x8(%rbx), %r12
je 0x56f1
cmpl %r10d, %r9d
jge 0x5645
leaq (%rbx,%r9,8), %rcx
addq $0xb78, %rcx            # imm = 0xB78
movq %r10, %rdx
subq %r9, %rdx
xorl %eax, %eax
movq (%rcx,%rax,8), %rsi
cmpb $0x2d, (%rsi)
je 0x54a3
incq %rax
cmpq %rax, %rdx
jne 0x5630
movl 0x678(%r12), %ecx
cmpl 0x67c(%r12), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovel %ecx, %eax
jmp 0x54a3
movl %esi, %ecx
incl %ecx
leal (%r9,%rsi), %eax
incl %eax
movl %ecx, 0x670(%rbx)
movl %eax, 0x11c0(%rbx)
cmpl 0x678(%r12), %ecx
jge 0x5691
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
jmp 0x56ad
movl $0x1, %ebp
cmpl 0x67c(%r12), %ecx
jle 0x56e0
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x5739
jmp 0x56e0
movl $0xffffffff, 0x680(%rbx) # imm = 0xFFFFFFFF
addq $0x684, %rbx            # imm = 0x684
leaq 0xee5d(%rip), %rdx      # 0x14529
movl $0x101, %esi            # imm = 0x101
movq %rbx, %rdi
xorl %eax, %eax
callq 0x31d0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
jmp 0x54a3
leaq 0xe19e(%rip), %rdi      # 0x138a0
leaq 0xec39(%rip), %rsi      # 0x14342
leaq 0xecd8(%rip), %rcx      # 0x143e8
movl $0x164, %edx            # imm = 0x164
callq 0x3200
leaq 0xece3(%rip), %rdi      # 0x14404
leaq 0xec1a(%rip), %rsi      # 0x14342
leaq 0xecb9(%rip), %rcx      # 0x143e8
movl $0x165, %edx            # imm = 0x165
callq 0x3200