// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/quectel-mbim-proxy.c
// Function: main
int main(int argc, char **argv)
{
    int optidx = 0;
    int opt;
    char *optstr = "d:vh";
    const char *device = "/dev/cdc-wdm0";

    struct option options[] = {
        {"verbose", no_argument,        NULL, 'v'},
        {"device", required_argument,   NULL, 'd'},
        {0, 0, 0, 0},
    };
    while ((opt = getopt_long(argc, argv, optstr, options, &optidx)) != -1) {
        switch (opt) {
        case 'v':
            verbose = 1;
            break;
        case 'd':
            device = optarg;
            break;
        case 'h':
            mbim_debug("-h              Show this message\n");
            mbim_debug("-v              Verbose\n");
            mbim_debug("-d [device]     MBIM device\n");
            return 0;
        default:
            mbim_debug("illegal argument\n");
            return -1;
        }
    }

    if (!device) {
        mbim_debug("Missing parameter: device\n");
        return -1;
    }

    while (1) {
        int mbim_dev_fd = open(device, O_RDWR | O_NONBLOCK | O_NOCTTY);
        if (mbim_dev_fd < 0) {
            mbim_debug("cannot open mbim_device %s: %s\n", device, strerror(errno));
            sleep(2);
            continue;
        }
        mbim_debug ("mbim_dev_fd=%d\n", mbim_dev_fd);

        memset(cm_clients, 0, sizeof(cm_clients));
        mbim_send_open_msg(mbim_dev_fd, sizeof(cm_recv_buffer));
        proxy_loop(mbim_dev_fd);
        safe_close(mbim_dev_fd);
    }

    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
leaq 0x2c(%rsp), %r14
andl $0x0, (%r14)
movq %rsi, %r15
movl %edi, %ebp
leaq 0x2a4b(%rip), %rsi      # 0x3d80
pushq $0xc
popq %rcx
leaq 0x1b0(%rsp), %r12
movq %r12, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xcf8(%rip), %rax       # 0x2045
movq %rax, 0x18(%rsp)
leaq 0xce7(%rip), %r13       # 0x2040
pushq $-0x1
popq %rbx
movl %ebp, %edi
movq %r15, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x1080
cmpl $0x76, %eax
jne 0x137d
movb $0x1, 0x2de5(%rip)      # 0x4160
jmp 0x135c
cmpl $-0x1, %eax
je 0x13f7
cmpl $0x64, %eax
jne 0x1398
movq 0x2c4a(%rip), %rax      # 0x3fd8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x135c
cmpl $0x68, %eax
jne 0x1cb6
movq 0x2c28(%rip), %r12      # 0x3fd0
movq (%r12), %r14
callq 0x127c
leaq 0xcaa(%rip), %rsi       # 0x2062
leaq 0x2d21(%rip), %r15      # 0x40e0
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r12), %r14
callq 0x127c
leaq 0xcaa(%rip), %rsi       # 0x2088
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10e0
leaq 0xcb2(%rip), %r14       # 0x20a4
jmp 0x1cc6
movq 0x18(%rsp), %r15
testq %r15, %r15
je 0x1cbf
movq 0x2bc4(%rip), %r12      # 0x3fd0
leaq 0x2ccd(%rip), %r13      # 0x40e0
movq %r15, %rdi
movl $0x902, %esi            # imm = 0x902
xorl %eax, %eax
callq 0x1120
movl %eax, %ebp
movq (%r12), %r14
callq 0x127c
testl %ebp, %ebp
js 0x1b85
movq %r14, %rdi
leaq 0xcdb(%rip), %rsi       # 0x211a
movq %r13, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x10e0
movl $0x100, %edx            # imm = 0x100
leaq 0x2d19(%rip), %rbx      # 0x4170
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10b0
movaps 0xba8(%rip), %xmm0      # 0x2010
movaps %xmm0, 0xa0(%rsp)
movq (%r12), %r14
callq 0x127c
movq %r14, %rdi
leaq 0xcaa(%rip), %rsi       # 0x212d
movq %r13, %rdx
leaq 0xca9(%rip), %rcx       # 0x2136
xorl %eax, %eax
callq 0x10e0
movl %ebp, %edi
leaq 0xa0(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x1cfd
movq %rbx, %rdx
movl %ebp, 0xc(%rsp)
testl %ebp, %ebp
je 0x1c29
pushq $-0x1
popq %rbp
movl 0xc(%rsp), %eax
movl %eax, 0xa0(%rsp)
movl $0x1, 0xa4(%rsp)
testl %ebp, %ebp
jle 0x151c
movl %ebp, 0xa8(%rsp)
movl $0x1, 0xac(%rsp)
xorl %eax, %eax
pushq $0x2
popq %rcx
movl %ecx, %ebx
cmpq $0x100, %rax            # imm = 0x100
je 0x1517
movl (%rax,%rdx), %ecx
testl %ecx, %ecx
jle 0x1511
movslq %ebx, %rbx
movl %ecx, 0xa0(%rsp,%rbx,8)
movl $0x1, 0xa4(%rsp,%rbx,8)
incl %ebx
addq $0x8, %rax
jmp 0x14eb
pushq $-0x1
popq %rdx
jmp 0x1526
movl $0x2710, %edx           # imm = 0x2710
pushq $0x1
popq %rax
movl %eax, %ebx
movslq %ebx, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1100
testl %eax, %eax
jle 0x1c10
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
xorl %r15d, %r15d
leaq 0x2c1e(%rip), %rdx      # 0x4170
cmpq %rbx, %r15
je 0x14b8
movl 0xa0(%rsp,%r15,8), %r14d
movswl 0xa6(%rsp,%r15,8), %r12d
testb $0x38, %r12b
je 0x15cd
movq 0x2a57(%rip), %rax      # 0x3fd0
movq (%rax), %r13
callq 0x127c
movq %r13, %rdi
leaq 0xc13(%rip), %rsi       # 0x219e
leaq 0x2b4e(%rip), %rdx      # 0x40e0
leaq 0xc29(%rip), %rcx       # 0x21c2
movl %r14d, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x10e0
cmpl 0xc(%rsp), %r14d
je 0x1c10
cmpl %ebp, %r14d
je 0x15be
movl %r14d, %edi
callq 0x1de7
movl %ebp, %r13d
leaq 0x2ba8(%rip), %rdx      # 0x4170
jmp 0x19a3
testb $0x1, %r12b
je 0x19a0
cmpl %ebp, %r14d
jne 0x1685
movl $0x10, 0x14(%rsp)
movl %ebp, %edi
leaq 0x30(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x1130
testl %eax, %eax
js 0x1725
movl %eax, %r14d
movl %eax, %edi
pushq $0x3
popq %rsi
xorl %eax, %eax
callq 0x1060
orl $0x800, %eax            # imm = 0x800
movl %r14d, %edi
pushq $0x4
popq %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
jns 0x1661
movq 0x29a1(%rip), %rax      # 0x3fd0
movq (%rax), %r12
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r12, %rdi
leaq 0xc5c(%rip), %rsi       # 0x22a9
leaq 0x2a8c(%rip), %rdx      # 0x40e0
movl %r14d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x10e0
xorl %r12d, %r12d
leaq 0x2b05(%rip), %rcx      # 0x4170
cmpq $0x20, %r12
je 0x1760
cmpl $0x0, (%rcx,%r12,8)
jle 0x176d
incq %r12
jmp 0x166b
movl $0x1000, %edx           # imm = 0x1000
movl %r14d, %edi
leaq 0x2bdc(%rip), %rsi      # 0x4270
callq 0x10d0
movq %rax, %r13
testl %r13d, %r13d
jle 0x1bb8
cmpl 0xc(%rsp), %r14d
jne 0x16fc
cmpl $-0x1, %ebp
leaq 0x2aba(%rip), %rdx      # 0x4170
je 0x1810
movl 0x2bb6(%rip), %ecx      # 0x4278
testl %ecx, %ecx
je 0x19ae
movl %ecx, %eax
shrl $0x18, %eax
xorl %r12d, %r12d
cmpq $0x20, %r12
je 0x1965
cmpl %eax, 0x4(%rdx,%r12,8)
jne 0x16f7
leaq (,%r12,8), %r14
movl (%r14,%rdx), %edi
testl %edi, %edi
jg 0x1a38
incq %r12
jmp 0x16d2
movl 0x2b76(%rip), %esi      # 0x4278
xorl %r12d, %r12d
leaq 0x2a64(%rip), %rdx      # 0x4170
cmpq $0x20, %r12
je 0x19a0
cmpl %r14d, (%rdx,%r12,8)
je 0x17c5
incq %r12
jmp 0x170c
movq 0x28a4(%rip), %rax      # 0x3fd0
movq (%rax), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0xb43(%rip), %rsi       # 0x228d
leaq 0x298f(%rip), %rdx      # 0x40e0
movq %rax, %rcx
xorl %eax, %eax
callq 0x10e0
jmp 0x15be
movl %r14d, %edi
callq 0x10c0
jmp 0x1999
movl %r14d, (%rcx,%r12,8)
leal 0x1(%r12), %eax
movl %eax, 0x4(%rcx,%r12,8)
movq 0x284e(%rip), %rax      # 0x3fd0
movq (%rax), %r14
callq 0x127c
leaq 0x29df(%rip), %rax      # 0x4170
movl (%rax,%r12,8), %r8d
leaq 0x29d4(%rip), %rax      # 0x4170
movl 0x4(%rax,%r12,8), %r9d
movq %r14, %rdi
leaq 0xaa6(%rip), %rsi       # 0x2251
leaq 0x292e(%rip), %rdx      # 0x40e0
leaq 0xb27(%rip), %rcx       # 0x22e0
xorl %eax, %eax
callq 0x10e0
jmp 0x1999
movl 0x4(%rdx,%r12,8), %eax
cmpl $-0x1, %eax
je 0x19a0
movl 0x2a97(%rip), %ecx      # 0x4270
leal -0x1(%rcx), %edx
cmpl $0x1, %edx
ja 0x19de
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x30(%rsp)
movl $0x10, 0x34(%rsp)
movl %esi, 0x38(%rsp)
andl $0x0, 0x3c(%rsp)
movl %r14d, %edi
leaq 0x30(%rsp), %rsi
pushq $0x10
popq %rdx
jmp 0x1aa5
cmpl $0x80000001, 0x2a56(%rip) # imm = 0x80000001
pushq $-0x1
popq %r13
jne 0x19a3
movq 0x27a5(%rip), %rax      # 0x3fd0
movq (%rax), %r14
callq 0x127c
movl 0x2a43(%rip), %ecx      # 0x427c
movq %r14, %rdi
leaq 0x9b3(%rip), %rsi       # 0x21f6
leaq 0x2896(%rip), %rdx      # 0x40e0
xorl %eax, %eax
callq 0x10e0
cmpl $0x0, 0x2a24(%rip)      # 0x427c
jne 0x1c10
pushq $0x1
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x1170
testl %eax, %eax
js 0x1aaf
movl %eax, %r13d
movl %eax, %edi
pushq $0x3
popq %rsi
xorl %eax, %eax
callq 0x1060
orl $0x800, %eax            # imm = 0x800
movl %r13d, %edi
pushq $0x4
popq %r14
movl %r14d, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
movq 0x272e(%rip), %r12      # 0x3fd0
leaq 0x2837(%rip), %rbp      # 0x40e0
jns 0x18de
movq (%r12), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
pushq $0x4
popq %r14
leaq 0xa3e(%rip), %rsi       # 0x230c
movq %rbp, %rdx
movl %r13d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x10e0
leaq 0x32(%rsp), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x5c(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movw $0x1, 0x30(%rsp)
pushq $0x6c
popq %rsi
leaq 0xa31(%rip), %rdx       # 0x2343
leaq 0x903(%rip), %rcx       # 0x221c
xorl %eax, %eax
callq 0x1090
movb $0x0, 0x32(%rsp)
movl $0x1, 0x14(%rsp)
movl %r13d, %edi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
leaq 0x14(%rsp), %rcx
movl %r14d, %r8d
callq 0x1050
testl %eax, %eax
jns 0x1b02
testl %r13d, %r13d
je 0x1ade
movl %r13d, %edi
callq 0x10c0
pushq $-0x1
popq %r13
jmp 0x1ae1
movq 0x2664(%rip), %rax      # 0x3fd0
movq (%rax), %r12
movl %ecx, %r14d
callq 0x127c
movq %r12, %rdi
leaq 0xa1c(%rip), %rsi       # 0x239d
leaq 0x2758(%rip), %rdx      # 0x40e0
leaq 0xa28(%rip), %rcx       # 0x23b7
movl %r14d, %r8d
xorl %eax, %eax
callq 0x10e0
leaq 0x27d0(%rip), %rdx      # 0x4170
movl %ebp, %r13d
incq %r15
movl %r13d, %ebp
jmp 0x1552
xorl %r14d, %r14d
cmpq $0x100, %r14            # imm = 0x100
je 0x19a0
movl (%r14,%rdx), %edi
testl %edi, %edi
jle 0x19d8
leaq 0x28a7(%rip), %rsi      # 0x4270
movl %r13d, %edx
callq 0x1cfd
leaq 0x2798(%rip), %rdx      # 0x4170
addq $0x8, %r14
jmp 0x19b1
shll $0x18, %eax
orl %esi, %eax
movl %eax, 0x288f(%rip)      # 0x4278
cmpb $0x1, 0x2770(%rip)      # 0x4160
jne 0x1a32
movq 0x25d7(%rip), %rax      # 0x3fd0
movq (%rax), %r14
movl %esi, 0x10(%rsp)
callq 0x127c
leaq 0x2764(%rip), %rax      # 0x4170
movl (%rax,%r12,8), %ecx
movl 0x4(%rax,%r12,8), %r8d
movq %r14, %rdi
leaq 0x9af(%rip), %rsi       # 0x23ce
leaq 0x26ba(%rip), %rdx      # 0x40e0
movl 0x10(%rsp), %r9d
xorl %eax, %eax
callq 0x10e0
movl 0xc(%rsp), %edi
jmp 0x1a9b
andl $0xffffff, %ecx         # imm = 0xFFFFFF
movl %ecx, 0x2834(%rip)      # 0x4278
cmpb $0x1, 0x2715(%rip)      # 0x4160
jne 0x1a9b
movq 0x257c(%rip), %rax      # 0x3fd0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl %ecx, 0x10(%rsp)
callq 0x127c
leaq 0x2704(%rip), %rax      # 0x4170
movl (%r14,%rax), %ecx
movl 0x4(%rax,%r12,8), %r8d
movq %rax, %r12
movq 0x20(%rsp), %rdi
leaq 0x8ed(%rip), %rsi       # 0x2371
leaq 0x2655(%rip), %rdx      # 0x40e0
movl 0x10(%rsp), %r9d
xorl %eax, %eax
callq 0x10e0
movl (%r14,%r12), %edi
leaq 0x27ce(%rip), %rsi      # 0x4270
movl %r13d, %edx
callq 0x1cfd
jmp 0x15be
movq 0x251a(%rip), %r12      # 0x3fd0
movq (%r12), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x821(%rip), %rsi       # 0x22f6
leaq 0x2604(%rip), %rbp      # 0x40e0
jmp 0x1b4f
xorl %r13d, %r13d
movq (%r12), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x853(%rip), %rsi       # 0x2347
movq %rbp, %rdx
xorl %eax, %eax
callq 0x10e0
pushq $0x4
popq %r14
movl %r13d, %edi
leaq 0x30(%rsp), %rsi
pushq $0x15
popq %rdx
callq 0x1110
testl %eax, %eax
js 0x1b23
movl %r13d, %edi
movl %r14d, %esi
callq 0x10f0
jmp 0x1b60
testl %r13d, %r13d
jle 0x1b30
movl %r13d, %edi
callq 0x10c0
movq (%r12), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x80e(%rip), %rsi       # 0x235d
movq %rbp, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10e0
pushq $-0x1
popq %r13
movq (%r12), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x6bc(%rip), %rsi       # 0x222f
movq %rbp, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x10e0
jmp 0x15c1
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x55c(%rip), %rsi       # 0x20f7
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x10e0
pushq $0x2
popq %rdi
callq 0x1160
jmp 0x1413
movq 0x2411(%rip), %rax      # 0x3fd0
movq (%rax), %rbx
callq 0x127c
callq 0x1040
movl (%rax), %r12d
movl %r12d, %edi
callq 0x1150
movq %rax, %r10
movq %rbx, %rdi
leaq 0x5e9(%rip), %rsi       # 0x21cd
leaq 0x24f5(%rip), %rdx      # 0x40e0
leaq 0x5d0(%rip), %rcx       # 0x21c2
movl %r14d, %r8d
movl %r13d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r12
callq 0x10e0
popq %rcx
popq %rdx
cmpl 0xc(%rsp), %r14d
jne 0x1c9e
leaq 0x2559(%rip), %rdx      # 0x4170
testl %ebp, %ebp
jle 0x1c29
movl %ebp, %edi
callq 0x10c0
leaq 0x2547(%rip), %rdx      # 0x4170
xorl %ebx, %ebx
movq 0x239e(%rip), %r12      # 0x3fd0
leaq 0x24a7(%rip), %r13      # 0x40e0
cmpq $0x100, %rbx            # imm = 0x100
je 0x1c5f
movl (%rbx,%rdx), %edi
testl %edi, %edi
jle 0x1c59
callq 0x10c0
leaq 0x251b(%rip), %rdx      # 0x4170
orl $-0x1, (%rbx,%rdx)
addq $0x8, %rbx
jmp 0x1c39
movq (%r12), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x5d3(%rip), %rsi       # 0x2245
movq %r13, %rdx
leaq 0x546(%rip), %rcx       # 0x21c2
xorl %eax, %eax
callq 0x10e0
movl 0xc(%rsp), %edi
testl %edi, %edi
movq 0x18(%rsp), %r15
je 0x1413
callq 0x10c0
jmp 0x1413
movl %r14d, %edi
callq 0x1de7
movq 0x2323(%rip), %r12      # 0x3fd0
leaq 0x242c(%rip), %r13      # 0x40e0
jmp 0x1c83
leaq 0x407(%rip), %r14       # 0x20c4
jmp 0x1cc6
leaq 0x413(%rip), %r14       # 0x20d9
movq 0x2303(%rip), %rax      # 0x3fd0
movq (%rax), %r15
callq 0x127c
leaq 0x2404(%rip), %rdx      # 0x40e0
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x10e0
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq