// File: /workspace/github_c_makefile_star2_O3/j-hoppe[P]tu58fs/getopt2.c
// Function: getopt_first
int getopt_first(getopt_t *_this, int argc, char **argv)
{
	int	i;
	char	*cb = _this->default_cmdline_buff; // alias
	getopt_option_descr_t *odesc;
	char	*token;

	// for all options with "default" args:
	// put strings <option> <args> in front of commandline,
	// so they are parsed first and overwritten later by actual values
	// 1) build own cmdline
	*cb = 0; // clear
	for (i = 0; (odesc = _this->option_descrs[i]); i++)
		if (odesc->default_args && strlen(odesc->default_args)) {
			strcat(cb, "--");
			strcat(cb, odesc->long_name);
			strcat(cb, " ");
			strcat(cb, odesc->default_args);
			strcat(cb, " ");
		}
	// 2) separate into words and add to argv
	// Input in cb like : char space char char space space char char char space 0
	token = cb;
	while (*token) {
		// last token terminated with 0.
		// clear white space before next token
		while (*token && isspace(*token)) *token++ = 0;
		if (*token) {
			// add to arg list
			assert(_this->argc < GETOPT_MAX_CMDLINE_TOKEN);
			_this->argv[_this->argc++] = token;
			// skip and terminate token
			while (*token && !isspace(*token)) token++;
			if (*token) // convert terminating space to 0
				*token++ = 0;
		}
	}

	// 3) append user commandline tokens, so they are processed after defaults
	for (i = 1; i < argc; i++) { // skip program name of
		assert(_this->argc < GETOPT_MAX_CMDLINE_TOKEN);
		_this->argv[_this->argc++] = argv[i];
	}

	_this->cur_cline_arg_idx = 0;
	_this->cur_option = NULL;
	_this->cur_option_argval[0] = NULL;
	_this->cur_option_argvalcount = 0;

	return getopt_next(_this);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, %rbx
movb $0x0, 0x785(%rdi)
movq 0x10(%rdi), %rbp
testq %rbp, %rbp
je 0x5933
movl %r12d, 0x4(%rsp)
leaq 0x785(%rbx), %r15
leaq 0x18(%rbx), %r12
movw $0x20, %r13w
movq 0x680(%rbp), %rax
testq %rax, %rax
je 0x58a3
cmpb $0x0, (%rax)
je 0x58a3
movq %r15, %rdi
callq 0x3190
movw $0x2d2d, (%r15,%rax)    # imm = 0x2D2D
movb $0x0, 0x2(%r15,%rax)
movq 0x10(%rbp), %rsi
movq %r15, %rdi
callq 0x3510
movq %r15, %rdi
callq 0x3190
movw %r13w, (%r15,%rax)
movq 0x680(%rbp), %rsi
movq %r15, %rdi
callq 0x3510
movq %r15, %rdi
callq 0x3190
movw %r13w, (%r15,%rax)
movq (%r12), %rbp
addq $0x8, %r12
testq %rbp, %rbp
jne 0x5848
movb (%r15), %bpl
testb %bpl, %bpl
movl 0x4(%rsp), %r12d
je 0x5933
callq 0x35d0
movq (%rax), %rcx
movsbq %bpl, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x5919
movslq 0xb70(%rbx), %rcx
cmpq $0xc8, %rcx
jge 0x59dc
leal 0x1(%rcx), %edx
movl %edx, 0xb70(%rbx)
movq %r15, 0xb78(%rbx,%rcx,8)
movb (%r15), %dl
testb %dl, %dl
je 0x5933
movq (%rax), %rcx
incq %r15
movsbq %dl, %rdx
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x5926
movb (%r15), %dl
incq %r15
testb %dl, %dl
jne 0x5902
jmp 0x5933
movb $0x0, (%r15)
movb 0x1(%r15), %bpl
incq %r15
jmp 0x592e
movb $0x0, -0x1(%r15)
movb (%r15), %bpl
testb %bpl, %bpl
jne 0x58c2
cmpl $0x2, %r12d
jl 0x598b
movslq 0xb70(%rbx), %rsi
cmpl $0xc9, %esi
movl $0xc8, %eax
cmovgel %esi, %eax
subl %esi, %eax
incl %eax
movl %r12d, %ecx
decq %rax
decq %rcx
leaq (%rbx,%rsi,8), %rdx
addq $0xb78, %rdx            # imm = 0xB78
incl %esi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x59bd
movq 0x8(%r14,%rdi,8), %r8
leal (%rsi,%rdi), %r9d
movl %r9d, 0xb70(%rbx)
movq %r8, (%rdx,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x596a
xorl %eax, %eax
movl %eax, 0x11c0(%rbx)
movq %rax, 0x338(%rbx)
movq %rax, 0x348(%rbx)
movl %eax, 0x670(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5438
leaq 0xea61(%rip), %rdi      # 0x14425
leaq 0xe977(%rip), %rsi      # 0x14342
leaq 0xea7a(%rip), %rcx      # 0x1444c
movl $0x1d4, %edx            # imm = 0x1D4
callq 0x3200
leaq 0xea42(%rip), %rdi      # 0x14425
leaq 0xe958(%rip), %rsi      # 0x14342
leaq 0xea5b(%rip), %rcx      # 0x1444c
movl $0x1c9, %edx            # imm = 0x1C9
callq 0x3200