// File: /workspace/github_c_makefile_star2_O2/Tarsnap[P]libcperciva/liball/../util/getopt.c
// Function: libcperciva_getopt
const char *
getopt(int argc, char * const argv[])
{
	const char * os = NULL;
	const char * canonical_os = NULL;

	/* No argument yet. */
	optarg = NULL;

	/* Reset the getopt state if needed. */
	if (optreset)
		reset(argc, argv);

	/* If not initialized, return dummy option. */
	if (!getopt_initialized)
		return (GETOPT_DUMMY);

	/* If we've run out of arguments, we're done. */
	if (optind >= argc)
		return (NULL);

	/*
	 * If we're not already in the middle of a packed single-character
	 * options, see if we should start.
	 */
	if ((packedopts == NULL) && (argv[optind][0] == '-') &&
	    (argv[optind][1] != '-') && (argv[optind][1] != '\0')) {
		/* We have one or more single-character options. */
		packedopts = &argv[optind][1];
	}

	/* If we're processing single-character options, fish one out. */
	if (packedopts != NULL) {
		/* Construct the option string. */
		popt[0] = '-';
		popt[1] = *packedopts;
		popt[2] = '\0';
		os = popt;

		/* We've done this character. */
		packedopts++;

		/* Are we done with this string? */
		if (*packedopts == '\0') {
			packedopts = NULL;
			optind++;
		}
	}

	/* If we don't have an option yet, do we have dash-dash? */
	if ((os == NULL) && (argv[optind][0] == '-') &&
	    (argv[optind][1] == '-')) {
		/* If this is not "--\0", it's an option. */
		if (argv[optind][2] != '\0')
			os = argv[optind];

		/* Either way, we want to eat the string. */
		optind++;
	}

	/* If we have found nothing which looks like an option, we're done. */
	if (os == NULL)
		return (NULL);

	/* Search for the potential option. */
	opt_found = searchopt(os);

	/* If the option is not registered, give up now. */
	if (opt_found == opt_default) {
		WARN("unknown option: %s", os);
		return (os);
	}

	/* The canonical option string is the one registered. */
	canonical_os = opts[opt_found].os;

	/* Does the option take an argument? */
	if (opts[opt_found].hasarg) {
		/*
		 * If we're processing packed single-character options, the
		 * rest of the string is the argument to this option.
		 */
		if (packedopts != NULL) {
			optarg = packedopts;
			packedopts = NULL;
			optind++;
		}

		/*
		 * If the option string is <option>=<value>, extract that
		 * value as the option argument.
		 */
		if (os[opts[opt_found].olen] == '=')
			optarg = &os[opts[opt_found].olen + 1];

		/*
		 * If we don't have an argument yet, take one from the
		 * remaining command line.
		 */
		if ((optarg == NULL) && (optind < argc))
			optarg = argv[optind++];

		/* If we still have no option, declare it MIA. */
		if (optarg == NULL) {
			WARN("option requires an argument: %s",
			    opts[opt_found].os);
			opt_found = opt_missing;
		}
	} else {
		/* If we have --foo=bar, something went wrong. */
		if (os[opts[opt_found].olen] == '=') {
			WARN("option doesn't take an argument: %s",
			    opts[opt_found].os);
			opt_found = opt_default;
		}
	}

	/* Return the canonical option string. */
	return (canonical_os);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
andq $0x0, 0x392d(%rip)      # 0x50a8
movq %rsi, %r15
movl %edi, %ebp
cmpl $0x0, 0x3909(%rip)      # 0x5090
je 0x181c
testl %ebp, %ebp
jle 0x17ab
movq (%r15), %rax
movq %rax, 0x3945(%rip)      # 0x50e0
incq %rax
movzbl -0x1(%rax), %ecx
cmpl $0x2f, %ecx
je 0x1794
testl %ecx, %ecx
jne 0x179b
movq 0x3936(%rip), %rdi      # 0x50e8
callq 0x1030
andq $0x0, 0x3929(%rip)      # 0x50e8
cmpb $0x0, 0x3932(%rip)      # 0x50f8
jne 0x17db
leaq 0x82e(%rip), %rdi       # 0x1ffd
callq 0x2020
movb $0x1, 0x391d(%rip)      # 0x50f8
andq $0x0, 0x38d5(%rip)      # 0x50b8
orq $-0x1, 0x38dd(%rip)     # 0x50c8
andl $0x0, 0x38be(%rip)      # 0x50b0
movl $0x1, 0x388c(%rip)      # 0x5088
andl $0x0, 0x388d(%rip)      # 0x5090
movq 0x388e(%rip), %rbx      # 0x5098
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x388d(%rip)      # 0x50b0
je 0x1803
movl 0x385c(%rip), %r12d     # 0x5088
cmpl %ebp, %r12d
jge 0x1901
movq 0x387c(%rip), %rax      # 0x50b8
testq %rax, %rax
je 0x18bd
movb $0x2d, 0x3878(%rip)     # 0x50c0
leaq 0x3871(%rip), %r14      # 0x50c0
movb (%rax), %cl
movb %cl, 0x386a(%rip)       # 0x50c1
movb $0x0, 0x3864(%rip)      # 0x50c2
leaq 0x1(%rax), %r13
movq %r13, 0x384f(%rip)      # 0x50b8
cmpb $0x0, 0x1(%rax)
jne 0x1884
andq $0x0, 0x3841(%rip)      # 0x50b8
incl %r12d
movl %r12d, 0x3807(%rip)     # 0x5088
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x1b11
movq %rax, 0x3835(%rip)      # 0x50c8
movq 0x3836(%rip), %rdx      # 0x50d0
cmpq %rdx, %rax
jne 0x1908
cmpl $0x0, 0x37e6(%rip)      # 0x508c
je 0x18b5
cmpq %rax, 0x3829(%rip)      # 0x50d8
je 0x19ed
movq %r14, %rbx
jmp 0x180a
movslq %r12d, %rax
movq (%r15,%rax,8), %r14
cmpb $0x2d, (%r14)
jne 0x1901
movzbl 0x1(%r14), %eax
testl %eax, %eax
je 0x18dc
cmpl $0x2d, %eax
jne 0x19e2
cmpb $0x2d, 0x1(%r14)
jne 0x1901
incl %r12d
xorl %r13d, %r13d
cmpb $0x0, 0x2(%r14)
movl %r12d, 0x3793(%rip)     # 0x5088
movl $0x0, %ebx
jne 0x1884
jmp 0x180a
xorl %ebx, %ebx
jmp 0x180a
movq 0x37d9(%rip), %rcx      # 0x50e8
imulq $0x18, %rax, %rsi
movq (%rcx,%rsi), %rbx
cmpl $0x0, 0x10(%rcx,%rsi)
je 0x1960
testq %r13, %r13
je 0x193c
andq $0x0, 0x378d(%rip)      # 0x50b8
movq %r13, 0x3776(%rip)      # 0x50a8
incl %r12d
movl %r12d, 0x374c(%rip)     # 0x5088
movq 0x8(%rcx,%rsi), %rsi
cmpb $0x3d, (%r14,%rsi)
jne 0x1994
addq %r14, %rsi
incq %rsi
movq %rsi, 0x3753(%rip)      # 0x50a8
testq %rsi, %rsi
jne 0x180a
jmp 0x19b6
addq %rsi, %rcx
movq 0x8(%rcx), %rax
cmpb $0x3d, (%r14,%rax)
jne 0x180a
cmpl $0x0, 0x3713(%rip)      # 0x508c
je 0x1988
cmpq %rdx, 0x3756(%rip)      # 0x50d8
je 0x1aa5
movq %rdx, 0x3739(%rip)      # 0x50c8
jmp 0x180a
testq %r13, %r13
jne 0x180a
cmpl %ebp, %r12d
jge 0x19b6
leal 0x1(%r12), %esi
movl %esi, 0x36db(%rip)      # 0x5088
movslq %r12d, %rsi
movq (%r15,%rsi,8), %rsi
jmp 0x194e
cmpl $0x0, 0x36cf(%rip)      # 0x508c
setne %dil
movq 0x3710(%rip), %rsi      # 0x50d8
cmpq %rdx, %rsi
sete %dl
andb %dil, %dl
cmpb $0x1, %dl
je 0x1a3c
movq %rsi, 0x36eb(%rip)      # 0x50c8
jmp 0x180a
incq %r14
movq %r14, %rax
jmp 0x1841
movq 0x36ec(%rip), %rdx      # 0x50e0
testq %rdx, %rdx
je 0x1a11
movq 0x35f8(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
leaq 0x1742(%rip), %rsi      # 0x314c
xorl %eax, %eax
callq 0x10a0
movq 0x35e0(%rip), %rbx      # 0x4ff8
movq (%rbx), %rdi
leaq 0x172f(%rip), %rsi      # 0x3151
movq %r14, %rdx
xorl %eax, %eax
callq 0x10a0
movq (%rbx), %rsi
pushq $0xa
popq %rdi
callq 0x1080
jmp 0x18b5
movq 0x369d(%rip), %rdx      # 0x50e0
testq %rdx, %rdx
je 0x1a6e
movq 0x35a9(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
leaq 0x16f3(%rip), %rsi      # 0x314c
xorl %eax, %eax
callq 0x10a0
movq 0x3681(%rip), %rcx      # 0x50e8
movq 0x365a(%rip), %rax      # 0x50c8
movq 0x3583(%rip), %r14      # 0x4ff8
movq (%r14), %rdi
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rdx
leaq 0x16dd(%rip), %rsi      # 0x3164
xorl %eax, %eax
callq 0x10a0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x1080
movq 0x3638(%rip), %rsi      # 0x50d8
jmp 0x19d6
movq 0x3634(%rip), %rax      # 0x50e0
movq %rbx, %rdx
testq %rax, %rax
je 0x1ae2
movq 0x353d(%rip), %rcx      # 0x4ff8
movq (%rcx), %rdi
leaq 0x1687(%rip), %rsi      # 0x314c
movq %rax, %rdx
xorl %eax, %eax
callq 0x10a0
movq 0x3612(%rip), %rax      # 0x50e8
imulq $0x18, 0x35ea(%rip), %rcx # 0x50c8
movq (%rax,%rcx), %rdx
movq 0x350f(%rip), %r14      # 0x4ff8
movq (%r14), %rdi
leaq 0x1691(%rip), %rsi      # 0x3184
xorl %eax, %eax
callq 0x10a0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x1080
movq 0x35c4(%rip), %rdx      # 0x50d0
jmp 0x1988