// File: /workspace/github_c_makefile_star2_O3/Carton32[P]quectel-CM/device.c
// Function: ql_get_netcard_driver_info
int ql_get_netcard_driver_info(const char *devname)
{
    int fd = -1;
    struct ethtool_drvinfo drvinfo;
    struct ifreq ifr;	/* ifreq suitable for ethtool ioctl */

    memset(&ifr, 0, sizeof(ifr));
    strcpy(ifr.ifr_name, devname);

    fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (fd < 0) {
        dbg_time("Cannot get control socket: errno(%d)(%s)", errno, strerror(errno));
        return -1;
    }

    drvinfo.cmd = ETHTOOL_GDRVINFO;
    ifr.ifr_data = (void *)&drvinfo;

    if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) {
        dbg_time("ioctl() error: errno(%d)(%s)", errno, strerror(errno));
        close(fd);
        return -1;
    }

    dbg_time("netcard driver = %s, driver version = %s", drvinfo.driver, drvinfo.version);

    close(fd);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %rsi
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movq $0x0, 0x20(%rdi)
callq 0x50a0
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x55a0
testl %eax, %eax
js 0x17b12
movl %eax, %ebx
leaq 0x34(%rsp), %rax
movl $0x3, (%rax)
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
movl $0x8946, %esi           # imm = 0x8946
movl %ebx, %edi
xorl %eax, %eax
callq 0x5210
movl %eax, %ebp
movq 0x12521(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq %rax, %r15
testl %ebp, %ebp
js 0x17b92
leaq 0x38(%rsp), %r12
leaq 0x58(%rsp), %r13
leaq 0xb1c0(%rip), %rsi      # 0x22c83
xorl %ebp, %ebp
movq %r14, %rdi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x131c9(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x17b06
callq 0xea3b
leaq 0xb190(%rip), %rsi      # 0x22c83
movq %r14, %rdi
movq %rax, %rdx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x52c0
movl %ebx, %edi
callq 0x5230
jmp 0x17c03
movq 0x124a7(%rip), %rax     # 0x29fc0
movq (%rax), %r14
callq 0xea3b
movq %rax, %r15
callq 0x5070
movq %rax, %rbx
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0xb0f5(%rip), %rsi      # 0x22c31
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x13153(%rip), %rax     # 0x2aca8
movq (%rax), %r14
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x17c03
callq 0xea3b
movq %rax, %r15
movl (%rbx), %ebx
movl %ebx, %edi
callq 0x5530
leaq 0xb0b3(%rip), %rsi      # 0x22c31
movq %r14, %rdi
movq %r15, %rdx
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
jmp 0x17c03
callq 0x5070
movq %rax, %r12
movl (%rax), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0xb0b6(%rip), %rsi      # 0x22c60
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
leaq 0x130e5(%rip), %rax     # 0x2aca8
movq (%rax), %r14
testq %r14, %r14
je 0x17bf7
callq 0xea3b
movq %rax, %r15
movl (%r12), %ebp
movl %ebp, %edi
callq 0x5530
leaq 0xb07b(%rip), %rsi      # 0x22c60
movq %r14, %rdi
movq %r15, %rdx
movl %ebp, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x52c0
movl %ebx, %edi
callq 0x5230
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq