// File: /workspace/github_c_makefile_star2_O2/lh3[P]minigraph/./ketopt.h
// Function: ketopt
static int ketopt(ketopt_t *s, int argc, char *argv[], int permute, const char *ostr, const ko_longopt_t *longopts)
{
	int opt = -1, i0, j;
	if (permute) {
		while (s->i < argc && (argv[s->i][0] != '-' || argv[s->i][1] == '\0'))
			++s->i, ++s->n_args;
	}
	s->arg = 0, s->longidx = -1, i0 = s->i;
	if (s->i >= argc || argv[s->i][0] != '-' || argv[s->i][1] == '\0') {
		s->ind = s->i - s->n_args;
		return -1;
	}
	if (argv[s->i][0] == '-' && argv[s->i][1] == '-') { /* "--" or a long option */
		if (argv[s->i][2] == '\0') { /* a bare "--" */
			ketopt_permute(argv, s->i, s->n_args);
			++s->i, s->ind = s->i - s->n_args;
			return -1;
		}
		s->opt = 0, opt = '?', s->pos = -1;
		if (longopts) { /* parse long options */
			int k, n_matches = 0;
			const ko_longopt_t *o = 0;
			for (j = 2; argv[s->i][j] != '\0' && argv[s->i][j] != '='; ++j) {} /* find the end of the option name */
			for (k = 0; longopts[k].name != 0; ++k)
				if (strncmp(&argv[s->i][2], longopts[k].name, j - 2) == 0)
					++n_matches, o = &longopts[k];
			if (n_matches == 1) {
				s->opt = opt = o->val, s->longidx = o - longopts;
				if (argv[s->i][j] == '=') s->arg = &argv[s->i][j + 1];
				if (o->has_arg == 1 && argv[s->i][j] == '\0') {
					if (s->i < argc - 1) s->arg = argv[++s->i];
					else opt = ':'; /* missing option argument */
				}
			}
		}
	} else { /* a short option */
		char *p;
		if (s->pos == 0) s->pos = 1;
		opt = s->opt = argv[s->i][s->pos++];
		p = strchr((char*)ostr, opt);
		if (p == 0) {
			opt = '?'; /* unknown option */
		} else if (p[1] == ':') {
			if (argv[s->i][s->pos] == 0) {
				if (s->i < argc - 1) s->arg = argv[++s->i];
				else opt = ':'; /* missing option argument */
			} else s->arg = &argv[s->i][s->pos];
			s->pos = -1;
		}
	}
	if (s->pos < 0 || argv[s->i][s->pos] == 0) {
		++s->i, s->pos = 0;
		if (s->n_args > 0) /* permute */
			for (j = i0; j < s->i; ++j)
				ketopt_permute(argv, j, s->n_args);
	}
	s->ind = s->i - s->n_args;
	return opt;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rdi, %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
movslq 0x14(%rdi), %r14
movslq %esi, %rcx
movq %r14, %r13
shlq $0x20, %r13
cmpq %rcx, %r14
jge 0x226c0
movq (%r15,%r14,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x226ae
cmpb $0x0, 0x1(%rdx)
jne 0x226e4
leal 0x1(%r14), %edx
movl %edx, 0x14(%rbx)
incl 0x1c(%rbx)
incq %r14
addq %rax, %r13
jmp 0x2269a
andq $0x0, 0x8(%rbx)
orl $-0x1, 0x10(%rbx)
pushq $-0x1
popq %rbp
subl 0x1c(%rbx), %r14d
movl %r14d, (%rbx)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andq $0x0, 0x8(%rbx)
orl $-0x1, 0x10(%rbx)
sarq $0x1d, %r13
movq (%r15,%r13), %rdx
pushq $-0x1
popq %rbp
cmpb $0x2d, (%rdx)
jne 0x226cc
movzbl 0x1(%rdx), %ecx
cmpl $0x2d, %ecx
je 0x22770
testl %ecx, %ecx
je 0x226cc
movl %esi, 0xc(%rsp)
movl 0x18(%rbx), %r13d
cmpl $0x1, %r13d
adcl $0x0, %r13d
movslq %r13d, %rax
leaq 0x1(%rax), %r12
movl %r12d, 0x18(%rbx)
movq %rdx, 0x10(%rsp)
movsbl (%rdx,%rax), %ebp
movl %ebp, 0x4(%rbx)
leaq 0x3394(%rip), %rdi      # 0x25acc
pushq $0x2f
popq %rdx
movl %ebp, %esi
callq 0x21d0
testq %rax, %rax
je 0x2287b
cmpb $0x3a, 0x1(%rax)
jne 0x2287e
movq 0x10(%rsp), %rcx
cmpb $0x0, (%rcx,%r12)
je 0x228a5
addq %r12, %rcx
movl %r14d, %eax
jmp 0x228bb
cmpb $0x0, 0x2(%rdx)
je 0x2285d
andl $0x0, 0x4(%rbx)
orl $-0x1, 0x18(%rbx)
leaq 0x2(%rdx), %rcx
movq %rcx, 0x28(%rsp)
addq $0x3, %rdx
pushq $0x2
popq %rdi
xorl %r8d, %r8d
movzbl -0x1(%rdx), %ecx
testl %ecx, %ecx
je 0x227ad
cmpl $0x3d, %ecx
je 0x227ad
incq %rdi
incq %rdx
addq %rax, %r8
jmp 0x22795
movq %rdi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, 0xc(%rsp)
sarq $0x20, %r8
movq %r8, 0x20(%rsp)
xorl %eax, %eax
leaq 0xbc43(%rip), %r12      # 0x2e410
xorl %ebp, %ebp
movq (%r12), %rsi
testq %rsi, %rsi
je 0x22804
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rdx
movq %rax, 0x30(%rsp)
callq 0x2070
xorl %ecx, %ecx
testl %eax, %eax
movq 0x30(%rsp), %rax
sete %cl
cmoveq %r12, %rbp
addl %ecx, %eax
addq $0x10, %r12
jmp 0x227cf
cmpl $0x1, %eax
jne 0x2289d
movq %rbp, %rdx
movl 0xc(%rbp), %ebp
movl %ebp, 0x4(%rbx)
leaq 0xbbf3(%rip), %rax      # 0x2e410
movq %rdx, %rcx
subq %rax, %rcx
shrq $0x4, %rcx
movl %ecx, 0x10(%rbx)
movq 0x10(%rsp), %rax
cmpb $0x3d, -0x1(%rax)
jne 0x22839
movq %rax, 0x8(%rbx)
cmpl $0x1, 0x8(%rdx)
movl 0xc(%rsp), %ecx
jne 0x228a0
movq (%r15,%r13), %rax
movq 0x18(%rsp), %rdx
cmpb $0x0, (%rax,%rdx)
jne 0x228a0
decl %ecx
cmpl %r14d, %ecx
jg 0x228b0
pushq $0x3a
jmp 0x2289f
movl 0x1c(%rbx), %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x22a4c
movl 0x14(%rbx), %r14d
incl %r14d
movl %r14d, 0x14(%rbx)
jmp 0x226cc
pushq $0x3f
popq %rbp
cmpl $-0x1, %r13d
jl 0x228a0
movslq %r14d, %rax
movq (%r15,%rax,8), %rax
movl %r12d, %ecx
cmpb $0x0, (%rax,%rcx)
movl %r14d, %eax
jne 0x226cc
jmp 0x228bf
pushq $0x3f
popq %rbp
movl %r14d, %eax
jmp 0x228bf
movl 0xc(%rsp), %eax
decl %eax
cmpl %r14d, %eax
jle 0x22859
leal 0x1(%r14), %eax
movslq %eax, %rcx
movq (%r15,%rcx,8), %rcx
movq %rcx, 0x8(%rbx)
incl %eax
movl %eax, 0x14(%rbx)
andl $0x0, 0x18(%rbx)
cmpl $0x0, 0x1c(%rbx)
jle 0x228e9
cmpl %eax, %r14d
jge 0x228e9
movl 0x1c(%rbx), %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x22a4c
incl %r14d
movl 0x14(%rbx), %eax
jmp 0x228ce
movl %eax, %r14d
jmp 0x226cc