// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x11c0(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xb70(%rcx), %eax
jl 0x5f8e
movl $0x0, -0x4(%rbp)
jmp 0x62f1
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x11c0(%rcx), %rcx
movq 0xb78(%rax,%rcx,8), %rcx
movq %rcx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rcx, 0x678(%rax)
cmpq $0x0, -0x18(%rbp)
je 0x5fbd
jmp 0x5fdc
leaq 0x148b0(%rip), %rdi     # 0x1a874
leaq 0x1535d(%rip), %rsi     # 0x1b328
movl $0x164, %edx            # imm = 0x164
leaq 0x153f7(%rip), %rcx     # 0x1b3ce
callq 0x3200
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0x5fe7
jmp 0x6006
leaq 0x153fc(%rip), %rdi     # 0x1b3ea
leaq 0x15333(%rip), %rsi     # 0x1b328
movl $0x165, %edx            # imm = 0x165
leaq 0x153cd(%rip), %rcx     # 0x1b3ce
callq 0x3200
movq -0x18(%rbp), %rdi
callq 0x6300
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x60d4
movq -0x10(%rbp), %rax
movq $0x0, 0x338(%rax)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x609b
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x5f10
cmpl $0x0, %eax
je 0x607f
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x5f10
cmpl $0x0, %eax
jne 0x608e
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x338(%rax)
jmp 0x6090
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6034
movq -0x10(%rbp), %rax
cmpq $0x0, 0x338(%rax)
jne 0x60bf
movq -0x10(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x6370
movl %eax, -0x4(%rbp)
jmp 0x62f1
movq -0x10(%rbp), %rax
movl 0x11c0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x11c0(%rax)
jmp 0x60e7
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x338(%rax)
movq -0x10(%rbp), %rax
movq 0x338(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x6108
movl $0x7fffffff, -0x30(%rbp) # imm = 0x7FFFFFFF
jmp 0x61c2
movq -0x10(%rbp), %rax
movl 0x11c0(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0xb70(%rdx), %ecx
movb %al, -0x31(%rbp)
jge 0x6148
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq 0xb78(%rax,%rcx,8), %rdi
callq 0x6300
cmpq $0x0, %rax
sete %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x6151
jmp 0x615c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6115
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xb70(%rcx), %eax
jge 0x617d
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0x11c0(%rcx), %eax
movl %eax, -0x30(%rbp)
jmp 0x61c0
movq -0x10(%rbp), %rax
movq 0x338(%rax), %rax
movl 0x678(%rax), %eax
movq -0x10(%rbp), %rcx
movq 0x338(%rcx), %rcx
cmpl 0x67c(%rcx), %eax
jne 0x61b7
movq -0x10(%rbp), %rax
movq 0x338(%rax), %rax
movl 0x678(%rax), %eax
movl %eax, -0x30(%rbp)
jmp 0x61be
movl $0x7fffffff, -0x30(%rbp) # imm = 0x7FFFFFFF
jmp 0x61c0
jmp 0x61c2
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x11c0(%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0xb70(%rdx), %ecx
movb %al, -0x32(%rbp)
jge 0x61f0
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
setl %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0x61fc
jmp 0x6298
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x11c0(%rcx), %rcx
movq 0xb78(%rax,%rcx,8), %rdx
movq -0x10(%rbp), %rax
movq %rdx, 0x678(%rax)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x2c(%rbp)
movslq %ecx, %rcx
movq %rdx, 0x348(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq $0x0, 0x348(%rax,%rcx,8)
cmpl $0x64, -0x2c(%rbp)
jge 0x6254
jmp 0x6273
leaq 0x15192(%rip), %rdi     # 0x1b3ed
leaq 0x150c6(%rip), %rsi     # 0x1b328
movl $0x19e, %edx            # imm = 0x19E
leaq 0x15160(%rip), %rcx     # 0x1b3ce
callq 0x3200
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x670(%rax)
movq -0x10(%rbp), %rax
movl 0x11c0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x11c0(%rax)
jmp 0x61c9
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x338(%rcx), %rcx
cmpl 0x678(%rcx), %eax
jge 0x62c1
movq -0x10(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x6370
movl %eax, -0x4(%rbp)
jmp 0x62f1
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x338(%rcx), %rcx
cmpl 0x67c(%rcx), %eax
jle 0x62ea
movq -0x10(%rbp), %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x6370
movl %eax, -0x4(%rbp)
jmp 0x62f1
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)