// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/getopt_x.c
// Function: getopt_x_prepare0
static int getopt_x_prepare0(struct getopt_x *state, int argc, char **argv, const char *optstring, struct option *longopts, const char *optreq, int verbose)
{
	int optstring_len = 0;
	int optstring0_alnum_len = 0;

	opterr = 0; /* prevent the error message */

#ifdef GETOPTX_CHECK_FUNDAMENTALS
	/* fundamental assumptions
	 */

	assert(required_argument == 1);
	assert(FD_SETSIZE == 1024);
	assert(BYTE_PLANE_0(0) == 0);
	assert(BYTE_PLANE_0(255) == 255);
	assert(BYTE_PLANE_1(0) == 256);
	assert(BYTE_PLANE_1(255) == 256+255);
	assert(BYTE_PLANE_2(0) == 512);
	assert(BYTE_PLANE_2(255) == 512+255);
	assert(BYTE_PLANE_3(0) == 768);
	assert(BYTE_PLANE_3(255) == 768+255);
	assert(BYTE_PLANE_3(255) == FD_SETSIZE-1);
#endif

	/* sanity check
	 */

	assert(longopts);

	/* initialize
	 */

	memset(state, 0, sizeof(struct getopt_x));
	/* FD_ZERO(state->optset); */

	state->argc = argc;
	state->argv = argv;
	state->optstring0 = optstring;
	state->longopts = longopts;

	state->optreq = optreq;

	state->verbose = verbose;

	/* optstring
	 */

	if (verbose) {
		DEBUG("optstring=[%s]", optstring);
		DEBUG("optreq=[%s]", optreq);
	}

	assert(optstring_len < sizeof(state->optstring)-1);
	state->optstring[optstring_len++] = '-'; /* this turn non-option arguments swap off */

	assert(optstring_len < sizeof(state->optstring)-1);
	state->optstring[optstring_len++] = ':'; /* this diferentiates error from unknown option */

	if (optstring && *optstring) {
		int prior = 0;
		const char *cp = optstring;
		assert(isalnum(*cp));
		do {
			if (isalnum(*cp)) {
				if (FD_ISSET_IS_OPT(*cp, state->optset)) {
					DEBUG("error: duplicate option '%c' in optstring", *cp);
					return -1;
				}
				FD_SET_IS_OPT(*cp, state->optset);
				if (prior && prior != ':') {
					if (verbose) DEBUG("found short option -%c, has arg? 0", prior);
					state->n_short_options++;
				}

				assert(optstring0_alnum_len < sizeof(state->optstring0_alnum)-1);
				state->optstring0_alnum[optstring0_alnum_len++] = *cp;
			} else if (*cp == ':') {
				if (prior == ':') {
					/* optional arguments not allowed here, use
					 * ':' in return of getopt
					 */
					DEBUG("error: optional arguments not allowed in optstring");
					return -1;
				} else {
					if (verbose) DEBUG("found short option -%c, has arg? 1", prior);
					FD_SET_HAS_ARG(prior, state->optset);
					state->n_short_options++;
				}
			} else {
				if (isprint(*cp)) {
					DEBUG("error: invalid char '%c' (byte %i) in optstring", *cp, *cp);
				} else {
					DEBUG("error: invalid byte %i in optstring", *cp);
				}
				return -1;
			}

			assert(optstring_len < sizeof(state->optstring)-1);
			state->optstring[optstring_len++] = *cp;

			prior = *cp;
		} while (*++cp);

		if (verbose) {
			if (prior != ':') {
				DEBUG("found short option -%c, has arg? 0", prior);
				state->n_short_options++;
			}
		}
	}

	/* close state->optstring0_alnum
	 */

	state->optstring0_alnum[optstring0_alnum_len++] = 0;

	/* DEBUG("state->optstring0_alnum=[%s]", state->optstring0_alnum);
	 */

	/* state->longopts
	 */

	state->n_all_options = state->n_short_options;

	if (state->longopts->name) {
		struct option *opt = state->longopts;
		do {
			int namelen;
			if ((namelen = strlen(opt->name)) > state->longest_name_option) {
				state->longest_name_option = namelen;
			}
			if (opt->val) {
				assert(isalnum(opt->val));
				if (verbose) DEBUG("found long option -%c/--%s, has arg? %i", opt->val, opt->name, !!opt->has_arg);
				if (FD_ISSET_IS_OPT(opt->val, state->optset)) {
					DEBUG("error: duplicate option -%c/--%s in longopts", opt->val, opt->name);
					return -1;
				}
				FD_SET_IS_OPT(opt->val, state->optset);
				assert(optstring_len < sizeof(state->optstring)-1);
				state->optstring[optstring_len++] = opt->val;
				if (opt->has_arg) {
					assert(opt->has_arg == 1); /* optional arguments not allowed */
					assert(optstring_len < sizeof(state->optstring)-1);
					state->optstring[optstring_len++] = ':';
					FD_SET_HAS_ARG(opt->val, state->optset);
				}
			} else {
				if (opt->has_arg) {
					assert(opt->has_arg == 1); /* optional arguments not allowed */
				}
				if (verbose) DEBUG("found long option --%s, has arg? %i", opt->name, !!opt->has_arg);
			}
			state->n_all_options++;
			opt++;
		} while (opt->name);
	}

	/* close state->optstring
	 */

	state->optstring[optstring_len++] = 0;

	/* optreq
	 */

	if (optreq && *optreq) {
		const char *cp = optreq;
		do {
			if (isalnum(*cp)) {
				if (!FD_ISSET_IS_OPT(*cp, state->optset)) {
					DEBUG("error: unknown option '%c' in optstring", *cp);
					return -1;
				}
				if (FD_ISSET_IS_REQUIRED(*cp, state->optset)) {
					DEBUG("error: duplicate option '%c' in optreq", *cp);
					return -1;
				}
				FD_SET_IS_REQUIRED(*cp, state->optset);
			} else {
				if (isprint(*cp)) {
					DEBUG("error: invalid char '%c' (byte %i) in optreq", *cp, *cp);
				} else {
					DEBUG("error: invalid byte %i in optreq", *cp);
				}
				return -1;
			}
		} while (*++cp);
	}

	{
		int i = state->longest_name_option + 4;
		snprintf(state->fmt_both, sizeof(state->fmt_both), ", --%%-%is", i + 6);
		snprintf(state->fmt_long, sizeof(state->fmt_long), "--%%-%is", i + 8);
		snprintf(state->fmt_short, sizeof(state->fmt_short), " %%-%is", i + 9);
	}

	/*
	 */

	if (verbose) DEBUG("state->optstring=[%s]", state->optstring);

#ifdef OPTSET_VERIFY
	optset_verify(state->optset);
#endif
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
leaq 0x5dc5(%rip), %rax      # 0x86d0
andl $0x0, (%rax)
testq %r8, %r8
je 0x2f9b
movq %r8, %r12
movq %rcx, %r15
movl %esi, %r14d
movq %rdi, %rbx
movl 0x10(%rbp), %r13d
movl $0x208, %edx            # imm = 0x208
xorl %esi, %esi
callq 0x1170
movl %r14d, (%rbx)
movq -0x30(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq -0x38(%rbp), %r12
movq %r12, 0x20(%rbx)
movl %r13d, 0x110(%rbx)
testl %r13d, %r13d
je 0x2993
leaq 0x2f96(%rip), %r14      # 0x58f7
leaq 0x35b1(%rip), %rdx      # 0x5f19
movq %r14, %rdi
movl $0x84, %esi
movq %r15, %rcx
xorl %eax, %eax
callq 0x4030
leaq 0x32e2(%rip), %rdx      # 0x5c63
movq %r14, %rdi
movl $0x85, %esi
movq %r12, %rcx
xorl %eax, %eax
callq 0x4030
movw $0x3a2d, 0x28(%rbx)     # imm = 0x3A2D
pushq $0x2
popq %r14
testq %r15, %r15
je 0x2b33
movsbq (%r15), %r12
testq %r12, %r12
movl $0x0, %edi
je 0x2b35
callq 0x1260
movq %rax, %r8
movq (%rax), %rax
testb $0x8, (%rax,%r12,2)
je 0x2fb8
xorl %r14d, %r14d
xorl %edi, %edi
xorl %r13d, %r13d
movq %r8, -0x30(%rbp)
movq (%r8), %rax
movsbl %r12b, %ecx
movsbq %cl, %rdx
movzwl (%rax,%rdx,2), %eax
testb $0x8, %al
jne 0x2a52
cmpb $0x3a, %r12b
jne 0x2e05
cmpl $0x3a, %r13d
je 0x2e20
cmpl $0x0, 0x10(%rbp)
je 0x2a2e
movl %edi, %r12d
leaq 0x2ee6(%rip), %rdi      # 0x58f7
movl $0xa8, %esi
leaq 0x3343(%rip), %rdx      # 0x5d60
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4030
movq -0x30(%rbp), %r8
movl %r12d, %edi
pushq $0x1
popq %rax
movl %r13d, %ecx
shlq %cl, %rax
shrl $0x3, %r13d
andl $0x18, %r13d
orq %rax, 0xb0(%rbx,%r13)
incl 0x180(%rbx)
jmp 0x2ad3
movl %ecx, %eax
shrl $0x6, %eax
andl $0x3, %eax
movq 0x90(%rbx,%rax,8), %rdx
pushq $0x1
popq %rsi
shlq %cl, %rsi
btq %rcx, %rdx
jb 0x2df0
orq %rsi, %rdx
movq %rdx, 0x90(%rbx,%rax,8)
testl %r13d, %r13d
je 0x2abb
cmpl $0x3a, %r13d
je 0x2abb
cmpl $0x0, 0x10(%rbp)
je 0x2ab5
movl %edi, %r12d
leaq 0x2e5f(%rip), %rdi      # 0x58f7
movl $0x9a, %esi
leaq 0x322d(%rip), %rdx      # 0x5cd1
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4030
movq -0x30(%rbp), %r8
movl %r12d, %edi
incl 0x180(%rbx)
cmpl $0x63, %edi
jae 0x2f7c
movl %edi, %eax
movb (%r15,%r14), %cl
incl %edi
movb %cl, 0x11c(%rbx,%rax)
cmpq $0x61, %r14
je 0x2f00
movsbl (%r15,%r14), %r13d
movb %r13b, 0x2a(%rbx,%r14)
movb 0x1(%r15,%r14), %r12b
incq %r14
testb %r12b, %r12b
jne 0x29da
addq $0x2, %r14
cmpl $0x0, 0x10(%rbp)
je 0x2b35
cmpb $0x3a, %r13b
je 0x2b35
movl %edi, %r15d
leaq 0x2de5(%rip), %rdi      # 0x58f7
leaq 0x31b8(%rip), %rdx      # 0x5cd1
movl $0xbd, %esi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4030
movl %r15d, %edi
incl 0x180(%rbx)
jmp 0x2b35
xorl %edi, %edi
leaq 0x28(%rbx), %rax
movq %rax, -0x30(%rbp)
movslq %edi, %rax
movb $0x0, 0x11c(%rbx,%rax)
movl 0x180(%rbx), %eax
movl %eax, 0x184(%rbx)
movq 0x18(%rbx), %r15
movq (%r15), %r13
testq %r13, %r13
je 0x2ca8
addq $0x20, %r15
movq %r13, %rdi
callq 0x10e0
cmpl %eax, 0x188(%rbx)
jge 0x2b7e
movl %eax, 0x188(%rbx)
movslq -0x8(%r15), %r12
testq %r12, %r12
je 0x2c59
callq 0x1260
movq (%rax), %rax
testb $0x8, (%rax,%r12,2)
je 0x2ec2
cmpl $0x0, 0x10(%rbp)
je 0x2bd4
xorl %r9d, %r9d
cmpl $0x0, -0x18(%r15)
setne %r9b
leaq 0x2d40(%rip), %rdi      # 0x58f7
movl $0xd9, %esi
leaq 0x3214(%rip), %rdx      # 0x5dd7
movl %r12d, %ecx
movq %r13, %r8
xorl %eax, %eax
callq 0x4030
movl -0x8(%r15), %r12d
movl %r12d, %eax
shrl $0x6, %eax
andl $0x3, %eax
movq 0x90(%rbx,%rax,8), %rdx
pushq $0x1
popq %rsi
movl %r12d, %ecx
shlq %cl, %rsi
btq %r12, %rdx
jb 0x2dca
orq %rdx, %rsi
movq %rsi, 0x90(%rbx,%rax,8)
cmpl $0x63, %r14d
jae 0x2ee1
movl %r14d, %eax
movq -0x30(%rbp), %rcx
movb %r12b, (%rcx,%rax)
incq %rax
movl -0x18(%r15), %ecx
testl %ecx, %ecx
je 0x2c8d
cmpl $0x1, %ecx
jne 0x2f3e
cmpl $0x62, %r14d
je 0x2f5d
movb $0x3a, 0x28(%rbx,%rax)
movl -0x8(%r15), %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
addl $0x2, %r14d
shrl $0x3, %ecx
andl $0x18, %ecx
orq %rax, 0xb0(%rbx,%rcx)
jmp 0x2c8a
movl -0x18(%r15), %r8d
cmpl $0x2, %r8d
jae 0x2f1f
cmpl $0x0, 0x10(%rbp)
je 0x2c8a
leaq 0x2c83(%rip), %rdi      # 0x58f7
movl $0xeb, %esi
leaq 0x31be(%rip), %rdx      # 0x5e3e
movq %r13, %rcx
xorl %eax, %eax
callq 0x4030
movl %r14d, %eax
incl 0x184(%rbx)
movq (%r15), %r13
addq $0x20, %r15
movl %eax, %r14d
testq %r13, %r13
jne 0x2b68
jmp 0x2cab
movl %r14d, %eax
cltq
movq -0x30(%rbp), %rcx
movb $0x0, (%rcx,%rax)
movq -0x38(%rbp), %r15
testq %r15, %r15
je 0x2d30
movb (%r15), %r14b
testb %r14b, %r14b
je 0x2d30
callq 0x1260
movq (%rax), %rax
incq %r15
movsbl %r14b, %ecx
movsbq %cl, %rdx
movzwl (%rax,%rdx,2), %edx
testb $0x8, %dl
je 0x2e3c
movl %ecx, %edx
shrl $0x6, %edx
andl $0x3, %edx
movq 0x90(%rbx,%rdx,8), %rdi
pushq $0x1
popq %rsi
shlq %cl, %rsi
btq %rcx, %rdi
jae 0x2e57
orl $0x8, %edx
movq 0x90(%rbx,%rdx,8), %rdi
testq %rsi, %rdi
jne 0x2e6c
orq %rsi, %rdi
movq %rdi, 0x90(%rbx,%rdx,8)
movb (%r15), %r14b
incq %r15
testb %r14b, %r14b
jne 0x2cd1
movl 0x188(%rbx), %r12d
leaq 0x1b4(%rbx), %rdi
leal 0xa(%r12), %ecx
leaq 0x31b5(%rip), %rdx      # 0x5eff
xorl %r14d, %r14d
pushq $0x28
popq %r13
movq %r13, %rsi
xorl %eax, %eax
callq 0x1110
leaq 0x18c(%rbx), %rdi
leal 0xc(%r12), %ecx
leaq 0x3193(%rip), %rdx      # 0x5f01
movq %r13, %rsi
xorl %eax, %eax
callq 0x1110
addq $0x1dc, %rbx            # imm = 0x1DC
addl $0xd, %r12d
leaq 0x3180(%rip), %rdx      # 0x5f0a
movq %rbx, %rdi
movq %r13, %rsi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x1110
cmpl $0x0, 0x10(%rbp)
je 0x2eb0
leaq 0x2b4c(%rip), %rdi      # 0x58f7
leaq 0x3160(%rip), %rdx      # 0x5f12
xorl %r14d, %r14d
movl $0x11c, %esi            # imm = 0x11C
movq -0x30(%rbp), %rcx
xorl %eax, %eax
callq 0x4030
jmp 0x2eb0
movq -0x20(%r15), %r8
leaq 0x2b22(%rip), %rdi      # 0x58f7
leaq 0x3023(%rip), %rdx      # 0x5dff
movl $0xdb, %esi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x4030
jmp 0x2eac
leaq 0x2b00(%rip), %rdi      # 0x58f7
leaq 0x2ea9(%rip), %rdx      # 0x5ca7
movl $0x95, %esi
jmp 0x2e7f
leaq 0x2aeb(%rip), %rdi      # 0x58f7
btl $0xe, %eax
jb 0x2e88
leaq 0x2f9a(%rip), %rdx      # 0x5db3
movl $0xb0, %esi
jmp 0x2e7f
leaq 0x2ad0(%rip), %rdi      # 0x58f7
leaq 0x2eff(%rip), %rdx      # 0x5d2d
movl $0xa5, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x2eac
leaq 0x2ab4(%rip), %rdi      # 0x58f7
btl $0xe, %edx
jb 0x2e96
leaq 0x308e(%rip), %rdx      # 0x5ede
movl $0x10b, %esi            # imm = 0x10B
jmp 0x2e7f
leaq 0x2a99(%rip), %rdi      # 0x58f7
leaq 0x2ffd(%rip), %rdx      # 0x5e62
movl $0xff, %esi
jmp 0x2e7f
leaq 0x2a84(%rip), %rdi      # 0x58f7
leaq 0x3010(%rip), %rdx      # 0x5e8a
movl $0x103, %esi            # imm = 0x103
xorl %eax, %eax
callq 0x4030
jmp 0x2eac
leaq 0x2ef4(%rip), %rdx      # 0x5d83
movl $0xae, %esi
jmp 0x2ea2
leaq 0x3014(%rip), %rdx      # 0x5eb1
movl $0x109, %esi            # imm = 0x109
movl %ecx, %r8d
xorl %eax, %eax
callq 0x4030
pushq $-0x1
popq %r14
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b51(%rip), %rdi      # 0x5a1a
leaq 0x2a27(%rip), %rsi      # 0x58f7
leaq 0x2d1e(%rip), %rcx      # 0x5bf5
movl $0xd8, %edx
callq 0x1140
leaq 0x2d87(%rip), %rdi      # 0x5c6f
leaq 0x2a08(%rip), %rsi      # 0x58f7
leaq 0x2cff(%rip), %rcx      # 0x5bf5
movl $0xdf, %edx
callq 0x1140
leaq 0x2d68(%rip), %rdi      # 0x5c6f
leaq 0x29e9(%rip), %rsi      # 0x58f7
leaq 0x2ce0(%rip), %rcx      # 0x5bf5
movl $0xb5, %edx
callq 0x1140
leaq 0x2f06(%rip), %rdi      # 0x5e2c
leaq 0x29ca(%rip), %rsi      # 0x58f7
leaq 0x2cc1(%rip), %rcx      # 0x5bf5
movl $0xe9, %edx
callq 0x1140
leaq 0x2ee7(%rip), %rdi      # 0x5e2c
leaq 0x29ab(%rip), %rsi      # 0x58f7
leaq 0x2ca2(%rip), %rcx      # 0x5bf5
movl $0xe2, %edx
callq 0x1140
leaq 0x2d0b(%rip), %rdi      # 0x5c6f
leaq 0x298c(%rip), %rsi      # 0x58f7
leaq 0x2c83(%rip), %rcx      # 0x5bf5
movl $0xe3, %edx
callq 0x1140
leaq 0x2d71(%rip), %rdi      # 0x5cf4
leaq 0x296d(%rip), %rsi      # 0x58f7
leaq 0x2c64(%rip), %rcx      # 0x5bf5
movl $0x9e, %edx
callq 0x1140
leaq 0x2e81(%rip), %rdi      # 0x5e23
leaq 0x294e(%rip), %rsi      # 0x58f7
leaq 0x2c45(%rip), %rcx      # 0x5bf5
pushq $0x6f
popq %rdx
callq 0x1140
leaq 0x2cdb(%rip), %rdi      # 0x5c9a
leaq 0x2931(%rip), %rsi      # 0x58f7
leaq 0x2c28(%rip), %rcx      # 0x5bf5
movl $0x91, %edx
callq 0x1140