// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/qmap_bridge_mode.c
// Function: ql_enable_qmi_wwan_rawip_mode
int ql_enable_qmi_wwan_rawip_mode(PROFILE_T *profile) {
    char filename[256];
    char buf[4];
    size_t n;
    FILE *fp;

    if (!qmidev_is_qmiwwan(profile->qmichannel))
        return 0;

    snprintf(filename, sizeof(filename), "/sys/class/net/%s/qmi/rawip", profile->usbnet_adapter);
    n = ql_fread(filename, buf, sizeof(buf));

    if (n == 0)
        return 0;

    if (buf[0] == '1' || buf[0] == 'Y')
        return 0;

    fp = fopen(filename , "w");
    if (fp == NULL) {
        dbg_time("Fail to fopen(%s, \"w\"), errno: %d (%s)", filename, errno, strerror(errno));
        return 1;
    }

    buf[0] = 'Y';
    n = fwrite(buf, 1, 1, fp);
    if (n != 1) {
        dbg_time("Fail to fwrite(%s), errno: %d (%s)", filename, errno, strerror(errno));
        fclose(fp);
        return 1;
    }
    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8a, %rdi
leaq 0x18a19(%rip), %rsi     # 0x2e18a
movl $0xc, %edx
callq 0x5090
cmpl $0x0, %eax
je 0x1578c
movl $0x0, -0x4(%rbp)
jmp 0x15a83
leaq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rcx
addq $0xaa, %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0x189ed(%rip), %rdx     # 0x2e197
movb $0x0, %al
callq 0x51c0
leaq -0x110(%rbp), %rdi
leaq -0x114(%rbp), %rsi
movl $0x4, %edx
callq 0x15460
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
jne 0x157e6
movl $0x0, -0x4(%rbp)
jmp 0x15a83
movsbl -0x114(%rbp), %eax
cmpl $0x31, %eax
je 0x157fe
movsbl -0x114(%rbp), %eax
cmpl $0x59, %eax
jne 0x1580a
movl $0x0, -0x4(%rbp)
jmp 0x15a83
leaq -0x110(%rbp), %rdi
leaq 0x19091(%rip), %rsi     # 0x2e8a9
callq 0x5480
movq %rax, -0x128(%rbp)
cmpq $0x0, -0x128(%rbp)
jne 0x15931
jmp 0x15834
movq 0x217a5(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x148(%rbp)
callq 0x13930
movq %rax, -0x140(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x138(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x12c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rdx
movq -0x138(%rbp), %rcx
movl -0x12c(%rbp), %r8d
movq %rax, %r9
leaq 0x18915(%rip), %rsi     # 0x2e1b3
movb $0x0, %al
callq 0x52c0
leaq 0x225bc(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x15923
leaq 0x225af(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x168(%rbp)
callq 0x13930
movq %rax, -0x160(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x158(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x14c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rdx
movq -0x158(%rbp), %rcx
movl -0x14c(%rbp), %r8d
movq %rax, %r9
leaq 0x18897(%rip), %rsi     # 0x2e1b3
movb $0x0, %al
callq 0x52c0
jmp 0x15925
movl $0x1, -0x4(%rbp)
jmp 0x15a83
movb $0x59, -0x114(%rbp)
leaq -0x114(%rbp), %rdi
movq -0x128(%rbp), %rcx
movl $0x1, %edx
movq %rdx, %rsi
callq 0x5510
movq %rax, -0x120(%rbp)
cmpq $0x1, -0x120(%rbp)
je 0x15a70
jmp 0x1596a
movq 0x2166f(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x188(%rbp)
callq 0x13930
movq %rax, -0x180(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x178(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x16c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x188(%rbp), %rdi
movq -0x180(%rbp), %rdx
movq -0x178(%rbp), %rcx
movl -0x16c(%rbp), %r8d
movq %rax, %r9
leaq 0x1880c(%rip), %rsi     # 0x2e1e0
movb $0x0, %al
callq 0x52c0
leaq 0x22486(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0x15a59
leaq 0x22479(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
callq 0x13930
movq %rax, -0x1a0(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x198(%rbp)
callq 0x5070
movl (%rax), %eax
movl %eax, -0x18c(%rbp)
callq 0x5070
movl (%rax), %edi
callq 0x5540
movq -0x1a8(%rbp), %rdi
movq -0x1a0(%rbp), %rdx
movq -0x198(%rbp), %rcx
movl -0x18c(%rbp), %r8d
movq %rax, %r9
leaq 0x1878e(%rip), %rsi     # 0x2e1e0
movb $0x0, %al
callq 0x52c0
jmp 0x15a5b
movq -0x128(%rbp), %rdi
callq 0x5130
movl $0x1, -0x4(%rbp)
jmp 0x15a83
movq -0x128(%rbp), %rdi
callq 0x5130
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nop