// File: /workspace/github_c_makefile_star2_O1/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
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x0, 0x114(%rdi)
je 0x4254
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 0x428d
leaq 0x547d(%rip), %rax      # 0x96e4
movslq (%rax), %rcx
cmpl (%rbx), %ecx
je 0x4242
movq 0x8(%rbx), %rdx
leal 0x1(%rcx), %esi
movl %esi, (%rax)
movq (%rdx,%rcx,8), %rax
leaq 0x5496(%rip), %rcx      # 0x9718
movq %rax, (%rcx)
movl $0x1, %r14d
jmp 0x4242
movq %rsi, %r15
leaq -0x2c(%rbp), %r8
movl $0xffffffff, (%r8)      # imm = 0xFFFFFFFF
movl (%rbx), %edi
movq 0x8(%rbx), %rsi
leaq 0x28(%rbx), %rdx
movq 0x18(%rbx), %rcx
callq 0x4e93
cmpl $0x39, %eax
jg 0x42be
cmpl $-0x1, %eax
je 0x430c
testl %eax, %eax
je 0x42e6
jmp 0x42cc
cmpl $0x3a, %eax
je 0x4357
cmpl $0x3f, %eax
je 0x42e6
movl $0x1, %edx
movl %eax, %ecx
shlq %cl, %rdx
movl %eax, %ecx
shrl $0x3, %ecx
andl $0x18, %ecx
orq %rdx, 0xf0(%rbx,%rcx)
testq %r15, %r15
je 0x43a2
movslq -0x2c(%rbp), %rcx
testq %rcx, %rcx
js 0x439b
shlq $0x5, %rcx
addq 0x18(%rbx), %rcx
movq %rcx, (%r15)
jmp 0x43a2
leaq 0x53d1(%rip), %r15      # 0x96e4
movslq (%r15), %r12
cmpl (%rbx), %r12d
jge 0x43aa
movq 0x8(%rbx), %r14
movq -0x8(%r14,%r12,8), %rdi
leaq 0x259d(%rip), %rsi      # 0x68cc
callq 0x21a0
testl %eax, %eax
jne 0x446f
movl $0x1, 0x118(%rbx)
leal 0x1(%r12), %eax
movl %eax, (%r15)
movq (%r14,%r12,8), %rax
jmp 0x427b
leaq 0x538a(%rip), %rax      # 0x96e8
movl (%rax), %ecx
testq %rcx, %rcx
je 0x441a
movl %ecx, %eax
shrl $0x3, %eax
andl $0x18, %eax
movq 0xb0(%rbx,%rax), %rax
leaq 0x257a(%rip), %rdi      # 0x68fa
btq %rcx, %rax
jae 0x444d
leaq 0x25ce(%rip), %rdx      # 0x695f
movl $0x15b, %esi            # imm = 0x15B
jmp 0x4459
movq $0x0, (%r15)
movl %eax, %r14d
jmp 0x4242
movq 0x20(%rbx), %r13
testq %r13, %r13
je 0x4242
cmpb $0x0, (%r13)
je 0x4242
incq %r13
leaq 0x252e(%rip), %r15      # 0x68fa
leaq 0x256e(%rip), %r12      # 0x6941
movsbl -0x1(%r13), %ecx
movl %ecx, %eax
shrl $0x3, %eax
andl $0x18, %eax
movq 0xf0(%rbx,%rax), %rax
btq %rcx, %rax
jb 0x440a
movq %r15, %rdi
movl $0x14a, %esi            # imm = 0x14A
movq %r12, %rdx
xorl %eax, %eax
callq 0x5224
movl $0xffffffff, 0x114(%rbx) # imm = 0xFFFFFFFF
cmpb $0x0, (%r13)
leaq 0x1(%r13), %r13
jne 0x43d3
jmp 0x4242
movq 0x8(%rbx), %rax
leaq 0x52bf(%rip), %rcx      # 0x96e4
movslq (%rcx), %rcx
movq -0x8(%rax,%rcx,8), %rcx
movl -0x2c(%rbp), %r8d
leaq 0x24c2(%rip), %rdi      # 0x68fa
leaq 0x2571(%rip), %rdx      # 0x69b0
movl $0x160, %esi            # imm = 0x160
xorl %eax, %eax
callq 0x5224
jmp 0x4460
leaq 0x252e(%rip), %rdx      # 0x6982
movl $0x15d, %esi            # imm = 0x15D
xorl %eax, %eax
callq 0x5224
movl $0x1, 0x114(%rbx)
jmp 0x4242
leaq 0x2459(%rip), %rdi      # 0x68cf
leaq 0x247d(%rip), %rsi      # 0x68fa
leaq 0x2481(%rip), %rcx      # 0x6905
movl $0x141, %edx            # imm = 0x141
callq 0x2140