// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, -0x30(%rbp)
movl %esi, -0x38(%rbp)
leaq 0x5c3b(%rip), %rax      # 0x96e0
movl $0x0, (%rax)
testq %r8, %r8
je 0x418f
movq %r9, %r14
movq %r8, %r12
movq %rcx, %r15
movq %rdi, %rbx
movl 0x10(%rbp), %r13d
movl $0x208, %edx            # imm = 0x208
xorl %esi, %esi
callq 0x2170
movl -0x38(%rbp), %eax
movl %eax, (%rbx)
movq -0x30(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movq %r14, 0x20(%rbx)
movl %r13d, 0x110(%rbx)
testl %r13d, %r13d
movq %rbx, -0x30(%rbp)
movq %r14, %r12
je 0x3b39
leaq 0x2df7(%rip), %r14      # 0x68fa
leaq 0x3412(%rip), %rdx      # 0x6f1c
movq %r14, %rdi
movl $0x84, %esi
movq %r15, %rcx
xorl %eax, %eax
callq 0x5224
leaq 0x3143(%rip), %rdx      # 0x6c66
movq %r14, %rdi
movq -0x30(%rbp), %rbx
movl $0x85, %esi
movq %r12, %rcx
xorl %eax, %eax
callq 0x5224
movw $0x3a2d, 0x28(%rbx)     # imm = 0x3A2D
movl $0x2, %ebx
testq %r15, %r15
movq %r12, -0x48(%rbp)
je 0x3cf6
movsbq (%r15), %r14
testq %r14, %r14
movl $0x0, %edi
je 0x3d9f
callq 0x2270
movq %rax, %r12
movq (%rax), %rax
testb $0x8, (%rax,%r14,2)
je 0x41ec
xorl %ebx, %ebx
xorl %edi, %edi
xorl %r13d, %r13d
movq %r12, -0x38(%rbp)
movq (%r12), %rax
movsbq (%r15,%rbx), %rcx
movzwl (%rax,%rcx,2), %eax
testb $0x8, %al
jne 0x3c00
cmpb $0x3a, %cl
movq -0x30(%rbp), %r14
jne 0x3d1f
cmpl $0x3a, %r13d
je 0x3d4b
cmpl $0x0, 0x10(%rbp)
je 0x3bd9
movl %edi, %r12d
leaq 0x2d3e(%rip), %rdi      # 0x68fa
movl $0xa8, %esi
leaq 0x319b(%rip), %rdx      # 0x6d63
movl %r13d, %ecx
xorl %eax, %eax
callq 0x5224
movl %r12d, %edi
movq -0x38(%rbp), %r12
movl $0x1, %eax
movl %r13d, %ecx
shlq %cl, %rax
shrl $0x3, %r13d
andl $0x18, %r13d
orq %rax, 0xb0(%r14,%r13)
incl 0x180(%r14)
jmp 0x3c85
movl %ecx, %eax
shrl $0x6, %eax
andl $0x3, %eax
movq -0x30(%rbp), %r14
movq 0x90(%r14,%rax,8), %rdx
movl $0x1, %esi
shlq %cl, %rsi
btq %rcx, %rdx
jb 0x3cfd
orq %rsi, %rdx
movq %rdx, 0x90(%r14,%rax,8)
testl %r13d, %r13d
je 0x3c6c
cmpl $0x3a, %r13d
je 0x3c6c
cmpl $0x0, 0x10(%rbp)
je 0x3c65
movl %edi, -0x3c(%rbp)
leaq 0x2cae(%rip), %rdi      # 0x68fa
movl $0x9a, %esi
leaq 0x307c(%rip), %rdx      # 0x6cd4
movl %r13d, %ecx
xorl %eax, %eax
callq 0x5224
movl -0x3c(%rbp), %edi
incl 0x180(%r14)
cmpl $0x63, %edi
jae 0x4151
movl %edi, %eax
movb (%r15,%rbx), %cl
incl %edi
movb %cl, 0x11c(%r14,%rax)
cmpq $0x61, %rbx
je 0x4113
movb (%r15,%rbx), %al
movb %al, 0x2a(%r14,%rbx)
movsbl (%r15,%rbx), %r13d
leaq 0x1(%rbx), %r14
cmpb $0x0, 0x1(%r15,%rbx)
movq %r14, %rbx
jne 0x3b84
addq $0x2, %r14
movb $0x1, %r15b
cmpl $0x0, 0x10(%rbp)
je 0x3cee
cmpb $0x3a, %r13b
je 0x3cee
movl %edi, %ebx
leaq 0x2c2e(%rip), %rdi      # 0x68fa
leaq 0x3001(%rip), %rdx      # 0x6cd4
movl $0xbd, %esi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x5224
movl %ebx, %edi
movq -0x30(%rbp), %rax
incl 0x180(%rax)
movq %r14, %rbx
jmp 0x3d90
xorl %edi, %edi
jmp 0x3d9f
movl %edi, %r14d
leaq 0x2bf3(%rip), %rdi      # 0x68fa
leaq 0x2f9c(%rip), %rdx      # 0x6caa
xorl %r15d, %r15d
movl $0x95, %esi
xorl %eax, %eax
callq 0x5224
jmp 0x3d6b
movl %edi, %r14d
addq $0x2, %rbx
leaq 0x2bcd(%rip), %rdi      # 0x68fa
btl $0xe, %eax
jb 0x3d74
leaq 0x307c(%rip), %rdx      # 0x6db6
xorl %r15d, %r15d
movl $0xb0, %esi
xorl %eax, %eax
callq 0x5224
jmp 0x3d8d
movl %edi, %r14d
leaq 0x2ba5(%rip), %rdi      # 0x68fa
leaq 0x2fd4(%rip), %rdx      # 0x6d30
xorl %r15d, %r15d
movl $0xa5, %esi
xorl %eax, %eax
callq 0x5224
movl %r14d, %edi
addq $0x2, %rbx
jmp 0x3d90
leaq 0x300b(%rip), %rdx      # 0x6d86
xorl %r15d, %r15d
movl $0xae, %esi
movl %ecx, %r8d
xorl %eax, %eax
callq 0x5224
movl %r14d, %edi
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %r15b, %r15b
je 0x40ca
movq -0x30(%rbp), %r14
leaq 0x28(%r14), %rax
movq %rax, -0x38(%rbp)
movslq %edi, %rax
movb $0x0, 0x11c(%r14,%rax)
movl 0x180(%r14), %eax
movl %eax, 0x184(%r14)
movq 0x18(%r14), %r12
cmpq $0x0, (%r12)
je 0x3f62
movq (%r12), %r13
movq %r13, %rdi
callq 0x20e0
movq -0x30(%rbp), %r14
cmpl %eax, 0x188(%r14)
jge 0x3df4
movl %eax, 0x188(%r14)
movslq 0x18(%r12), %r15
testq %r15, %r15
je 0x3e91
callq 0x2270
movq (%rax), %rax
testb $0x8, (%rax,%r15,2)
je 0x40f4
cmpl $0x0, 0x10(%rbp)
je 0x3e48
xorl %r9d, %r9d
cmpl $0x0, 0x8(%r12)
setne %r9b
leaq 0x2acb(%rip), %rdi      # 0x68fa
movl $0xd9, %esi
leaq 0x2f9f(%rip), %rdx      # 0x6dda
movl %r15d, %ecx
movq %r13, %r8
xorl %eax, %eax
callq 0x5224
movl 0x18(%r12), %ecx
movl %ecx, %eax
shrl $0x6, %eax
andl $0x3, %eax
movq 0x90(%r14,%rax,8), %rdx
movl $0x1, %esi
shlq %cl, %rsi
btq %rcx, %rdx
jae 0x3ec5
movq (%r12), %r8
xorl %r14d, %r14d
leaq 0x2a81(%rip), %rdi      # 0x68fa
movl $0xdb, %esi
leaq 0x2f7d(%rip), %rdx      # 0x6e02
xorl %eax, %eax
callq 0x5224
jmp 0x3f36
movl 0x8(%r12), %r8d
cmpl $0x2, %r8d
jae 0x4132
cmpl $0x0, 0x10(%rbp)
je 0x3f24
leaq 0x2a4d(%rip), %rdi      # 0x68fa
movl $0xeb, %esi
leaq 0x2f88(%rip), %rdx      # 0x6e41
movq %r13, %rcx
xorl %eax, %eax
callq 0x5224
jmp 0x3f24
orq %rdx, %rsi
movq %rsi, 0x90(%r14,%rax,8)
cmpl $0x63, %ebx
jae 0x4170
movl %ebx, %eax
movq -0x38(%rbp), %rdx
movb %cl, (%rdx,%rax)
incq %rax
movl 0x8(%r12), %ecx
testl %ecx, %ecx
je 0x3f26
cmpl $0x1, %ecx
jne 0x41ae
cmpl $0x62, %ebx
je 0x41cd
movb $0x3a, 0x28(%r14,%rax)
movl 0x18(%r12), %ecx
movl $0x1, %eax
shlq %cl, %rax
addl $0x2, %ebx
shrl $0x3, %ecx
andl $0x18, %ecx
orq %rax, 0xb0(%r14,%rcx)
movl %ebx, %eax
incl 0x184(%r14)
addq $0x20, %r12
movb $0x1, %r14b
movl %eax, %ebx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testb %r14b, %r14b
je 0x40ca
cmpq $0x0, (%r12)
jne 0x3dd4
testb %r14b, %r14b
movq -0x30(%rbp), %r14
movq -0x48(%rbp), %r15
jne 0x3f66
jmp 0x40ca
movq -0x48(%rbp), %r15
movslq %ebx, %rax
movq -0x38(%rbp), %rcx
movb $0x0, (%rcx,%rax)
testq %r15, %r15
je 0x3fe4
cmpb $0x0, (%r15)
je 0x3fe4
callq 0x2270
movq (%rax), %rax
incq %r15
movsbq -0x1(%r15), %rcx
movzwl (%rax,%rcx,2), %edx
testb $0x8, %dl
je 0x407a
movl %ecx, %edx
shrl $0x6, %edx
andl $0x3, %edx
movq 0x90(%r14,%rdx,8), %rdi
movl $0x1, %esi
shlq %cl, %rsi
btq %rcx, %rdi
jae 0x4095
orl $0x8, %edx
movq 0x90(%r14,%rdx,8), %rdi
testq %rsi, %rdi
jne 0x40aa
orq %rsi, %rdi
movq %rdi, 0x90(%r14,%rdx,8)
cmpb $0x0, (%r15)
leaq 0x1(%r15), %r15
jne 0x3f87
movq %r14, %rbx
movl 0x188(%r14), %r14d
leaq 0x1b4(%rbx), %rdi
leal 0xa(%r14), %ecx
leaq 0x2f02(%rip), %rdx      # 0x6f02
xorl %r13d, %r13d
movl $0x28, %esi
xorl %eax, %eax
callq 0x2110
leaq 0x18c(%rbx), %rdi
leal 0xc(%r14), %ecx
leaq 0x2ee3(%rip), %rdx      # 0x6f04
movl $0x28, %esi
xorl %eax, %eax
callq 0x2110
addq $0x1dc, %rbx            # imm = 0x1DC
addl $0xd, %r14d
leaq 0x2ece(%rip), %rdx      # 0x6f0d
movl $0x28, %esi
movq %rbx, %rdi
movl %r14d, %ecx
xorl %eax, %eax
callq 0x2110
cmpl $0x0, 0x10(%rbp)
je 0x40ca
leaq 0x289c(%rip), %rdi      # 0x68fa
leaq 0x2eb0(%rip), %rdx      # 0x6f15
xorl %r13d, %r13d
movl $0x11c, %esi            # imm = 0x11C
movq -0x38(%rbp), %rcx
xorl %eax, %eax
callq 0x5224
jmp 0x40ca
leaq 0x2879(%rip), %rdi      # 0x68fa
btl $0xe, %edx
jb 0x40dc
leaq 0x2e53(%rip), %rdx      # 0x6ee1
movl $0x10b, %esi            # imm = 0x10B
jmp 0x40bd
leaq 0x285e(%rip), %rdi      # 0x68fa
leaq 0x2dc2(%rip), %rdx      # 0x6e65
movl $0xff, %esi
jmp 0x40bd
leaq 0x2849(%rip), %rdi      # 0x68fa
leaq 0x2dd5(%rip), %rdx      # 0x6e8d
movl $0x103, %esi            # imm = 0x103
xorl %eax, %eax
callq 0x5224
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2dd1(%rip), %rdx      # 0x6eb4
movl $0x109, %esi            # imm = 0x109
movl %ecx, %r8d
xorl %eax, %eax
callq 0x5224
jmp 0x40c4
leaq 0x2922(%rip), %rdi      # 0x6a1d
leaq 0x27f8(%rip), %rsi      # 0x68fa
leaq 0x2aef(%rip), %rcx      # 0x6bf8
movl $0xd8, %edx
callq 0x2140
leaq 0x2b58(%rip), %rdi      # 0x6c72
leaq 0x27d9(%rip), %rsi      # 0x68fa
leaq 0x2ad0(%rip), %rcx      # 0x6bf8
movl $0xb5, %edx
callq 0x2140
leaq 0x2cf6(%rip), %rdi      # 0x6e2f
leaq 0x27ba(%rip), %rsi      # 0x68fa
leaq 0x2ab1(%rip), %rcx      # 0x6bf8
movl $0xe9, %edx
callq 0x2140
leaq 0x2b9f(%rip), %rdi      # 0x6cf7
leaq 0x279b(%rip), %rsi      # 0x68fa
leaq 0x2a92(%rip), %rcx      # 0x6bf8
movl $0x9e, %edx
callq 0x2140
leaq 0x2afb(%rip), %rdi      # 0x6c72
leaq 0x277c(%rip), %rsi      # 0x68fa
leaq 0x2a73(%rip), %rcx      # 0x6bf8
movl $0xdf, %edx
callq 0x2140
leaq 0x2c90(%rip), %rdi      # 0x6e26
leaq 0x275d(%rip), %rsi      # 0x68fa
leaq 0x2a54(%rip), %rcx      # 0x6bf8
movl $0x6f, %edx
callq 0x2140
leaq 0x2c7a(%rip), %rdi      # 0x6e2f
leaq 0x273e(%rip), %rsi      # 0x68fa
leaq 0x2a35(%rip), %rcx      # 0x6bf8
movl $0xe2, %edx
callq 0x2140
leaq 0x2a9e(%rip), %rdi      # 0x6c72
leaq 0x271f(%rip), %rsi      # 0x68fa
leaq 0x2a16(%rip), %rcx      # 0x6bf8
movl $0xe3, %edx
callq 0x2140
leaq 0x2aaa(%rip), %rdi      # 0x6c9d
leaq 0x2700(%rip), %rsi      # 0x68fa
leaq 0x29f7(%rip), %rcx      # 0x6bf8
movl $0x91, %edx
callq 0x2140