// File: /workspace/github_c_makefile_star2_O1/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
movl %esi, %ebp
movq %rdi, %rbx
movl 0x14(%rdi), %r13d
cmpl %esi, %r13d
setl %al
jge 0x2769d
movslq %r13d, %rcx
movslq %ebp, %rdx
incq %rcx
movq -0x8(%r15,%rcx,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x27682
cmpb $0x0, 0x1(%rsi)
jne 0x2769d
incl %r13d
movl %r13d, 0x14(%rbx)
incl 0x1c(%rbx)
cmpq %rdx, %rcx
setl %al
incq %rcx
cmpl %r13d, %ebp
jne 0x27672
movl %ebp, %r13d
movq $0x0, 0x8(%rbx)
movl $0xffffffff, 0x10(%rbx) # imm = 0xFFFFFFFF
testb $0x1, %al
je 0x276cb
movslq %r13d, %r10
movq (%r15,%r10,8), %r8
cmpb $0x2d, (%r8)
jne 0x276cb
movzbl 0x1(%r8), %eax
cmpl $0x2d, %eax
je 0x276e6
testl %eax, %eax
jne 0x27732
subl 0x1c(%rbx), %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %r13d, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x2(%r8)
je 0x27830
leaq 0x2(%r8), %rdi
movl $0x0, 0x4(%rbx)
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
addq $0x3, %r8
movl $0x2, %edx
xorl %r9d, %r9d
movabsq $0x100000000, %rax      # imm = 0x100000000
movzbl -0x1(%r8), %ecx
testl %ecx, %ecx
je 0x277a1
cmpl $0x3d, %ecx
je 0x277a1
incq %rdx
addq %rax, %r9
incq %r8
jmp 0x27719
movq %r10, 0x8(%rsp)
cmpl $0x0, 0x18(%rbx)
jne 0x27744
movl $0x1, 0x18(%rbx)
movslq 0x18(%rbx), %rax
leaq 0x1(%rax), %r14
movl %r14d, 0x18(%rbx)
movq %r8, 0x10(%rsp)
movsbl (%r8,%rax), %esi
movl %esi, 0x4(%rbx)
leaq 0x32f0(%rip), %rdi      # 0x2aa54
movl $0x2f, %edx
movl %esi, %r12d
callq 0x21d0
testq %rax, %rax
je 0x2785b
cmpb $0x3a, 0x1(%rax)
jne 0x2786a
movq 0x10(%rsp), %rax
cmpb $0x0, (%rax,%r14)
movq 0x8(%rsp), %r10
je 0x27906
addq %r14, %rax
jmp 0x27921
movq %rdx, 0x28(%rsp)
movq 0xac63(%rip), %rsi      # 0x32410
xorl %r14d, %r14d
testq %rsi, %rsi
je 0x27877
movq %rbx, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movq %r8, 0x10(%rsp)
movq %r10, 0x8(%rsp)
movq %r15, 0x30(%rsp)
sarq $0x20, %r9
leaq 0xac34(%rip), %r15      # 0x32410
xorl %r12d, %r12d
movq %r9, %rdx
movq %rdi, %rbp
movq %r9, %rbx
callq 0x2070
movq %rbx, %r9
movq %rbp, %rdi
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
cmoveq %r15, %r12
addl %ecx, %r14d
movq 0x10(%r15), %rsi
addq $0x10, %r15
testq %rsi, %rsi
jne 0x277df
cmpl $0x1, %r14d
sete %r14b
movq 0x30(%rsp), %r15
movq 0x8(%rsp), %r10
movq 0x10(%rsp), %r8
movl 0x1c(%rsp), %ebp
movq 0x20(%rsp), %rbx
jmp 0x2787a
movslq 0x1c(%rbx), %rax
testq %rax, %rax
jle 0x278e9
leaq (%r15,%r10,8), %rdx
xorl %ecx, %ecx
movq -0x8(%rdx), %rsi
movq %rsi, (%rdx)
addq $-0x8, %rdx
incq %rcx
cmpq %rcx, %rax
jne 0x27843
jmp 0x278eb
movl $0x3f, %eax
movq 0x8(%rsp), %r10
jmp 0x2792f
movq 0x8(%rsp), %r10
movl %r12d, %eax
jmp 0x2792f
xorl %r12d, %r12d
movl $0x3f, %eax
testb %r14b, %r14b
je 0x2792f
movl 0xc(%r12), %esi
movl %esi, 0x4(%rbx)
leaq 0xab79(%rip), %rcx      # 0x32410
movq %r12, %rdx
subq %rcx, %rdx
shrq $0x4, %rdx
movl %edx, 0x10(%rbx)
cmpb $0x3d, -0x1(%r8)
jne 0x278af
movq %r8, 0x8(%rbx)
cmpl $0x1, 0x8(%r12)
jne 0x278e5
movq (%r15,%r10,8), %rcx
movq 0x28(%rsp), %rax
cmpb $0x0, (%rcx,%rax)
jne 0x278e5
decl %ebp
movl $0x3a, %eax
cmpl %ebp, %r13d
jge 0x2792f
leal 0x1(%r13), %ecx
movl %ecx, 0x14(%rbx)
movslq %r13d, %rcx
movq 0x8(%r15,%rcx,8), %rcx
movq %rcx, 0x8(%rbx)
movl %esi, %eax
jmp 0x2792f
xorl %ecx, %ecx
movl %r13d, %edx
subl %ecx, %edx
movslq %edx, %rcx
movq %r8, (%r15,%rcx,8)
incl %r13d
movl %r13d, 0x14(%rbx)
subl %eax, %r13d
jmp 0x276cf
decl %ebp
movl $0x3a, %eax
cmpl %ebp, %r13d
jge 0x27928
leal 0x1(%r13), %eax
movl %eax, 0x14(%rbx)
movslq %r13d, %rax
movq 0x8(%r15,%rax,8), %rax
movq %rax, 0x8(%rbx)
movl %r12d, %eax
movl $0xffffffff, 0x18(%rbx) # imm = 0xFFFFFFFF
movslq 0x18(%rbx), %rdx
testq %rdx, %rdx
js 0x27946
movslq 0x14(%rbx), %rcx
movq (%r15,%rcx,8), %rcx
cmpb $0x0, (%rcx,%rdx)
jne 0x279ad
movl 0x14(%rbx), %edx
leal 0x1(%rdx), %r11d
movl %r11d, 0x14(%rbx)
movl $0x0, 0x18(%rbx)
movslq 0x1c(%rbx), %rcx
testq %rcx, %rcx
setle %sil
cmpl %edx, %r13d
setg %dl
orb %sil, %dl
jne 0x279ad
movq %rcx, %rdx
negq %rdx
leaq (%r15,%r10,8), %rsi
movq (%r15,%r10,8), %rdi
xorl %r8d, %r8d
testl %ecx, %ecx
jle 0x27997
movq -0x8(%rsi,%r8,8), %r9
movq %r9, (%rsi,%r8,8)
decq %r8
cmpq %r8, %rdx
jne 0x27983
negq %r8
movq %r10, %r9
subq %r8, %r9
movq %rdi, (%r15,%r9,8)
incq %r10
addq $0x8, %rsi
cmpl %r10d, %r11d
jne 0x27978
movl 0x14(%rbx), %r13d
subl 0x1c(%rbx), %r13d
jmp 0x276d4