// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movq $0x0, 0x35c9(%rip) # 0x50a8
cmpl $0x0, 0x35aa(%rip)      # 0x5090
je 0x1b67
testl %ebp, %ebp
jle 0x1b06
movq (%rbx), %rax
movq %rax, 0x35ea(%rip)      # 0x50e0
incq %rax
movzbl -0x1(%rax), %ecx
cmpl $0x2f, %ecx
je 0x1aef
testl %ecx, %ecx
jne 0x1af6
movq 0x35db(%rip), %rdi      # 0x50e8
callq 0x1030
movq $0x0, 0x35cb(%rip) # 0x50e8
cmpb $0x0, 0x35d4(%rip)      # 0x50f8
jne 0x1b39
leaq 0x573(%rip), %rdi       # 0x20a0
callq 0x20c0
movb $0x1, 0x35bf(%rip)      # 0x50f8
movl $0x1, 0x3545(%rip)      # 0x5088
movq $0x0, 0x356a(%rip) # 0x50b8
movq $-0x1, 0x356f(%rip) # 0x50c8
xorl %eax, %eax
movl %eax, 0x354f(%rip)      # 0x50b0
movl %eax, 0x3529(%rip)      # 0x5090
cmpl $0x0, 0x3542(%rip)      # 0x50b0
je 0x1bfc
movslq 0x350d(%rip), %rax      # 0x5088
cmpl %ebp, %eax
jge 0x1c76
cmpq $0x0, 0x352d(%rip)      # 0x50b8
jne 0x1bad
movq (%rbx,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0x1bad
movzbl 0x1(%rcx), %edx
testl %edx, %edx
je 0x1bad
cmpl $0x2d, %edx
je 0x1bad
incq %rcx
movq %rcx, 0x350b(%rip)      # 0x50b8
movq 0x3504(%rip), %rcx      # 0x50b8
testq %rcx, %rcx
je 0x1c05
movb $0x2d, 0x3500(%rip)     # 0x50c0
leaq 0x34f9(%rip), %r15      # 0x50c0
movb (%rcx), %dl
movb %dl, 0x34f2(%rip)       # 0x50c1
movb $0x0, 0x34ec(%rip)      # 0x50c2
leaq 0x1(%rcx), %rdx
movq %rdx, 0x34d7(%rip)      # 0x50b8
cmpb $0x0, 0x1(%rcx)
jne 0x1c08
movq $0x0, 0x34c6(%rip) # 0x50b8
incl %eax
movl %eax, 0x348e(%rip)      # 0x5088
jmp 0x1c08
movq 0x3495(%rip), %r14      # 0x5098
jmp 0x1c79
xorl %r15d, %r15d
testq %rcx, %rcx
jne 0x1c3b
movslq 0x3474(%rip), %rax      # 0x5088
movq (%rbx,%rax,8), %rcx
cmpb $0x2d, (%rcx)
jne 0x1c38
cmpb $0x2d, 0x1(%rcx)
jne 0x1c38
xorl %r15d, %r15d
cmpb $0x0, 0x2(%rcx)
cmovneq %rcx, %r15
incl %eax
movl %eax, 0x3452(%rip)      # 0x5088
jmp 0x1c3b
xorl %r15d, %r15d
testq %r15, %r15
je 0x1c76
movq %r15, %rdi
callq 0x1d83
movq %rax, 0x3479(%rip)      # 0x50c8
movq 0x347a(%rip), %rcx      # 0x50d0
cmpq %rcx, %rax
jne 0x1c87
cmpl $0x0, 0x342a(%rip)      # 0x508c
je 0x1c71
cmpq %rcx, 0x346d(%rip)      # 0x50d8
je 0x1d68
movq %r15, %r14
jmp 0x1c79
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x345a(%rip), %rdx      # 0x50e8
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %r14
cmpl $0x0, 0x10(%rdx,%rax,8)
je 0x1d30
movq 0x3410(%rip), %rsi      # 0x50b8
testq %rsi, %rsi
je 0x1cc5
movq %rsi, 0x33f4(%rip)      # 0x50a8
movq $0x0, 0x33f9(%rip) # 0x50b8
incl 0x33c3(%rip)            # 0x5088
movq 0x8(%rdx,%rax,8), %rax
cmpb $0x3d, (%r15,%rax)
jne 0x1cde
addq %r15, %rax
incq %rax
movq %rax, 0x33ca(%rip)      # 0x50a8
cmpq $0x0, 0x33c2(%rip)      # 0x50a8
jne 0x1d07
movslq 0x3399(%rip), %rax      # 0x5088
cmpl %ebp, %eax
jge 0x1d07
leal 0x1(%rax), %edx
movl %edx, 0x338c(%rip)      # 0x5088
movq (%rbx,%rax,8), %rax
movq %rax, 0x33a1(%rip)      # 0x50a8
cmpq $0x0, 0x3399(%rip)      # 0x50a8
jne 0x1c79
cmpl $0x0, 0x3370(%rip)      # 0x508c
je 0x1d27
cmpq %rcx, 0x33b3(%rip)      # 0x50d8
je 0x1d75
movq 0x33aa(%rip), %rax      # 0x50d8
jmp 0x1d5c
leaq (%rdx,%rax,8), %rax
movq 0x8(%rax), %rax
cmpb $0x3d, (%r15,%rax)
jne 0x1c79
cmpl $0x0, 0x3342(%rip)      # 0x508c
je 0x1d55
cmpq %rcx, 0x3385(%rip)      # 0x50d8
je 0x1d7c
movq 0x3374(%rip), %rax      # 0x50d0
movq %rax, 0x3365(%rip)      # 0x50c8
jmp 0x1c79
movq %r15, %rdi
callq 0x12af
jmp 0x1c71
callq 0x11f7
jmp 0x1d27
callq 0x1253
jmp 0x1d55