// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/getopt_x.c
// Function: getopt_x_next
int getopt_x_next(struct getopt_x *state, struct option **opt)
{
	int c;
	int index;

	if (state->got_error) {
		return -1;
	}

	if (state->got_dashdash) {
		if (optind == state->argc) return -1;
		optarg = state->argv[optind++];
		return 1;
	}

	index = -1;

	if ((c = getopt_long(state->argc, state->argv, state->optstring, state->longopts, &index)) == -1) {
		if (optind < state->argc) {
			assert(strcmp(state->argv[optind - 1], "--") == 0);
			state->got_dashdash = 1;
			optarg = state->argv[optind++];
			return 1;
		}
		if (state->optreq && *state->optreq) {
			const char *cp = state->optreq;
			do {
				if (!FD_ISSET_OPT_INFORMED(*cp, state->optset)) {
					DEBUG("error: option -%c is required", *cp);
					state->got_error = -1;
				}
			} while (*++cp);
		}
		return -1;
	}

	//DEBUG("c=%c/%i, index=%i, optopt=%c/%i", c, c, *indexp, optopt, optopt);

	/* sanity check
	 */

	switch (c) {
	case ':':
		if (optopt) {
			if (FD_ISSET_HAS_ARG(optopt, state->optset)) {
				DEBUG("error: option -%c need an argument", optopt);
			} else {
				DEBUG("error: option -%c does not accept an argument", optopt);
			}
		} else {
			DEBUG("error: invalid argument [%s], index=%i", state->argv[optind - 1], index);
		}
		state->got_error = 1;
		return -1;
	case '?': break; /* unknown */
	case 0: break; /* long option only */
	default:
		FD_SET_OPT_INFORMED(c, state->optset);
	}

	if (opt) {
		if (index >= 0) {
			*opt = &state->longopts[index];
		} else {
			*opt = NULL;
		}
	}

	return c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $-0x1
popq %r14
cmpl $0x0, 0x114(%rdi)
je 0x301e
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
cmpl $0x0, 0x118(%rdi)
je 0x3055
leaq 0x56a3(%rip), %rax      # 0x86d4
movslq (%rax), %rcx
cmpl (%rbx), %ecx
je 0x300c
movq 0x8(%rbx), %rdx
leal 0x1(%rcx), %esi
movl %esi, (%rax)
movq (%rdx,%rcx,8), %rax
leaq 0x56bc(%rip), %rcx      # 0x8708
movq %rax, (%rcx)
pushq $0x1
popq %r14
jmp 0x300c
movq %rsi, %r15
leaq -0x2c(%rbp), %r8
orl $-0x1, (%r8)
movl (%rbx), %edi
movq 0x8(%rbx), %rsi
leaq 0x28(%rbx), %rdx
movq 0x18(%rbx), %rcx
callq 0x3c99
cmpl $0x3f, %eax
je 0x3135
testl %eax, %eax
je 0x3135
cmpl $0x3a, %eax
je 0x30d9
cmpl $-0x1, %eax
jne 0x311d
leaq 0x563b(%rip), %rax      # 0x86d4
movslq (%rax), %rcx
cmpl (%rbx), %ecx
jge 0x315c
movq 0x8(%rbx), %rdx
movq -0x8(%rdx,%rcx,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x3220
cmpb $0x2d, 0x1(%rsi)
jne 0x3220
cmpb $0x0, 0x2(%rsi)
jne 0x3220
movl $0x1, 0x118(%rbx)
jmp 0x303c
leaq 0x55f8(%rip), %rax      # 0x86d8
movl (%rax), %ecx
testq %rcx, %rcx
je 0x31cb
movl %ecx, %eax
shrl $0x3, %eax
andl $0x18, %eax
movq 0xb0(%rbx,%rax), %rax
leaq 0x27f5(%rip), %rdi      # 0x58f7
btq %rcx, %rax
jae 0x31fe
leaq 0x2849(%rip), %rdx      # 0x595c
movl $0x15b, %esi            # imm = 0x15B
jmp 0x320a
pushq $0x1
popq %rdx
movl %eax, %ecx
shlq %cl, %rdx
movl %eax, %ecx
shrl $0x3, %ecx
andl $0x18, %ecx
orq %rdx, 0xf0(%rbx,%rcx)
testq %r15, %r15
je 0x3154
movslq -0x2c(%rbp), %rcx
testq %rcx, %rcx
js 0x3150
shlq $0x5, %rcx
addq 0x18(%rbx), %rcx
movq %rcx, (%r15)
jmp 0x3154
andq $0x0, (%r15)
movl %eax, %r14d
jmp 0x300c
movq 0x20(%rbx), %r13
testq %r13, %r13
je 0x300c
movb (%r13), %al
testb %al, %al
je 0x300c
incq %r13
leaq 0x2778(%rip), %r15      # 0x58f7
leaq 0x27b8(%rip), %r12      # 0x593e
movsbl %al, %ecx
movl %ecx, %eax
shrl $0x3, %eax
andl $0x18, %eax
movq 0xf0(%rbx,%rax), %rax
movzbl %cl, %edx
btq %rdx, %rax
jb 0x31bb
movq %r15, %rdi
movl $0x14a, %esi            # imm = 0x14A
movq %r12, %rdx
xorl %eax, %eax
callq 0x4030
orl $-0x1, 0x114(%rbx)
movb (%r13), %al
incq %r13
testb %al, %al
jne 0x3186
jmp 0x300c
movq 0x8(%rbx), %rax
leaq 0x54fe(%rip), %rcx      # 0x86d4
movslq (%rcx), %rcx
movq -0x8(%rax,%rcx,8), %rcx
movl -0x2c(%rbp), %r8d
leaq 0x270e(%rip), %rdi      # 0x58f7
leaq 0x27bd(%rip), %rdx      # 0x59ad
movl $0x160, %esi            # imm = 0x160
xorl %eax, %eax
callq 0x4030
jmp 0x3211
leaq 0x277a(%rip), %rdx      # 0x597f
movl $0x15d, %esi            # imm = 0x15D
xorl %eax, %eax
callq 0x4030
movl $0x1, 0x114(%rbx)
jmp 0x300c
leaq 0x26a5(%rip), %rdi      # 0x58cc
leaq 0x26c9(%rip), %rsi      # 0x58f7
leaq 0x26cd(%rip), %rcx      # 0x5902
movl $0x141, %edx            # imm = 0x141
callq 0x1140