// File: /workspace/github_c_makefile_star2_O0/DrYerzinia[P]C_DigiMode/src/util/argp.c
// Function: argp_parse
error_t argp_parse(struct argp *argp, int argc, char **argv, unsigned flags, int *arg_index,  void *input){

	struct argp_state state;

	state.input = input;

	int i;

	for(i = 1; i < argc; i++){

		if(argv[i][0] == '-'){

			if(argv[i][1] == '-'){

				struct argp_option *op = argp->options;

				int c = -1;

				while(*(uint8_t*)op != 0){

					c = argp_parse_argument(op->name, argv[i]);

					// If we found the option match the parameter
					if(c >= 0)
						break;

					op++;

				}

				if(c >= 0)
					argp->parser(op->key, &argv[i][c+3], &state);

				else {
					// Check if it is help
					c = argp_parse_argument("help", argv[i]);
					if(c >= 0){
						argp_print_help(argv[0], argp->options);
						return ARGP_ERR_HELP;
					} else {
						// Invalid Option
						fprintf(stderr, "%s: unrecognized option '%s'\nTry '%s --help' for more information.\n", argv[0], argv[i], argv[0]);
						return ARGP_ERR_UNKNOWN;
					}
				}

			} else {

				// single character option
				struct argp_option *op = argp->options;

				while(op->arg[0] != 0){

					if(op->key == argv[i][1] && argv[i][2] == '\0'){
						argp->parser(op->key, NULL, &state);
						break;
					}

					op++;

				}

			}

		}

		// Invalid Option
		else {
			return -1;
		}

	}

	return 0;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x1, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x2f8e
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x2f6f
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x2ed9
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movl $0xffffffff, -0xac(%rbp) # imm = 0xFFFFFFFF
movq -0xa8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x2e03
movq -0xa8(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2fb0
movl %eax, -0xac(%rbp)
cmpl $0x0, -0xac(%rbp)
jl 0x2def
jmp 0x2e03
movq -0xa8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xa8(%rbp)
jmp 0x2db1
cmpl $0x0, -0xac(%rbp)
jl 0x2e4a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xa8(%rbp), %rcx
movl 0x8(%rcx), %edi
movq -0x20(%rbp), %rcx
movslq -0x9c(%rbp), %rdx
movq (%rcx,%rdx,8), %rsi
movl -0xac(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
addq %rcx, %rsi
leaq -0x98(%rbp), %rdx
callq *%rax
jmp 0x2ed4
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x14d0(%rip), %rdi      # 0x4330
callq 0x2fb0
movl %eax, -0xac(%rbp)
cmpl $0x0, -0xac(%rbp)
jl 0x2e93
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3090
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2f95
movq 0x315e(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq (%rax), %r8
leaq 0x1474(%rip), %rsi      # 0x4335
movb $0x0, %al
callq 0x10c0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2f95
jmp 0x2f6d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq 0x10(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2f6b
movq -0xb8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x20(%rbp), %rcx
movslq -0x9c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x2f54
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x2(%rax), %eax
cmpl $0x0, %eax
jne 0x2f54
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xb8(%rbp), %rcx
movl 0x8(%rcx), %edi
xorl %ecx, %ecx
movl %ecx, %esi
leaq -0x98(%rbp), %rdx
callq *%rax
jmp 0x2f6b
movq -0xb8(%rbp), %rax
addq $0x30, %rax
movq %rax, -0xb8(%rbp)
jmp 0x2ee7
jmp 0x2f6d
jmp 0x2f78
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2f95
jmp 0x2f7a
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x2d53
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)