// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %r14
movl %edi, %ebp
movq $0x0, 0x3591(%rip) # 0x50a8
cmpl $0x0, 0x3572(%rip)      # 0x5090
je 0x1bbc
testl %ebp, %ebp
jle 0x1b42
movq (%r14), %rax
movq %rax, 0x35ae(%rip)      # 0x50e0
incq %rax
movzbl -0x1(%rax), %ecx
cmpl $0x2f, %ecx
je 0x1b2b
testl %ecx, %ecx
jne 0x1b32
movq 0x359f(%rip), %rdi      # 0x50e8
callq 0x1030
movq $0x0, 0x358f(%rip) # 0x50e8
cmpb $0x0, 0x3598(%rip)      # 0x50f8
jne 0x1b75
leaq 0x610(%rip), %rdi       # 0x2179
callq 0x21a0
movb $0x1, 0x3583(%rip)      # 0x50f8
movl $0x1, 0x3509(%rip)      # 0x5088
movq $0x0, 0x352e(%rip) # 0x50b8
movq $-0x1, 0x3533(%rip) # 0x50c8
xorl %eax, %eax
movl %eax, 0x3513(%rip)      # 0x50b0
movl %eax, 0x34ed(%rip)      # 0x5090
movq 0x34ee(%rip), %rbx      # 0x5098
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x34ed(%rip)      # 0x50b0
je 0x1ba3
movl 0x34bc(%rip), %r12d     # 0x5088
cmpl %ebp, %r12d
jge 0x1ca4
movq 0x34dc(%rip), %rax      # 0x50b8
testq %rax, %rax
je 0x1c60
movb $0x2d, 0x34d8(%rip)     # 0x50c0
leaq 0x34d1(%rip), %r15      # 0x50c0
movb (%rax), %cl
movb %cl, 0x34ca(%rip)       # 0x50c1
movb $0x0, 0x34c4(%rip)      # 0x50c2
leaq 0x1(%rax), %r13
movq %r13, 0x34af(%rip)      # 0x50b8
cmpb $0x0, 0x1(%rax)
jne 0x1c27
movq $0x0, 0x349e(%rip) # 0x50b8
incl %r12d
movl %r12d, 0x3464(%rip)     # 0x5088
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x1dd3
movq %rax, 0x3492(%rip)      # 0x50c8
movq 0x3493(%rip), %rcx      # 0x50d0
cmpq %rcx, %rax
jne 0x1cab
cmpl $0x0, 0x3443(%rip)      # 0x508c
je 0x1c58
cmpq %rax, 0x3486(%rip)      # 0x50d8
je 0x1d9d
movq %r15, %rbx
jmp 0x1baa
movslq %r12d, %rax
movq (%r14,%rax,8), %r15
cmpb $0x2d, (%r15)
jne 0x1ca4
movzbl 0x1(%r15), %eax
testl %eax, %eax
je 0x1c7f
cmpl $0x2d, %eax
jne 0x1d4d
cmpb $0x2d, 0x1(%r15)
jne 0x1ca4
incl %r12d
xorl %r13d, %r13d
cmpb $0x0, 0x2(%r15)
movl %r12d, 0x33f0(%rip)     # 0x5088
movl $0x0, %ebx
jne 0x1c27
jmp 0x1baa
xorl %ebx, %ebx
jmp 0x1baa
movq 0x3436(%rip), %rsi      # 0x50e8
leaq (%rax,%rax,2), %rdx
movq (%rsi,%rdx,8), %rbx
cmpl $0x0, 0x10(%rsi,%rdx,8)
je 0x1cf4
testq %r13, %r13
je 0x1d29
movq %r13, 0x33db(%rip)      # 0x50a8
movq $0x0, 0x33e0(%rip) # 0x50b8
incl %r12d
movl %r12d, 0x33a6(%rip)     # 0x5088
movq 0x8(%rsi,%rdx,8), %rdx
cmpb $0x3d, (%r15,%rdx)
jne 0x1baa
jmp 0x1d35
leaq (%rsi,%rdx,8), %rax
movq 0x8(%rax), %rax
cmpb $0x3d, (%r15,%rax)
jne 0x1baa
cmpl $0x0, 0x337e(%rip)      # 0x508c
je 0x1d1d
cmpq %rcx, 0x33c1(%rip)      # 0x50d8
je 0x1dbd
movq %rcx, 0x33a4(%rip)      # 0x50c8
jmp 0x1baa
movq 0x8(%rsi,%rdx,8), %rdx
cmpb $0x3d, (%r15,%rdx)
jne 0x1d58
addq %r15, %rdx
incq %rdx
movq %rdx, 0x3366(%rip)      # 0x50a8
testq %rdx, %rdx
jne 0x1baa
jmp 0x1d71
incq %r15
movq %r15, %rax
jmp 0x1be1
cmpl %ebp, %r12d
jge 0x1d71
leal 0x1(%r12), %edx
movl %edx, 0x3320(%rip)      # 0x5088
movslq %r12d, %rdx
movq (%r14,%rdx,8), %rdx
jmp 0x1d3b
cmpl $0x0, 0x3314(%rip)      # 0x508c
setne %dil
movq 0x3355(%rip), %rdx      # 0x50d8
cmpq %rcx, %rdx
sete %cl
andb %dil, %cl
cmpb $0x1, %cl
je 0x1daa
movq %rdx, 0x3330(%rip)      # 0x50c8
jmp 0x1baa
movq %r15, %rdi
callq 0x12e9
jmp 0x1c58
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rdx
callq 0x11f7
movq (%r14), %rdx
jmp 0x1d91
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1270
movq (%r14), %rcx
jmp 0x1d1d