// File: /workspace/github_cpp_makefile_star2_O1/chenhn123[P]wdt_util_src/wdt_ct/wdt_ct.cpp
// Function: parse_args(int, char**, ExecParam*)
int parse_args(int argc, char* argv[], EXEC_PARAM* pparam)
{
	int 	opt;
	int 	index;
	char	*parg = 0;	

	/* only support I2C here */
	pparam->interface_num = INTERFACE_I2C;

	while ((opt = getopt_long(argc, argv, WDT_UTIL_GETOPTS, long_options, &index)) != -1) {
		switch (opt) {
			case 'h':
				print_help(argv[0]);
				return 0;
			case 'd':
				/* there would be the 0x20 in the leading sometimes */
				parg = optarg;
				while (*parg == 0x20)
					parg++;
				
				if (memcmp("/dev", parg, 4))
					sprintf(pparam->dev_path, "/dev/%s", parg);
				else
					strcpy(pparam->dev_path, parg);
				break;
			case 'u':
				pparam->argus |= OPTION_UPDATE;
				pparam->image_file = optarg;
				break;
			case 'f':
				pparam->argus |= OPTION_NO_FORCE;	
				break;
			case 'b':
				pparam->argus |= OPTION_NO_REBIND;
				break;
			case 'r':
				pparam->argus |= OPTION_NO_RPARAM;	
				break;				
			case 's':
				pparam->argus |= OPTION_INFO;
				break;				
			case 'w':
				pparam->argus |= OPTION_WIF_INFO;
				pparam->image_file = optarg;				
				break;
			case 'v':
				pparam->argus |= OPTION_FW_VER;
				break;
			case 'c':
				pparam->argus |= OPTION_CFG_CHKSUM;
				break;
			case 'i':
				pparam->argus |= OPTION_HW_ID;
				break;
			case 'x':
				pparam->argus |= OPTION_EXTRA_INFO;		
				g_show_extra_info = 1;
			case 'k':
				pparam->argus |= OPTION_BLOCK;
				break;	
			default:
				break;

		}
	}

	if (optind != argc) {
		int i=0; 
		while (i<argc) {
			printf("%s ", argv[i]);
			i++;
		}
		printf("\n");
		
		print_help(argv[0]);
		return 0;
	}

	return pparam->argus;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %ebp
movl $0x2, 0x4(%rdx)
leaq 0x18(%rdx), %rax
movq %rax, 0x8(%rsp)
leaq 0xeb33(%rip), %r13      # 0x11190
leaq 0x14(%rsp), %r15
leaq 0x899b(%rip), %r12      # 0xb004
movl %ebp, %edi
movq %rbx, %rsi
leaq 0x8a31(%rip), %rdx      # 0xb0a6
movq %r13, %rcx
movq %r15, %r8
callq 0x22b0
leal -0x62(%rax), %ecx
cmpl $0x16, %ecx
ja 0x272e
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
orb $0x40, (%r14)
jmp 0x2669
orb $0x1, 0x1(%r14)
jmp 0x26fd
orb $0x10, 0x1(%r14)
jmp 0x2669
orb $0x4, (%r14)
jmp 0x2669
orb $0x20, 0x1(%r14)
jmp 0x2669
orb $0x8, (%r14)
jmp 0x2669
orb $0x20, (%r14)
jmp 0x2669
movq 0xe8ff(%rip), %rax      # 0x10fc8
movq (%rax), %rdx
decq %rdx
cmpb $0x20, 0x1(%rdx)
leaq 0x1(%rdx), %rdx
je 0x26cf
cmpl $0x7665642f, (%rdx)     # imm = 0x7665642F
je 0x2739
movq 0x8(%rsp), %rdi
leaq 0x89cf(%rip), %rsi      # 0xb0bc
xorl %eax, %eax
callq 0x2080
jmp 0x2669
orb $0x1, (%r14)
movq 0xe8c4(%rip), %rax      # 0x10fc8
movq (%rax), %rax
movq %rax, 0x10(%r14)
jmp 0x2669
orb $0x40, 0x1(%r14)
jmp 0x2669
orb $0x10, (%r14)
movb $0x1, 0xec5f(%rip)      # 0x11384
orb $-0x80, (%r14)
jmp 0x2669
cmpl $-0x1, %eax
jne 0x2669
jmp 0x274b
movq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x2180
jmp 0x2669
movq 0xe886(%rip), %rax      # 0x10fd8
cmpl %ebp, (%rax)
jne 0x275b
movl (%r14), %eax
jmp 0x2796
testl %ebp, %ebp
jle 0x2782
movl %ebp, %r15d
leaq 0x895b(%rip), %r14      # 0xb0c4
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x2050
incq %r12
cmpq %r12, %r15
jne 0x276c
movl $0xa, %edi
callq 0x2200
movq (%rbx), %rdi
callq 0x2438
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq