// File: /workspace/github_c_makefile_star2_O3/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
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x2c(%rsp), %r14
movl $0x0, (%r14)
leaq 0x2a35(%rip), %rsi      # 0x3d80
leaq 0x1b0(%rsp), %r15
movl $0xc, %ecx
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0xce0(%rip), %rax       # 0x2045
movq %rax, 0x10(%rsp)
leaq 0xccf(%rip), %r12       # 0x2040
movq 0x2c60(%rip), %r13      # 0x3fd8
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x1080
cmpl $0x76, %eax
jne 0x1399
movb $0x1, 0x2dc9(%rip)      # 0x4160
jmp 0x1378
cmpl $-0x1, %eax
je 0x140d
cmpl $0x64, %eax
jne 0x13ae
movq (%r13), %rax
movq %rax, 0x10(%rsp)
jmp 0x1378
cmpl $0x68, %eax
jne 0x1cba
movq 0x2c12(%rip), %r12      # 0x3fd0
movq (%r12), %r14
callq 0x127c
leaq 0xc94(%rip), %rsi       # 0x2062
leaq 0x2d0b(%rip), %r15      # 0x40e0
xorl %ebx, %ebx
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r12), %r14
callq 0x127c
leaq 0xc94(%rip), %rsi       # 0x2088
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10e0
leaq 0xc9c(%rip), %r14       # 0x20a4
jmp 0x1cd4
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x1cc8
movq 0x2bae(%rip), %r13      # 0x3fd0
leaq 0x2d47(%rip), %rbp      # 0x4170
movq %rbx, %rdi
movl $0x902, %esi            # imm = 0x902
xorl %eax, %eax
callq 0x1120
movl %eax, %r15d
movq (%r13), %r14
callq 0x127c
testl %r15d, %r15d
js 0x1b8d
movq %r14, %rdi
leaq 0xcc3(%rip), %rsi       # 0x211a
leaq 0x2c82(%rip), %rbx      # 0x40e0
movq %rbx, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10e0
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
xorl %esi, %esi
callq 0x10b0
movaps 0xb8f(%rip), %xmm0      # 0x2010
movaps %xmm0, 0xa0(%rsp)
movq (%r13), %r14
callq 0x127c
movq %r14, %rdi
leaq 0xc91(%rip), %rsi       # 0x212d
movq %rbx, %rdx
leaq 0xc90(%rip), %rcx       # 0x2136
xorl %eax, %eax
callq 0x10e0
movl %r15d, %edi
leaq 0xa0(%rsp), %rsi
movl $0x10, %edx
callq 0x1d0b
testl %r15d, %r15d
je 0x1bdf
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r15d, 0x4(%rsp)
movl %r15d, 0xa0(%rsp)
movl $0x1, 0xa4(%rsp)
testl %r14d, %r14d
jle 0x1539
movl %r14d, 0xa8(%rsp)
movl $0x1, 0xac(%rsp)
movl $0x2, %ebx
xorl %eax, %eax
movl (%rax,%rbp), %ecx
testl %ecx, %ecx
jle 0x1526
movslq %ebx, %rbx
movl %ecx, 0xa0(%rsp,%rbx,8)
movl $0x1, 0xa4(%rsp,%rbx,8)
incl %ebx
addq $0x8, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0x1508
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x1543
movl $0x1, %ebx
movl $0x2710, %edx           # imm = 0x2710
movslq %ebx, %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1100
testl %eax, %eax
jle 0x1bd2
testl %ebx, %ebx
jle 0x1b76
movl %ebx, %eax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movl 0xa0(%rsp,%rbx,8), %r15d
movswl 0xa6(%rsp,%rbx,8), %r12d
testb $0x38, %r12b
je 0x15d1
movq 0x2a46(%rip), %rax      # 0x3fd0
movq (%rax), %r13
callq 0x127c
movq %r13, %rdi
leaq 0xc02(%rip), %rsi       # 0x219e
leaq 0x2b3d(%rip), %rdx      # 0x40e0
leaq 0xc18(%rip), %rcx       # 0x21c2
movl %r15d, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0x10e0
cmpl 0x4(%rsp), %r15d
je 0x1bc6
cmpl %r14d, %r15d
je 0x15d7
movl %r15d, %edi
callq 0x1df7
jmp 0x15d7
testb $0x1, %r12b
jne 0x15ec
movl %r14d, %r13d
incq %rbx
movl %r13d, %r14d
cmpq 0x18(%rsp), %rbx
jne 0x156c
jmp 0x1b79
cmpl %r14d, %r15d
jne 0x16a1
movl $0x10, 0xc(%rsp)
movl %r14d, %edi
leaq 0x30(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x1130
testl %eax, %eax
movq 0x29b8(%rip), %r13      # 0x3fd0
js 0x1767
movl %eax, %r15d
movl %eax, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x1060
orl $0x800, %eax            # imm = 0x800
movl %r15d, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
jns 0x167c
movq (%r13), %r12
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r12, %rdi
leaq 0xc41(%rip), %rsi       # 0x22a9
leaq 0x2a71(%rip), %rdx      # 0x40e0
movl %r15d, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x10e0
xorl %r12d, %r12d
cmpl $0x0, (%rbp,%r12,8)
jle 0x179c
incq %r12
cmpq $0x20, %r12
jne 0x167f
movl %r15d, %edi
callq 0x10c0
jmp 0x15d7
movl $0x1000, %edx           # imm = 0x1000
movl %r15d, %edi
leaq 0x2bc0(%rip), %rsi      # 0x4270
callq 0x10d0
movq %rax, %r13
testl %r13d, %r13d
jle 0x1c44
cmpl 0x4(%rsp), %r15d
jne 0x1745
cmpl $-0x1, %r14d
je 0x1832
movl 0x2ba0(%rip), %ecx      # 0x4278
testl %ecx, %ecx
je 0x1992
movl %ecx, %eax
shrl $0x18, %eax
xorl %r12d, %r12d
cmpl %eax, 0x4(%rbp,%r12,8)
jne 0x1703
leaq (,%r12,8), %r15
movl (%r15,%rbp), %edi
testl %edi, %edi
jg 0x1a12
incq %r12
cmpq $0x20, %r12
jne 0x16e8
movq 0x28bd(%rip), %rax      # 0x3fd0
movq (%rax), %r12
movl %ecx, %r15d
callq 0x127c
movq %r12, %rdi
leaq 0xc75(%rip), %rsi       # 0x239d
leaq 0x29b1(%rip), %rdx      # 0x40e0
leaq 0xc81(%rip), %rcx       # 0x23b7
movl %r15d, %r8d
xorl %eax, %eax
callq 0x10e0
jmp 0x15d7
movl 0x2b2d(%rip), %esi      # 0x4278
xorl %r12d, %r12d
cmpl %r15d, (%rbp,%r12,8)
je 0x17e2
incq %r12
cmpq $0x20, %r12
jne 0x174e
jmp 0x15d7
movq (%r13), %r15
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r15, %rdi
leaq 0xb07(%rip), %rsi       # 0x228d
leaq 0x2953(%rip), %rdx      # 0x40e0
movq %rax, %rcx
xorl %eax, %eax
callq 0x10e0
jmp 0x15d7
movl %r15d, (%rbp,%r12,8)
leal 0x1(%r12), %eax
movl %eax, 0x4(%rbp,%r12,8)
movq (%r13), %r15
callq 0x127c
movl (%rbp,%r12,8), %r8d
movl 0x4(%rbp,%r12,8), %r9d
movq %r15, %rdi
leaq 0xa89(%rip), %rsi       # 0x2251
leaq 0x2911(%rip), %rdx      # 0x40e0
leaq 0xb0a(%rip), %rcx       # 0x22e0
xorl %eax, %eax
callq 0x10e0
jmp 0x15d7
movl 0x4(%rbp,%r12,8), %eax
cmpl $-0x1, %eax
je 0x15d7
movl 0x2a7a(%rip), %ecx      # 0x4270
leal -0x1(%rcx), %edx
cmpl $0x1, %edx
ja 0x19be
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0x30(%rsp)
movl $0x10, 0x34(%rsp)
movl %esi, 0x38(%rsp)
movl $0x0, 0x3c(%rsp)
movl %r15d, %edi
leaq 0x30(%rsp), %rsi
movl $0x10, %edx
jmp 0x1a75
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x80000001, 0x2a2e(%rip) # imm = 0x80000001
jne 0x15da
movq 0x2781(%rip), %r13      # 0x3fd0
movq (%r13), %r15
callq 0x127c
movl 0x2a1e(%rip), %ecx      # 0x427c
movq %r15, %rdi
leaq 0x98e(%rip), %rsi       # 0x21f6
leaq 0x2871(%rip), %rdx      # 0x40e0
xorl %eax, %eax
callq 0x10e0
cmpl $0x0, 0x29ff(%rip)      # 0x427c
jne 0x1bcd
movl $0x1, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1170
testl %eax, %eax
js 0x1a7f
movl %eax, %r13d
movl %eax, %edi
movl $0x3, %esi
xorl %eax, %eax
callq 0x1060
orl $0x800, %eax            # imm = 0x800
movl %r13d, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x1060
testl %eax, %eax
jns 0x1900
movq 0x2702(%rip), %rax      # 0x3fd0
movq (%rax), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0xa20(%rip), %rsi       # 0x230c
leaq 0x27ed(%rip), %rdx      # 0x40e0
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)
movl $0x6c, %esi
leaq 0xa0d(%rip), %rdx       # 0x2343
leaq 0x8df(%rip), %rcx       # 0x221c
xorl %eax, %eax
callq 0x1090
movb $0x0, 0x32(%rsp)
movl $0x1, 0xc(%rsp)
movl %r13d, %edi
movl $0x1, %esi
movl $0x2, %edx
leaq 0xc(%rsp), %rcx
movl $0x4, %r8d
callq 0x1050
testl %eax, %eax
jns 0x1ad3
testl %r13d, %r13d
je 0x1aa9
movl %r13d, %edi
callq 0x10c0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
jmp 0x1aac
xorl %r15d, %r15d
movl (%r15,%rbp), %edi
testl %edi, %edi
jle 0x19ac
leaq 0x28cc(%rip), %rsi      # 0x4270
movl %r13d, %edx
callq 0x1d0b
addq $0x8, %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0x1995
jmp 0x15d7
shll $0x18, %eax
orl %esi, %eax
movl %eax, 0x28af(%rip)      # 0x4278
cmpb $0x1, 0x2790(%rip)      # 0x4160
jne 0x1a0c
movq 0x25f7(%rip), %rax      # 0x3fd0
movq (%rax), %r15
movl %esi, 0x8(%rsp)
callq 0x127c
movl (%rbp,%r12,8), %ecx
movl 0x4(%rbp,%r12,8), %r8d
movq %r15, %rdi
leaq 0x9d5(%rip), %rsi       # 0x23ce
leaq 0x26e0(%rip), %rdx      # 0x40e0
movl 0x8(%rsp), %r9d
xorl %eax, %eax
callq 0x10e0
movl 0x4(%rsp), %edi
jmp 0x1a6b
andl $0xffffff, %ecx         # imm = 0xFFFFFF
movl %ecx, 0x285a(%rip)      # 0x4278
cmpb $0x1, 0x273b(%rip)      # 0x4160
jne 0x1a6b
movq 0x25a2(%rip), %rax      # 0x3fd0
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movl %ecx, 0x8(%rsp)
callq 0x127c
movl (%r15,%rbp), %ecx
movl 0x4(%rbp,%r12,8), %r8d
movq 0x20(%rsp), %rdi
leaq 0x91d(%rip), %rsi       # 0x2371
leaq 0x2685(%rip), %rdx      # 0x40e0
movl 0x8(%rsp), %r9d
xorl %eax, %eax
callq 0x10e0
movl (%r15,%rbp), %edi
leaq 0x27fe(%rip), %rsi      # 0x4270
movl %r13d, %edx
callq 0x1d0b
jmp 0x15d7
movq 0x254a(%rip), %r15      # 0x3fd0
movq (%r15), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x852(%rip), %rsi       # 0x22f6
jmp 0x1b38
xorl %r13d, %r13d
movq 0x251d(%rip), %rax      # 0x3fd0
movq (%rax), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x882(%rip), %rsi       # 0x2347
leaq 0x2614(%rip), %rdx      # 0x40e0
xorl %eax, %eax
callq 0x10e0
movl %r13d, %edi
leaq 0x30(%rsp), %rsi
movl $0x15, %edx
callq 0x1110
testl %eax, %eax
js 0x1b06
movl %r13d, %edi
movl $0x4, %esi
callq 0x10f0
movq 0x24d3(%rip), %r15      # 0x3fd0
leaq 0x25dc(%rip), %r12      # 0x40e0
jmp 0x1b52
testl %r13d, %r13d
jle 0x1b13
movl %r13d, %edi
callq 0x10c0
movq 0x24b6(%rip), %r15      # 0x3fd0
movq (%r15), %r14
callq 0x127c
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x825(%rip), %rsi       # 0x235d
leaq 0x25a1(%rip), %r12      # 0x40e0
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10e0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq (%r15), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x6cb(%rip), %rsi       # 0x222f
movq %r12, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x10e0
jmp 0x15da
movl %r14d, %r13d
movl %r13d, %r14d
movq 0x244d(%rip), %r13      # 0x3fd0
movl 0x4(%rsp), %r15d
jmp 0x14d6
callq 0x1040
movl (%rax), %edi
callq 0x1150
movq %r14, %rdi
leaq 0x554(%rip), %rsi       # 0x20f7
leaq 0x2536(%rip), %rdx      # 0x40e0
movq %rbx, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x10e0
movl $0x2, %edi
callq 0x1160
jmp 0x1429
movq 0x2403(%rip), %r13      # 0x3fd0
movl 0x4(%rsp), %r15d
testl %r14d, %r14d
jle 0x1bdf
movl %r14d, %edi
callq 0x10c0
xorl %ebx, %ebx
movl (%rbx,%rbp), %edi
testl %edi, %edi
jle 0x1bf4
callq 0x10c0
movl $0xffffffff, (%rbx,%rbp) # imm = 0xFFFFFFFF
addq $0x8, %rbx
cmpq $0x100, %rbx            # imm = 0x100
jne 0x1be1
movq (%r13), %r14
callq 0x127c
movq %r14, %rdi
leaq 0x631(%rip), %rsi       # 0x2245
leaq 0x24c5(%rip), %rdx      # 0x40e0
leaq 0x5a0(%rip), %rcx       # 0x21c2
xorl %eax, %eax
callq 0x10e0
testl %r15d, %r15d
movq 0x10(%rsp), %rbx
je 0x1429
movl %r15d, %edi
callq 0x10c0
jmp 0x1429
movq 0x2385(%rip), %rbx      # 0x3fd0
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
callq 0x127c
callq 0x1040
movl (%rax), %r12d
movl %r12d, %edi
callq 0x1150
movq %rax, %r10
movq 0x18(%rsp), %rdi
leaq 0x556(%rip), %rsi       # 0x21cd
leaq 0x2462(%rip), %rdx      # 0x40e0
leaq 0x53d(%rip), %rcx       # 0x21c2
movl %r15d, %r8d
movl %r13d, %r9d
movq %rbx, %r13
xorl %eax, %eax
pushq %r10
pushq %r12
callq 0x10e0
addq $0x10, %rsp
cmpl 0x4(%rsp), %r15d
je 0x1bcd
movl %r15d, %edi
callq 0x1df7
movl 0x4(%rsp), %r15d
jmp 0x1c29
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x3fe(%rip), %r14       # 0x20c4
jmp 0x1cd4
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x405(%rip), %r14       # 0x20d9
movq 0x22f5(%rip), %rax      # 0x3fd0
movq (%rax), %r15
callq 0x127c
leaq 0x23f6(%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