// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/main.c
// Function: parse_user_input
static int parse_user_input(int argc, char **argv, PROFILE_T *profile) {
    int opt = 1;

    profile->pdp = CONFIG_DEFAULT_PDP;

    if (!strcmp(argv[argc-1], "&"))
        argc--;

#define has_more_argv() ((opt < argc) && (argv[opt][0] != '-'))
    while  (opt < argc) {
        if (argv[opt][0] != '-') {
            return usage(argv[0]);
        }

        switch (argv[opt++][1])
        {
            case 's':
                profile->apn = profile->user = profile->password = "";
                if (has_more_argv()) {
                    profile->apn = argv[opt++];
                }
                if (has_more_argv()) {
                    profile->user = argv[opt++];
                }
                if (has_more_argv()) {
                    profile->password = argv[opt++];
                    if (profile->password && profile->password[0])
                        profile->auth = 2; //default chap, customers may miss auth
                }
                if (has_more_argv()) {
                    const char *auth = argv[opt++];

                    if (!strcmp(auth, "0") || !strcasecmp(auth, "none")) {
                        profile->auth = 0;
                    }
                    else if (!strcmp(auth, "1") || !strcasecmp(auth, "pap")) {
                        profile->auth = 1;
                    }
                    else if (!strcmp(auth, "2") || !strcasecmp(auth, "chap")) {
                        profile->auth = 2;
                    }
					else if (!strcmp(auth, "3") || !strcasecmp(auth, "MsChapV2")) {
                        profile->auth = 3;
                    }
                    else {
                        dbg_time("unknow auth '%s'", auth);
                        return usage(argv[0]);
                    }
                }
            break;

            case 'p':
                if (has_more_argv()) {
                    const char *arg = argv[opt++];

                    if (!strcmp(arg, QUECTEL_QMI_PROXY) || !strcmp(arg, QUECTEL_MBIM_PROXY)
                        || !strcmp(arg, LIBQMI_PROXY) || !strcmp(arg, LIBMBIM_PROXY)) {
                        strncpy(profile->proxy, arg, sizeof(profile->proxy));
                    }
                    else if ((999 < atoi(arg)) && (atoi(arg) < 10000)) {
                        profile->pincode = arg;
                    }
                    else {
                        dbg_time("unknow -p '%s'", arg);
                        return usage(argv[0]);
                    }
                }
            break;

            case 'm':
                if (has_more_argv())
                    profile->muxid = argv[opt++][0] - '0' + 0x80;
            break;

            case 'n':
                if (has_more_argv())
                    profile->pdp = argv[opt++][0] - '0';
            break;

            case 'f':
                if (has_more_argv()) {
                    profile->logfile = argv[opt++];
                }
            break;

            case 'i':
                if (has_more_argv()) {
                    strncpy(profile->expect_adapter, argv[opt++], sizeof(profile->expect_adapter));
                }
            break;

            case 'v':
                debug_qmi = 1;
            break;

            case 'l':
            	if (has_more_argv()) {
                    profile->replication_factor = atoi(argv[opt++]);
                	if (profile->replication_factor > 0) {
                        	profile->loopback_state = 1;
                     }
                }
            break;

            case '4':
                profile->enable_ipv4 = 1; 
            break;

            case '6':
                profile->enable_ipv6 = 1;
            break;

            case 'u':
                if (has_more_argv()) {
                    profile->usblogfile = argv[opt++];
                }
            break;

            case 'b':
                profile->enable_bridge = 1;
            break;
			
            case 'k':
                if (has_more_argv()) {
                    profile->kill_pdp = argv[opt++][0] - '0';
                }
                break;
            
            default:
                return usage(argv[0]);
            break;
        }
    }

    if (profile->enable_ipv4 != 1 && profile->enable_ipv6 != 1) { // default enable IPv4
        profile->enable_ipv4 = 1;
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl $0x1, 0x48(%rax)
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x230b2(%rip), %rsi     # 0x2b61f
callq 0x52a0
cmpl $0x0, %eax
jne 0x8580
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x8582
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8c4d
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x85b6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x9290
movl %eax, -0x4(%rbp)
jmp 0x8c76
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %ecx, %edx
incl %edx
movl %edx, -0x1c(%rbp)
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
addl $-0x34, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x42, %eax
ja 0x8c37
movq -0x38(%rbp), %rax
leaq 0x22eb6(%rip), %rcx     # 0x2b4a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
leaq 0x23a0b(%rip), %rcx     # 0x2c009
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
leaq 0x239fc(%rip), %rcx     # 0x2c009
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
leaq 0x239ed(%rip), %rcx     # 0x2c009
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8658
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8658
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8692
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8692
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x86f4
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x86f4
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x86f2
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x86f2
movq -0x18(%rbp), %rax
movl $0x2, 0x18(%rax)
jmp 0x86f4
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x889c
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x889c
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
leaq 0x27c9d(%rip), %rsi     # 0x303da
callq 0x52a0
cmpl $0x0, %eax
je 0x875c
movq -0x28(%rbp), %rdi
leaq 0x22ecf(%rip), %rsi     # 0x2b621
callq 0x5050
cmpl $0x0, %eax
jne 0x876c
movq -0x18(%rbp), %rax
movl $0x0, 0x18(%rax)
jmp 0x889a
movq -0x28(%rbp), %rdi
leaq 0x27b4e(%rip), %rsi     # 0x302c5
callq 0x52a0
cmpl $0x0, %eax
je 0x8796
movq -0x28(%rbp), %rdi
leaq 0x22e9a(%rip), %rsi     # 0x2b626
callq 0x5050
cmpl $0x0, %eax
jne 0x87a6
movq -0x18(%rbp), %rax
movl $0x1, 0x18(%rax)
jmp 0x8898
movq -0x28(%rbp), %rdi
leaq 0x27aba(%rip), %rsi     # 0x3026b
callq 0x52a0
cmpl $0x0, %eax
je 0x87d0
movq -0x28(%rbp), %rdi
leaq 0x22e64(%rip), %rsi     # 0x2b62a
callq 0x5050
cmpl $0x0, %eax
jne 0x87e0
movq -0x18(%rbp), %rax
movl $0x2, 0x18(%rax)
jmp 0x8896
movq -0x28(%rbp), %rdi
leaq 0x2683a(%rip), %rsi     # 0x2f025
callq 0x52a0
cmpl $0x0, %eax
je 0x880a
movq -0x28(%rbp), %rdi
leaq 0x22e2f(%rip), %rsi     # 0x2b62f
callq 0x5050
cmpl $0x0, %eax
jne 0x8817
movq -0x18(%rbp), %rax
movl $0x3, 0x18(%rax)
jmp 0x8894
jmp 0x8819
movq 0x2e7c0(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x13930
movq -0x40(%rbp), %rdi
movq %rax, %rdx
movq -0x28(%rbp), %rcx
leaq 0x22dfa(%rip), %rsi     # 0x2b638
movb $0x0, %al
callq 0x52c0
leaq 0x2f61c(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x887e
leaq 0x2f60f(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x13930
movq -0x48(%rbp), %rdi
movq %rax, %rdx
movq -0x28(%rbp), %rcx
leaq 0x22dc1(%rip), %rsi     # 0x2b638
movb $0x0, %al
callq 0x52c0
jmp 0x8880
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x9290
movl %eax, -0x4(%rbp)
jmp 0x8c76
jmp 0x8896
jmp 0x8898
jmp 0x889a
jmp 0x889c
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8a01
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8a01
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x22863(%rip), %rsi     # 0x2b14d
callq 0x52a0
cmpl $0x0, %eax
je 0x8933
movq -0x30(%rbp), %rdi
leaq 0x22d50(%rip), %rsi     # 0x2b64f
callq 0x52a0
cmpl $0x0, %eax
je 0x8933
movq -0x30(%rbp), %rdi
leaq 0x22841(%rip), %rsi     # 0x2b155
callq 0x52a0
cmpl $0x0, %eax
je 0x8933
movq -0x30(%rbp), %rdi
leaq 0x22d2e(%rip), %rsi     # 0x2b657
callq 0x52a0
cmpl $0x0, %eax
jne 0x894e
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
movq -0x30(%rbp), %rsi
movl $0x20, %edx
callq 0x5080
jmp 0x89ff
movq -0x30(%rbp), %rdi
callq 0x54c0
movl %eax, %ecx
movl $0x3e7, %eax            # imm = 0x3E7
cmpl %ecx, %eax
jge 0x8980
movq -0x30(%rbp), %rdi
callq 0x54c0
cmpl $0x2710, %eax           # imm = 0x2710
jge 0x8980
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x89fd
jmp 0x8982
movq 0x2e657(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x13930
movq -0x50(%rbp), %rdi
movq %rax, %rdx
movq -0x30(%rbp), %rcx
leaq 0x22cbb(%rip), %rsi     # 0x2b662
movb $0x0, %al
callq 0x52c0
leaq 0x2f4b3(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x89e7
leaq 0x2f4a6(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x13930
movq -0x58(%rbp), %rdi
movq %rax, %rdx
movq -0x30(%rbp), %rcx
leaq 0x22c82(%rip), %rsi     # 0x2b662
movb $0x0, %al
callq 0x52c0
jmp 0x89e9
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x9290
movl %eax, -0x4(%rbp)
jmp 0x8c76
jmp 0x89ff
jmp 0x8a01
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8a4e
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8a4e
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
subl $0x30, %ecx
addl $0x80, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x11e(%rax)
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8a92
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8a92
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
subl $0x30, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x48(%rax)
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8ad1
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8ad1
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x52(%rax)
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8b1a
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8b1a
movq -0x18(%rbp), %rdi
addq $0x62, %rdi
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
movl $0x20, %edx
callq 0x5080
jmp 0x8c48
movl $0x1, 0x2ea63(%rip)     # 0x3758c
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8b8b
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8b8b
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x86(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x86(%rax)
jle 0x8b89
movq -0x18(%rbp), %rax
movb $0x1, 0x215(%rax)
jmp 0x8b8b
jmp 0x8c48
movq -0x18(%rbp), %rax
movb $0x1, 0x50(%rax)
jmp 0x8c48
movq -0x18(%rbp), %rax
movb $0x1, 0x51(%rax)
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8be4
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8be4
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x5a(%rax)
jmp 0x8c48
movq -0x18(%rbp), %rax
movl $0x1, 0x4c(%rax)
jmp 0x8c48
movl -0x1c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8c35
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x8c35
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
subl $0x30, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x82(%rax)
jmp 0x8c48
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x9290
movl %eax, -0x4(%rbp)
jmp 0x8c76
jmp 0x8582
movq -0x18(%rbp), %rax
movzbl 0x50(%rax), %eax
cmpl $0x1, %eax
je 0x8c6f
movq -0x18(%rbp), %rax
movzbl 0x51(%rax), %eax
cmpl $0x1, %eax
je 0x8c6f
movq -0x18(%rbp), %rax
movb $0x1, 0x50(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop