// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %r14
addq $0x8a, %rdi
leaq 0x11283(%rip), %rsi     # 0x20f92
movl $0xc, %edx
callq 0x5090
xorl %ebx, %ebx
testl %eax, %eax
je 0xfd31
movl %ebx, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0xaa, %r14
leaq 0x11260(%rip), %rdx     # 0x20f9f
xorl %ebx, %ebx
leaq 0x10(%rsp), %r15
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x51c0
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
movq %r15, %rdi
callq 0xfadd
testq %rax, %rax
je 0xfd1f
movzbl 0xc(%rsp), %eax
cmpl $0x31, %eax
je 0xfd1f
cmpl $0x59, %eax
je 0xfd1f
leaq 0x118bc(%rip), %rsi     # 0x21641
leaq 0x10(%rsp), %rdi
callq 0x5470
testq %rax, %rax
je 0xfdc8
movq %rax, %r14
leaq 0xc(%rsp), %rdi
movb $0x59, (%rdi)
movl $0x1, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x5500
cmpq $0x1, %rax
jne 0xfe58
movq %r14, %rdi
callq 0x5130
jmp 0xfd1f
movq 0x1a1f1(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
movq %rax, %r15
callq 0x5070
movq %rax, %r14
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x111c9(%rip), %rsi     # 0x20fbb
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1ae97(%rip), %rax     # 0x2aca8
movq (%rax), %r15
movl $0x1, %ebx
testq %r15, %r15
je 0xfd1f
callq 0xea3b
movq %rax, %r12
movl (%r14), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x11180(%rip), %rsi     # 0x20fbb
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
jmp 0xfd1f
movq 0x1a161(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xea3b
movq %rax, %r12
callq 0x5070
movq %rax, %rbx
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x11166(%rip), %rsi     # 0x20fe8
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1ae07(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0xfed9
callq 0xea3b
movq %rax, %r12
movl (%rbx), %ebx
movl %ebx, %edi
callq 0x5530
leaq 0x11127(%rip), %rsi     # 0x20fe8
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rdx
movl %ebx, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
movq %r14, %rdi
callq 0x5130
movl $0x1, %ebx
jmp 0xfd1f