// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]ufat/main.c
// Function: parse_options
static int parse_options(int argc, char **argv, struct options *opt)
{
	static const struct option longopts[] = {
		{"help",	0, 0, 'H'},
		{"version",	0, 0, 'V'},
		{"mkfs",	1, 0, 'M'},
		{NULL, 0, 0, 0}
	};
	int o;

	memset(opt, 0, sizeof(*opt));
	opt->log2_bs = 9;

	while ((o = getopt_long(argc, argv, "b:SR:i:o:", longopts, NULL)) >= 0)
		switch (o) {
		case 'i':
			opt->in_file = optarg;
			break;

		case 'o':
			opt->out_file = optarg;
			break;

		case 'M':
			opt->flags |= OPTION_MKFS;
			opt->num_blocks = atoll(optarg);
			break;

		case 'R':
			opt->flags |= OPTION_RANDOMIZE;
			opt->seed = atoi(optarg);
			break;

		case 'S':
			opt->flags |= OPTION_STATISTICS;
			break;

		case 'H':
			usage(argv[0]);
			exit(0);

		case 'V':
			version_banner();
			exit(0);

		case 'b':
			if (parse_blocksize(optarg, &opt->log2_bs) < 0)
				return -1;
			break;

		case '?':
			fprintf(stderr, "Try --help for usage.\n");
			return -1;
		}

	argc -= optind;
	argv += optind;

	if (argc <= 0) {
		fprintf(stderr, "Expected an image name\n");
		return -1;
	}

	opt->filename = argv[0];

	if (argc >= 2) {
		opt->command = find_command(argv[1]);
		opt->argv = argv + 2;
		opt->argc = argc - 2;

		if (!opt->command) {
			fprintf(stderr, "Unknown command: %s\n", argv[1]);
			return -1;
		}
	} else {
		opt->command = NULL;
		opt->argv = NULL;
		opt->argc = 0;
	}

	return 0;
}

// Assembly:
subq $0x28, %rsp
movl %edi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x2100
movq 0x10(%rsp), %rax
movl $0x9, 0x4(%rax)
movl 0x20(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0x33a5(%rip), %rdx      # 0xc334
leaq 0x6d2a(%rip), %rcx      # 0xfcc0
xorl %eax, %eax
movl %eax, %r8d
callq 0x20d0
movl %eax, 0xc(%rsp)
cmpl $0x0, %eax
jl 0x90de
movl 0xc(%rsp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, (%rsp)
subl $0x30, %eax
ja 0x90d9
movq (%rsp), %rax
leaq 0x31a6(%rip), %rcx      # 0xc174
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x6ffa(%rip), %rax      # 0xffd8
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
jmp 0x90d9
movq 0x6fe2(%rip), %rax      # 0xffd8
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x20(%rax)
jmp 0x90d9
movq 0x10(%rsp), %rax
movl (%rax), %ecx
orl $0x4, %ecx
movl %ecx, (%rax)
movq 0x6fbe(%rip), %rax      # 0xffd8
movq (%rax), %rdi
callq 0x2110
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x90d9
movq 0x10(%rsp), %rax
movl (%rax), %ecx
orl $0x2, %ecx
movl %ecx, (%rax)
movq 0x6f92(%rip), %rax      # 0xffd8
movq (%rax), %rdi
callq 0x21a0
movl %eax, %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x8(%rax)
jmp 0x90d9
movq 0x10(%rsp), %rax
movl (%rax), %ecx
orl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x90d9
movq 0x18(%rsp), %rax
movq (%rax), %rdi
callq 0x96a0
xorl %edi, %edi
callq 0x21b0
callq 0x96c0
xorl %edi, %edi
callq 0x21b0
movq 0x6f49(%rip), %rax      # 0xffd8
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
addq $0x4, %rsi
callq 0x96e0
cmpl $0x0, %eax
jge 0x90b2
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x91f4
jmp 0x90d9
movq 0x6f3d(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x3279(%rip), %rsi      # 0xc33e
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x91f4
jmp 0x8f7f
movq 0x6eeb(%rip), %rax      # 0xffd0
movl (%rax), %ecx
movl 0x20(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x20(%rsp)
movq 0x6ed8(%rip), %rax      # 0xffd0
movl (%rax), %ecx
movq 0x18(%rsp), %rax
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
cmpl $0x0, 0x20(%rsp)
jg 0x913a
movq 0x6edc(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x322f(%rip), %rsi      # 0xc355
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x91f4
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x28(%rax)
cmpl $0x2, 0x20(%rsp)
jl 0x91c6
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x97a0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0x18(%rsp), %rcx
addq $0x10, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x38(%rax)
movl 0x20(%rsp), %ecx
subl $0x2, %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x40(%rax)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x91c4
movq 0x6e58(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x31ba(%rip), %rsi      # 0xc36d
movb $0x0, %al
callq 0x2120
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0x91f4
jmp 0x91ec
movq 0x10(%rsp), %rax
movq $0x0, 0x30(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x38(%rax)
movq 0x10(%rsp), %rax
movl $0x0, 0x40(%rax)
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq
nopl (%rax)