// File: /workspace/github_c_makefile_star2_O1/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 0x1115b(%rip), %rsi     # 0x20f96
movl $0xc, %edx
callq 0x5090
xorl %ebx, %ebx
testl %eax, %eax
je 0xfe5d
movl %ebx, %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0xaa, %r14
leaq 0x11138(%rip), %rdx     # 0x20fa3
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 0xfc09
testq %rax, %rax
je 0xfe4b
movzbl 0xc(%rsp), %eax
cmpl $0x31, %eax
je 0xfe4b
cmpl $0x59, %eax
je 0xfe4b
leaq 0x11768(%rip), %rsi     # 0x21619
leaq 0x10(%rsp), %rdi
callq 0x5470
testq %rax, %rax
je 0xfef4
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 0xff84
movq %r14, %rdi
callq 0x5130
jmp 0xfe4b
movq 0x1a0c5(%rip), %rax     # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
movq %rax, %r15
callq 0x5070
movq %rax, %r14
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x110a1(%rip), %rsi     # 0x20fbf
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movq %r15, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1ad6b(%rip), %rax     # 0x2aca8
movq (%rax), %r15
movl $0x1, %ebx
testq %r15, %r15
je 0xfe4b
callq 0xeb2f
movq %rax, %r12
movl (%r14), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x11058(%rip), %rsi     # 0x20fbf
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
jmp 0xfe4b
movq 0x1a035(%rip), %rax     # 0x29fc0
movq (%rax), %r15
callq 0xeb2f
movq %rax, %r12
callq 0x5070
movq %rax, %rbx
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0x1103e(%rip), %rsi     # 0x20fec
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rdx
movl %ebp, %r8d
movq %rax, %r9
xorl %eax, %eax
callq 0x52c0
leaq 0x1acdb(%rip), %rax     # 0x2aca8
movq (%rax), %r15
testq %r15, %r15
je 0x10005
callq 0xeb2f
movq %rax, %r12
movl (%rbx), %ebx
movl %ebx, %edi
callq 0x5530
leaq 0x10fff(%rip), %rsi     # 0x20fec
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 0xfe4b