#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct ethtool_stats {
  int n_stats;
  int len;
  unsigned int *data;
  int /*<<< orphan*/ cmd;
  int /*<<< orphan*/ string_set;
};
struct ethtool_gstrings {
  int n_stats;
  int len;
  unsigned int *data;
  int /*<<< orphan*/ cmd;
  int /*<<< orphan*/ string_set;
};
struct ethtool_drvinfo {
  int n_stats;
  int len;
  unsigned int *data;
  int /*<<< orphan*/ cmd;
  int /*<<< orphan*/ string_set;
};
typedef int /*<<< orphan*/ info;
typedef int /*<<< orphan*/ __u64;

/* Variables and functions */
int /*<<< orphan*/ ETHTOOL_GDRVINFO;
int /*<<< orphan*/ ETHTOOL_GSTATS;
int /*<<< orphan*/ ETHTOOL_GSTRINGS;
int ETH_GSTRING_LEN;
int /*<<< orphan*/ ETH_SS_STATS;
scalar_t__ ethtool_ioctl(char const *, struct ethtool_stats *);
int /*<<< orphan*/ free(struct ethtool_stats *);
struct ethtool_stats *malloc(int);
int /*<<< orphan*/ memset(struct ethtool_stats *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned int ethtool_veth_peer(const char *ifname) {
  struct ethtool_drvinfo info;
  struct ethtool_gstrings *strs;
  struct ethtool_stats *stats;
  unsigned int i, res = 0;
  memset(&info, 0, sizeof(info));
  info.cmd = ETHTOOL_GDRVINFO;
  if (ethtool_ioctl(ifname, &info))
    return 0;
  if (!info.n_stats)
    return 0;
  strs =
      malloc(sizeof(struct ethtool_gstrings) + info.n_stats * ETH_GSTRING_LEN);
  if (!strs)
    return 0;
  memset(strs, 0, sizeof(struct ethtool_gstrings));
  strs->cmd = ETHTOOL_GSTRINGS;
  strs->string_set = ETH_SS_STATS;
  strs->len = info.n_stats;
  if (ethtool_ioctl(ifname, strs))
    goto fail_strs;
  if (strs->len != info.n_stats)
    goto fail_strs;
  stats = malloc(sizeof(struct ethtool_stats) + info.n_stats * sizeof(__u64));
  if (!stats)
    goto fail_strs;
  memset(stats, 0, sizeof(struct ethtool_stats));
  stats->cmd = ETHTOOL_GSTATS;
  stats->n_stats = info.n_stats;
  if (ethtool_ioctl(ifname, stats))
    goto fail_stats;
  if (stats->n_stats != info.n_stats)
    goto fail_stats;
  for (i = 0; i < info.n_stats; i++) {
    if (!strcmp((char *)strs->data + i * ETH_GSTRING_LEN, "peer_ifindex")) {
      res = stats->data[i];
      break;
    }
  }
fail_stats:
  free(stats);
fail_strs:
  free(strs);
  return res;
}


x86 assembly (clang, -O0):
<ethtool_veth_peer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x40(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <ethtool_ioctl@plt>
cmp    $0x0,%rax
je     11a2 <ethtool_veth_peer+0x52>
movl   $0x0,-0x4(%rbp)
jmp    1360 <ethtool_veth_peer+0x210>
cmpl   $0x0,-0x28(%rbp)
jne    11b8 <ethtool_veth_peer+0x68>
movl   $0x0,-0x4(%rbp)
jmp    1360 <ethtool_veth_peer+0x210>
mov    -0x28(%rbp),%eax
mov    0x2e26(%rip),%rcx
imul   (%rcx),%eax
cltq
add    $0x18,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ed <ethtool_veth_peer+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    1360 <ethtool_veth_peer+0x210>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    0x2db4(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1070 <ethtool_ioctl@plt>
cmp    $0x0,%rax
je     1243 <ethtool_veth_peer+0xf3>
jmp    1351 <ethtool_veth_peer+0x201>
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
cmp    -0x28(%rbp),%eax
je     1258 <ethtool_veth_peer+0x108>
jmp    1351 <ethtool_veth_peer+0x201>
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    $0x18,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    127f <ethtool_veth_peer+0x12f>
jmp    1351 <ethtool_veth_peer+0x201>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <ethtool_ioctl@plt>
cmp    $0x0,%rax
je     12c4 <ethtool_veth_peer+0x174>
jmp    1348 <ethtool_veth_peer+0x1f8>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
cmp    -0x28(%rbp),%eax
je     12d8 <ethtool_veth_peer+0x188>
jmp    1348 <ethtool_veth_peer+0x1f8>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    1343 <ethtool_veth_peer+0x1f3>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x3c(%rbp),%eax
mov    0x2ceb(%rip),%rcx
imul   (%rcx),%eax
mov    %eax,%eax
add    %rax,%rdi
lea    0xcf4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1330 <ethtool_veth_peer+0x1e0>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x3c(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x40(%rbp)
jmp    1343 <ethtool_veth_peer+0x1f3>
jmp    1335 <ethtool_veth_peer+0x1e5>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12df <ethtool_veth_peer+0x18f>
jmp    1348 <ethtool_veth_peer+0x1f8>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ethtool_veth_peer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rbp
xor    %r12d,%r12d
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <ethtool_ioctl@plt>
test   %rax,%rax
je     11a7 <ethtool_veth_peer+0x57>
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
test   %edi,%edi
je     1195 <ethtool_veth_peer+0x45>
mov    0x2e32(%rip),%rbp
imul   0x0(%rbp),%edi
add    $0x18,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1195 <ethtool_veth_peer+0x45>
mov    %rax,%r14
xor    %r12d,%r12d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%r14)
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%r14)
mov    0x8(%rsp),%eax
mov    %eax,0x4(%r14)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <ethtool_ioctl@plt>
test   %rax,%rax
jne    126a <ethtool_veth_peer+0x11a>
mov    0x4(%r14),%eax
cmp    0x8(%rsp),%eax
jne    126a <ethtool_veth_peer+0x11a>
lea    0x18(,%rax,4),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     126a <ethtool_veth_peer+0x11a>
mov    %rax,%r15
xor    %r12d,%r12d
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%r15)
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <ethtool_ioctl@plt>
test   %rax,%rax
je     1277 <ethtool_veth_peer+0x127>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1195 <ethtool_veth_peer+0x45>
mov    (%r15),%ecx
mov    0x8(%rsp),%eax
mov    %rcx,0x20(%rsp)
cmp    %eax,%ecx
jne    1262 <ethtool_veth_peer+0x112>
test   %eax,%eax
je     1262 <ethtool_veth_peer+0x112>
mov    0x8(%r14),%rbx
mov    0x0(%rbp),%ebp
xor    %r12d,%r12d
xor    %r13d,%r13d
mov    %r12d,%edi
add    %rbx,%rdi
lea    0xd5b(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     12c1 <ethtool_veth_peer+0x171>
add    $0x1,%r13
add    %ebp,%r12d
cmp    %r13,0x20(%rsp)
jne    1298 <ethtool_veth_peer+0x148>
xor    %r12d,%r12d
jmp    1262 <ethtool_veth_peer+0x112>
mov    0x8(%r15),%rax
mov    %r13d,%ecx
mov    (%rax,%rcx,4),%r12d
jmp    1262 <ethtool_veth_peer+0x112>

LLVM IR (-O0):
%struct.ethtool_drvinfo = type { i32, i32, i32*, i32, i32 }
%struct.ethtool_gstrings = type { i32, i32, i32*, i32, i32 }
%struct.ethtool_stats = type { i32, i32, i32*, i32, i32 }
@ETHTOOL_GDRVINFO = global i32 0
@ETH_GSTRING_LEN = global i32 0
@ETHTOOL_GSTRINGS = global i32 0
@ETH_SS_STATS = global i32 0
@ETHTOOL_GSTATS = global i32 0
@.str = [13 x i8] c"peer_ifindex\00"
define i32 @ethtool_veth_peer(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.ethtool_drvinfo
%5 = alloca %struct.ethtool_gstrings*
%6 = alloca %struct.ethtool_stats*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %8
%9 = bitcast %struct.ethtool_drvinfo* %4 to %struct.ethtool_stats*
%10 = call i32 @memset(%struct.ethtool_stats* %9, i32 0, i32 24)
%11 = load i32, i32* @ETHTOOL_GDRVINFO
%12 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 3
store i32 %11, i32* %12
%13 = load i8*, i8** %3
%14 = bitcast %struct.ethtool_drvinfo* %4 to %struct.ethtool_stats*
%15 = call i64 @ethtool_ioctl(i8* %13, %struct.ethtool_stats* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %1
store i32 0, i32* %2
br label %137
18: ; preds = %1
%19 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%20 = load i32, i32* %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i32 0, i32* %2
br label %137
23: ; preds = %18
%24 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%25 = load i32, i32* %24
%26 = load i32, i32* @ETH_GSTRING_LEN
%27 = mul nsw i32 %25, %26
%28 = sext i32 %27 to i64
%29 = add i64 24, %28
%30 = trunc i64 %29 to i32
%31 = call %struct.ethtool_stats* @malloc(i32 %30)
%32 = bitcast %struct.ethtool_stats* %31 to %struct.ethtool_gstrings*
store %struct.ethtool_gstrings* %32, %struct.ethtool_gstrings** %5
%33 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%34 = icmp ne %struct.ethtool_gstrings* %33, null
br i1 %34, label %36, label %35
35: ; preds = %23
store i32 0, i32* %2
br label %137
36: ; preds = %23
%37 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%38 = bitcast %struct.ethtool_gstrings* %37 to %struct.ethtool_stats*
%39 = call i32 @memset(%struct.ethtool_stats* %38, i32 0, i32 24)
%40 = load i32, i32* @ETHTOOL_GSTRINGS
%41 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%42 = getelementptr inbounds %struct.ethtool_gstrings, %struct.ethtool_gstrings* %41, i32 0, i32 3
store i32 %40, i32* %42
%43 = load i32, i32* @ETH_SS_STATS
%44 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%45 = getelementptr inbounds %struct.ethtool_gstrings, %struct.ethtool_gstrings* %44, i32 0, i32 4
store i32 %43, i32* %45
%46 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%47 = load i32, i32* %46
%48 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%49 = getelementptr inbounds %struct.ethtool_gstrings, %struct.ethtool_gstrings* %48, i32 0, i32 1
store i32 %47, i32* %49
%50 = load i8*, i8** %3
%51 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%52 = bitcast %struct.ethtool_gstrings* %51 to %struct.ethtool_stats*
%53 = call i64 @ethtool_ioctl(i8* %50, %struct.ethtool_stats* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %36
br label %132
56: ; preds = %36
%57 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%58 = getelementptr inbounds %struct.ethtool_gstrings, %struct.ethtool_gstrings* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%61 = load i32, i32* %60
%62 = icmp ne i32 %59, %61
br i1 %62, label %63, label %64
63: ; preds = %56
br label %132
64: ; preds = %56
%65 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%66 = load i32, i32* %65
%67 = sext i32 %66 to i64
%68 = mul i64 %67, 4
%69 = add i64 24, %68
%70 = trunc i64 %69 to i32
%71 = call %struct.ethtool_stats* @malloc(i32 %70)
store %struct.ethtool_stats* %71, %struct.ethtool_stats** %6
%72 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%73 = icmp ne %struct.ethtool_stats* %72, null
br i1 %73, label %75, label %74
74: ; preds = %64
br label %132
75: ; preds = %64
%76 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%77 = call i32 @memset(%struct.ethtool_stats* %76, i32 0, i32 24)
%78 = load i32, i32* @ETHTOOL_GSTATS
%79 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%80 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %79, i32 0, i32 3
store i32 %78, i32* %80
%81 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%82 = load i32, i32* %81
%83 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%84 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %83, i32 0, i32 0
store i32 %82, i32* %84
%85 = load i8*, i8** %3
%86 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%87 = call i64 @ethtool_ioctl(i8* %85, %struct.ethtool_stats* %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %75
br label %129
90: ; preds = %75
%91 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%92 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %91, i32 0, i32 0
%93 = load i32, i32* %92
%94 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%95 = load i32, i32* %94
%96 = icmp ne i32 %93, %95
br i1 %96, label %97, label %98
97: ; preds = %90
br label %129
98: ; preds = %90
store i32 0, i32* %7
br label %99
99: ; preds = %125, %98
%100 = load i32, i32* %7
%101 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %4, i32 0, i32 0
%102 = load i32, i32* %101
%103 = icmp ult i32 %100, %102
br i1 %103, label %104, label %128
104: ; preds = %99
%105 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%106 = getelementptr inbounds %struct.ethtool_gstrings, %struct.ethtool_gstrings* %105, i32 0, i32 2
%107 = load i32*, i32** %106
%108 = bitcast i32* %107 to i8*
%109 = load i32, i32* %7
%110 = load i32, i32* @ETH_GSTRING_LEN
%111 = mul i32 %109, %110
%112 = zext i32 %111 to i64
%113 = getelementptr inbounds i8, i8* %108, i64 %112
%114 = call i32 @strcmp(i8* %113, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%115 = icmp ne i32 %114, 0
br i1 %115, label %124, label %116
116: ; preds = %104
%117 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%118 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %117, i32 0, i32 2
%119 = load i32*, i32** %118
%120 = load i32, i32* %7
%121 = zext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %119, i64 %121
%123 = load i32, i32* %122
store i32 %123, i32* %8
br label %128
124: ; preds = %104
br label %125
125: ; preds = %124
%126 = load i32, i32* %7
%127 = add i32 %126, 1
store i32 %127, i32* %7
br label %99
128: ; preds = %116, %99
br label %129
129: ; preds = %128, %97, %89
%130 = load %struct.ethtool_stats*, %struct.ethtool_stats** %6
%131 = call i32 @free(%struct.ethtool_stats* %130)
br label %132
132: ; preds = %129, %74, %63, %55
%133 = load %struct.ethtool_gstrings*, %struct.ethtool_gstrings** %5
%134 = bitcast %struct.ethtool_gstrings* %133 to %struct.ethtool_stats*
%135 = call i32 @free(%struct.ethtool_stats* %134)
%136 = load i32, i32* %8
store i32 %136, i32* %2
br label %137
137: ; preds = %132, %35, %22, %17
%138 = load i32, i32* %2
ret i32 %138
}

LLVM IR (-O2):
%struct.ethtool_drvinfo = type { i32, i32, i32*, i32, i32 }
%struct.ethtool_stats = type { i32, i32, i32*, i32, i32 }
@ETHTOOL_GDRVINFO = global i32 0
@ETH_GSTRING_LEN = global i32 0
@ETHTOOL_GSTRINGS = global i32 0
@ETH_SS_STATS = global i32 0
@ETHTOOL_GSTATS = global i32 0
@.str = [13 x i8] c"peer_ifindex\00"
define i32 @ethtool_veth_peer(i8* %0) {
%2 = alloca %struct.ethtool_drvinfo
%3 = bitcast %struct.ethtool_drvinfo* %2 to i8*
%4 = bitcast %struct.ethtool_drvinfo* %2 to %struct.ethtool_stats*
%5 = call i32 @memset(%struct.ethtool_stats* %4, i32 0, i32 24)
%6 = load i32, i32* @ETHTOOL_GDRVINFO
%7 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %2, i64 0, i32 3
store i32 %6, i32* %7
%8 = call i64 @ethtool_ioctl(i8* %0, %struct.ethtool_stats* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %82
10: ; preds = %1
%11 = getelementptr inbounds %struct.ethtool_drvinfo, %struct.ethtool_drvinfo* %2, i64 0, i32 0
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %82, label %14
14: ; preds = %10
%15 = load i32, i32* @ETH_GSTRING_LEN
%16 = mul nsw i32 %15, %12
%17 = add i32 %16, 24
%18 = call %struct.ethtool_stats* @malloc(i32 %17)
%19 = icmp eq %struct.ethtool_stats* %18, null
br i1 %19, label %82, label %20
20: ; preds = %14
%21 = call i32 @memset(%struct.ethtool_stats* %18, i32 0, i32 24)
%22 = load i32, i32* @ETHTOOL_GSTRINGS
%23 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %18, i64 0, i32 3
store i32 %22, i32* %23
%24 = load i32, i32* @ETH_SS_STATS
%25 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %18, i64 0, i32 4
store i32 %24, i32* %25
%26 = load i32, i32* %11
%27 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %18, i64 0, i32 1
store i32 %26, i32* %27
%28 = call i64 @ethtool_ioctl(i8* %0, %struct.ethtool_stats* %18)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %79
30: ; preds = %20
%31 = load i32, i32* %27
%32 = load i32, i32* %11
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %79
34: ; preds = %30
%35 = shl i32 %31, 2
%36 = add i32 %35, 24
%37 = call %struct.ethtool_stats* @malloc(i32 %36)
%38 = icmp eq %struct.ethtool_stats* %37, null
br i1 %38, label %79, label %39
39: ; preds = %34
%40 = call i32 @memset(%struct.ethtool_stats* %37, i32 0, i32 24)
%41 = load i32, i32* @ETHTOOL_GSTATS
%42 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %37, i64 0, i32 3
store i32 %41, i32* %42
%43 = load i32, i32* %11
%44 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %37, i64 0, i32 0
store i32 %43, i32* %44
%45 = call i64 @ethtool_ioctl(i8* %0, %struct.ethtool_stats* %37)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %76
47: ; preds = %39
%48 = load i32, i32* %44
%49 = load i32, i32* %11
%50 = icmp eq i32 %48, %49
%51 = icmp ne i32 %49, 0
%52 = and i1 %50, %51
br i1 %52, label %53, label %76
53: ; preds = %47
%54 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %18, i64 0, i32 2
%55 = bitcast i32** %54 to i8**
%56 = load i8*, i8** %55
%57 = load i32, i32* @ETH_GSTRING_LEN
%58 = zext i32 %48 to i64
br label %59
59: ; preds = %53, %73
%60 = phi i64 [ 0, %53 ], [ %74, %73 ]
%61 = trunc i64 %60 to i32
%62 = mul i32 %57, %61
%63 = zext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %56, i64 %63
%65 = call i32 @strcmp(i8* dereferenceable(1) %64, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %73
67: ; preds = %59
%68 = getelementptr inbounds %struct.ethtool_stats, %struct.ethtool_stats* %37, i64 0, i32 2
%69 = load i32*, i32** %68
%70 = and i64 %60, 4294967295
%71 = getelementptr inbounds i32, i32* %69, i64 %70
%72 = load i32, i32* %71
br label %76
73: ; preds = %59
%74 = add nuw nsw i64 %60, 1
%75 = icmp eq i64 %74, %58
br i1 %75, label %76, label %59
76: ; preds = %73, %67, %47, %39
%77 = phi i32 [ 0, %39 ], [ 0, %47 ], [ %72, %67 ], [ 0, %73 ]
%78 = call i32 @free(%struct.ethtool_stats* %37)
br label %79
79: ; preds = %34, %30, %20, %76
%80 = phi i32 [ 0, %20 ], [ 0, %30 ], [ %77, %76 ], [ 0, %34 ]
%81 = call i32 @free(%struct.ethtool_stats* %18)
br label %82
82: ; preds = %14, %10, %1, %79
%83 = phi i32 [ %80, %79 ], [ 0, %1 ], [ 0, %10 ], [ 0, %14 ]
ret i32 %83
}