// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movslq 0x11c0(%rdi), %r13
movslq 0xb70(%rdi), %r12
xorl %ebp, %ebp
cmpl %r12d, %r13d
jge 0x5751
movq %rdi, %rbx
movq 0xb78(%rdi,%r13,8), %r14
movq %r14, 0x678(%rdi)
testq %r14, %r14
je 0x5762
movb (%r14), %bpl
testb %bpl, %bpl
je 0x5781
leaq 0xef81(%rip), %rsi      # 0x14422
movl $0x2, %edx
movq %r14, %rdi
callq 0x30c0
leaq 0x2(%r14), %rcx
leaq 0x1(%r14), %rdx
xorl %r15d, %r15d
cmpb $0x2d, %bpl
cmoveq %rdx, %r15
testl %eax, %eax
cmoveq %rcx, %r15
testq %r15, %r15
je 0x5540
movq %r13, 0x10(%rsp)
movq $0x0, 0x338(%rbx)
movq 0x10(%rbx), %rbp
testq %rbp, %rbp
je 0x5523
leaq 0x18(%rbx), %r13
movq 0x8(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5431
testl %eax, %eax
je 0x550f
movq 0x10(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5431
testl %eax, %eax
jne 0x5516
movq %rbp, 0x338(%rbx)
movq (%r13), %rbp
addq $0x8, %r13
testq %rbp, %rbp
jne 0x54e9
cmpq $0x0, 0x338(%rbx)
je 0x5722
movq 0x10(%rsp), %rax
incl %eax
movl %eax, 0x11c0(%rbx)
jmp 0x554b
movq 0x8(%rbx), %rax
movq %rax, 0x338(%rbx)
movq 0x338(%rbx), %r10
cmpq 0x8(%rbx), %r10
je 0x5619
movq %r10, 0x18(%rsp)
movl 0x11c0(%rbx), %eax
movl %eax, 0xc(%rsp)
cmpl %r12d, %eax
setl %al
jge 0x55fc
movb %al, 0x10(%rsp)
movl 0xc(%rsp), %ebp
movslq %ebp, %r13
movq 0xb78(%rbx,%r13,8), %r14
leaq 0xee91(%rip), %rsi      # 0x14422
movl $0x2, %edx
movq %r14, %rdi
callq 0x30c0
testl %eax, %eax
je 0x55ea
leaq -0x1(%r12), %rax
movq %rax, 0x20(%rsp)
cmpb $0x2d, (%r14)
je 0x55ea
cmpq %r13, 0x20(%rsp)
je 0x55fc
leaq 0x1(%r13), %r15
cmpq %r12, %r15
setl 0x10(%rsp)
movq 0xb80(%rbx,%r13,8), %r14
movl $0x2, %edx
movq %r14, %rdi
leaq 0xee46(%rip), %rsi      # 0x14422
callq 0x30c0
incl %ebp
movq %r15, %r13
testl %eax, %eax
jne 0x55ac
testb $0x1, 0x10(%rsp)
je 0x55fc
subl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r10
jmp 0x561e
movq 0x18(%rsp), %r10
movl 0x678(%r10), %eax
cmpl 0x67c(%r10), %eax
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmovel %eax, %ebp
jmp 0x561e
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl 0x11c0(%rbx), %eax
xorl %ecx, %ecx
cmpl %r12d, %eax
jge 0x56e8
testl %ebp, %ebp
jle 0x56e8
movslq %eax, %rdx
movl %ebp, %esi
leaq (%rbx,%rdx,8), %rdi
addq $0xb80, %rdi            # imm = 0xB80
movq -0x8(%rdi), %rcx
movq %rcx, 0x678(%rbx)
movq %rcx, 0x348(%rbx)
movq $0x0, 0x350(%rbx)
incq %rdx
xorl %ecx, %ecx
leaq (%rdx,%rcx), %r8
cmpq %r12, %r8
jge 0x56d6
leaq 0x1(%rcx), %r8
cmpq %rsi, %r8
jae 0x56d6
movq (%rdi,%rcx,8), %r9
movq %r9, 0x678(%rbx)
movq %r9, 0x350(%rbx,%rcx,8)
movq $0x0, 0x358(%rbx,%rcx,8)
movq %r8, %rcx
cmpq $0x63, %r8
jne 0x5669
addl %eax, %r8d
movl $0x63, 0x670(%rbx)
movl %r8d, 0x11c0(%rbx)
leaq 0xed49(%rip), %rdi      # 0x14407
leaq 0xec7d(%rip), %rsi      # 0x14342
leaq 0xed1c(%rip), %rcx      # 0x143e8
movl $0x19e, %edx            # imm = 0x19E
callq 0x3210
addl %ecx, %eax
incl %eax
incl %ecx
movl %ecx, 0x670(%rbx)
movl %eax, 0x11c0(%rbx)
cmpl 0x678(%r10), %ecx
jge 0x5700
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
jmp 0x571b
movl $0x1, %ebp
cmpl 0x67c(%r10), %ecx
jle 0x5751
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x57a0
jmp 0x5751
movl $0xffffffff, 0x680(%rbx) # imm = 0xFFFFFFFF
addq $0x684, %rbx            # imm = 0x684
leaq 0xedef(%rip), %rdx      # 0x14529
movl $0x101, %esi            # imm = 0x101
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x31e0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe137(%rip), %rdi      # 0x138a0
leaq 0xebd2(%rip), %rsi      # 0x14342
leaq 0xec71(%rip), %rcx      # 0x143e8
movl $0x164, %edx            # imm = 0x164
callq 0x3210
leaq 0xec7c(%rip), %rdi      # 0x14404
leaq 0xebb3(%rip), %rsi      # 0x14342
leaq 0xec52(%rip), %rcx      # 0x143e8
movl $0x165, %edx            # imm = 0x165
callq 0x3210