#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 ifreq {
  int /*<<< orphan*/ ifr_flags;
  scalar_t__ *ifr_name;
};
struct if_nameindex {
  char *if_name;
  scalar_t__ if_index;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IFF_UP;
int IFNAMSIZ;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct if_nameindex *if_nameindex();
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(scalar_t__ *, char *, int);
int ifdown(void) {
  struct if_nameindex *ifa, *ifp;
  struct ifreq ifr;
  int fd, shaper;
  if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    fprintf(stderr, "ifdown: ");
    perror("socket");
    goto error;
  }
  if ((ifa = if_nameindex()) == NULL) {
    fprintf(stderr, "ifdown: ");
    perror("if_nameindex");
    goto error;
  }
  for (shaper = 1; shaper >= 0; shaper--) {
    for (ifp = ifa; ifp->if_index; ifp++) {
      if ((strncmp(ifp->if_name, "shaper", 6) == 0) != shaper)
        continue;
      if (strcmp(ifp->if_name, "lo") == 0)
        continue;
      if (strchr(ifp->if_name, ':') != NULL)
        continue;
      strncpy(ifr.ifr_name, ifp->if_name, IFNAMSIZ - 1);
      ifr.ifr_name[IFNAMSIZ - 1] = 0;
      if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
        fprintf(stderr, "ifdown: shutdown ");
        perror(ifp->if_name);
        goto error;
      }
      ifr.ifr_flags &= ~(IFF_UP);
      if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
        fprintf(stderr, "ifdown: shutdown ");
        perror(ifp->if_name);
        goto error;
      }
    }
  }
  close(fd);
  return 0;
error:
  close(fd);
  return -1;
}


x86 assembly (clang, -O0):
<ifdown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    11f3 <ifdown+0x53>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xe20(%rip),%rdi
call   10b0 <perror@plt>
jmp    13da <ifdown+0x23a>
mov    $0x0,%al
call   10a0 <if_nameindex@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    122e <ifdown+0x8e>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xdec(%rip),%rdi
call   10b0 <perror@plt>
jmp    13da <ifdown+0x23a>
movl   $0x1,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jl     13c6 <ifdown+0x226>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     13b3 <ifdown+0x213>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdb9(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmp    -0x30(%rbp),%eax
je     1288 <ifdown+0xe8>
jmp    13a2 <ifdown+0x202>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd8e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12aa <ifdown+0x10a>
jmp    13a2 <ifdown+0x202>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     12ca <ifdown+0x12a>
jmp    13a2 <ifdown+0x202>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    0x2cd4(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
mov    0x2cbf(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%edi
mov    0x2cbd(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1346 <ifdown+0x1a6>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xcf7(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
jmp    13da <ifdown+0x23a>
mov    0x2c8b(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    139d <ifdown+0x1fd>
mov    0x2c3a(%rip),%rax
mov    (%rax),%edi
lea    0xca0(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
jmp    13da <ifdown+0x23a>
jmp    13a2 <ifdown+0x202>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    1247 <ifdown+0xa7>
jmp    13b8 <ifdown+0x218>
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x30(%rbp)
jmp    1235 <ifdown+0x95>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    13e9 <ifdown+0x249>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ifdown>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
js     13fc <ifdown+0x25c>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <if_nameindex@plt>
test   %rax,%rax
je     141a <ifdown+0x27a>
mov    %rax,%r13
cmpq   $0x0,0x8(%rax)
je     13e3 <ifdown+0x243>
lea    0xe24(%rip),%rbx
lea    0xe24(%rip),%r12
mov    0x2da9(%rip),%r14
mov    %r13,%rbp
jmp    121f <ifdown+0x7f>
nopl   0x0(%rax)
cmpq   $0x0,0x18(%rbp)
lea    0x10(%rbp),%rbp
je     12e4 <ifdown+0x144>
mov    0x0(%rbp),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1210 <ifdown+0x70>
mov    0x0(%rbp),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1210 <ifdown+0x70>
mov    0x0(%rbp),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1210 <ifdown+0x70>
mov    %r12,%rbx
mov    0x10(%rsp),%rdi
mov    0x0(%rbp),%rsi
mov    (%r14),%edx
add    $0xffffffff,%edx
call   1030 <strncpy@plt>
mov    0x10(%rsp),%rax
mov    %r14,%r12
movslq (%r14),%rcx
movq   $0x0,-0x8(%rax,%rcx,8)
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
lea    0x8(%rsp),%r14
mov    %r14,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     13c6 <ifdown+0x226>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r14,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
mov    %r12,%r14
mov    %rbx,%r12
lea    0xd44(%rip),%rbx
jns    1210 <ifdown+0x70>
jmp    13c6 <ifdown+0x226>
cmpq   $0x0,0x8(%r13)
je     13e1 <ifdown+0x241>
lea    0xd27(%rip),%rbx
lea    0xd27(%rip),%r12
lea    0x8(%rsp),%rbp
jmp    131f <ifdown+0x17f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpq   $0x0,0x18(%r13)
lea    0x10(%r13),%r13
je     13e1 <ifdown+0x241>
mov    0x0(%r13),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1310 <ifdown+0x170>
mov    0x0(%r13),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1310 <ifdown+0x170>
mov    0x0(%r13),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1310 <ifdown+0x170>
mov    0x10(%rsp),%rdi
mov    0x0(%r13),%rsi
mov    (%r14),%edx
add    $0xffffffff,%edx
call   1030 <strncpy@plt>
mov    0x10(%rsp),%rax
movslq (%r14),%rcx
movq   $0x0,-0x8(%rax,%rcx,8)
mov    0x2c43(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %rbp,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     13c3 <ifdown+0x223>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,0x8(%rsp)
mov    0x2c4b(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %rbp,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    1310 <ifdown+0x170>
mov    %r13,%rbp
mov    0x2beb(%rip),%rax
mov    (%rax),%edi
lea    0xc51(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x0(%rbp),%rdi
jmp    1436 <ifdown+0x296>
xor    %ebx,%ebx
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
lea    0xbf4(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xbf1(%rip),%rdi
jmp    1436 <ifdown+0x296>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
lea    0xbd6(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xbda(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    13e3 <ifdown+0x243>

LLVM IR (-O0):
%struct.if_nameindex = type { i8*, i64 }
%struct.ifreq = type { i32, i64* }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str = [9 x i8] c"ifdown: \00"
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [13 x i8] c"if_nameindex\00"
@.str.3 = [7 x i8] c"shaper\00"
@.str.4 = [3 x i8] c"lo\00"
@IFNAMSIZ = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.5 = [18 x i8] c"ifdown: shutdown \00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
define i32 @ifdown() {
%1 = alloca i32
%2 = alloca %struct.if_nameindex*
%3 = alloca %struct.if_nameindex*
%4 = alloca %struct.ifreq
%5 = alloca i32
%6 = alloca i32
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = call i32 @socket(i32 %7, i32 %8, i32 0)
store i32 %9, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %111
15: ; preds = %0
%16 = call %struct.if_nameindex* (...) @if_nameindex()
store %struct.if_nameindex* %16, %struct.if_nameindex** %2
%17 = icmp eq %struct.if_nameindex* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %111
22: ; preds = %15
store i32 1, i32* %6
br label %23
23: ; preds = %105, %22
%24 = load i32, i32* %6
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %108
26: ; preds = %23
%27 = load %struct.if_nameindex*, %struct.if_nameindex** %2
store %struct.if_nameindex* %27, %struct.if_nameindex** %3
br label %28
28: ; preds = %101, %26
%29 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%30 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %29, i32 0, i32 1
%31 = load i64, i64* %30
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %104
33: ; preds = %28
%34 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%35 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%38 = icmp eq i64 %37, 0
%39 = zext i1 %38 to i32
%40 = load i32, i32* %6
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %43
42: ; preds = %33
br label %101
43: ; preds = %33
%44 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%45 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %44, i32 0, i32 0
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %43
br label %101
50: ; preds = %43
%51 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%52 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %51, i32 0, i32 0
%53 = load i8*, i8** %52
%54 = call i32* @strchr(i8* %53, i8 signext 58)
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %57
56: ; preds = %50
br label %101
57: ; preds = %50
%58 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%59 = load i64*, i64** %58
%60 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%61 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %60, i32 0, i32 0
%62 = load i8*, i8** %61
%63 = load i32, i32* @IFNAMSIZ
%64 = sub nsw i32 %63, 1
%65 = call i32 @strncpy(i64* %59, i8* %62, i32 %64)
%66 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%67 = load i64*, i64** %66
%68 = load i32, i32* @IFNAMSIZ
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i64, i64* %67, i64 %70
store i64 0, i64* %71
%72 = load i32, i32* %5
%73 = load i32, i32* @SIOCGIFFLAGS
%74 = call i64 @ioctl(i32 %72, i32 %73, %struct.ifreq* %4)
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %83
76: ; preds = %57
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%79 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%80 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %79, i32 0, i32 0
%81 = load i8*, i8** %80
%82 = call i32 @perror(i8* %81)
br label %111
83: ; preds = %57
%84 = load i32, i32* @IFF_UP
%85 = xor i32 %84, -1
%86 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%87 = load i32, i32* %86
%88 = and i32 %87, %85
store i32 %88, i32* %86
%89 = load i32, i32* %5
%90 = load i32, i32* @SIOCSIFFLAGS
%91 = call i64 @ioctl(i32 %89, i32 %90, %struct.ifreq* %4)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %100
93: ; preds = %83
%94 = load i32, i32* @stderr
%95 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%96 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%97 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %96, i32 0, i32 0
%98 = load i8*, i8** %97
%99 = call i32 @perror(i8* %98)
br label %111
100: ; preds = %83
br label %101
101: ; preds = %100, %56, %49, %42
%102 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%103 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %102, i32 1
store %struct.if_nameindex* %103, %struct.if_nameindex** %3
br label %28
104: ; preds = %28
br label %105
105: ; preds = %104
%106 = load i32, i32* %6
%107 = add nsw i32 %106, -1
store i32 %107, i32* %6
br label %23
108: ; preds = %23
%109 = load i32, i32* %5
%110 = call i32 @close(i32 %109)
store i32 0, i32* %1
br label %114
111: ; preds = %93, %76, %18, %11
%112 = load i32, i32* %5
%113 = call i32 @close(i32 %112)
store i32 -1, i32* %1
br label %114
114: ; preds = %111, %108
%115 = load i32, i32* %1
ret i32 %115
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i64* }
%struct.if_nameindex = type { i8*, i64 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@stderr = global i32 0
@.str = [9 x i8] c"ifdown: \00"
@.str.1 = [7 x i8] c"socket\00"
@.str.2 = [13 x i8] c"if_nameindex\00"
@.str.3 = [7 x i8] c"shaper\00"
@.str.4 = [3 x i8] c"lo\00"
@IFNAMSIZ = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.5 = [18 x i8] c"ifdown: shutdown \00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
define i32 @ifdown() {
%1 = alloca %struct.ifreq
%2 = bitcast %struct.ifreq* %1 to i8*
%3 = load i32, i32* @AF_INET
%4 = load i32, i32* @SOCK_DGRAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %121
11: ; preds = %0
%12 = tail call %struct.if_nameindex* (...) @if_nameindex()
%13 = icmp eq %struct.if_nameindex* %12, null
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %12, i64 0, i32 1
%16 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %1, i64 0, i32 1
%17 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %1, i64 0, i32 0
%18 = load i64, i64* %15
%19 = icmp eq i64 %18, 0
br i1 %19, label %121, label %24
20: ; preds = %11
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %121
24: ; preds = %14, %72
%25 = phi %struct.if_nameindex* [ %73, %72 ], [ %12, %14 ]
%26 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %25, i64 0, i32 0
%27 = load i8*, i8** %26
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %72
30: ; preds = %24
%31 = load i8*, i8** %26
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %72, label %34
34: ; preds = %30
%35 = load i8*, i8** %26
%36 = call i32* @strchr(i8* %35, i8 signext 58)
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %72
38: ; preds = %34
%39 = load i64*, i64** %16
%40 = load i8*, i8** %26
%41 = load i32, i32* @IFNAMSIZ
%42 = add nsw i32 %41, -1
%43 = call i32 @strncpy(i64* %39, i8* %40, i32 %42)
%44 = load i64*, i64** %16
%45 = load i32, i32* @IFNAMSIZ
%46 = add nsw i32 %45, -1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i64, i64* %44, i64 %47
store i64 0, i64* %48
%49 = load i32, i32* @SIOCGIFFLAGS
%50 = call i64 @ioctl(i32 %5, i32 %49, %struct.ifreq* %1)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %38, %94
%53 = phi i8** [ %82, %94 ], [ %26, %38 ]
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%56 = load i8*, i8** %53
%57 = call i32 @perror(i8* %56)
br label %121
58: ; preds = %38
%59 = load i32, i32* @IFF_UP
%60 = xor i32 %59, -1
%61 = load i32, i32* %17
%62 = and i32 %61, %60
store i32 %62, i32* %17
%63 = load i32, i32* @SIOCSIFFLAGS
%64 = call i64 @ioctl(i32 %5, i32 %63, %struct.ifreq* %1)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %58, %108
%67 = phi i8** [ %82, %108 ], [ %26, %58 ]
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%70 = load i8*, i8** %67
%71 = call i32 @perror(i8* %70)
br label %121
72: ; preds = %58, %34, %30, %24
%73 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %25, i64 1
%74 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %25, i64 1, i32 1
%75 = load i64, i64* %74
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %24
77: ; preds = %72
%78 = load i64, i64* %15
%79 = icmp eq i64 %78, 0
br i1 %79, label %121, label %80
80: ; preds = %77, %116
%81 = phi %struct.if_nameindex* [ %117, %116 ], [ %12, %77 ]
%82 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %81, i64 0, i32 0
%83 = load i8*, i8** %82
%84 = call i64 @strncmp(i8* %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%85 = icmp eq i64 %84, 0
br i1 %85, label %116, label %86
86: ; preds = %80
%87 = load i8*, i8** %82
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %116, label %90
90: ; preds = %86
%91 = load i8*, i8** %82
%92 = call i32* @strchr(i8* %91, i8 signext 58)
%93 = icmp eq i32* %92, null
br i1 %93, label %94, label %116
94: ; preds = %90
%95 = load i64*, i64** %16
%96 = load i8*, i8** %82
%97 = load i32, i32* @IFNAMSIZ
%98 = add nsw i32 %97, -1
%99 = call i32 @strncpy(i64* %95, i8* %96, i32 %98)
%100 = load i64*, i64** %16
%101 = load i32, i32* @IFNAMSIZ
%102 = add nsw i32 %101, -1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i64, i64* %100, i64 %103
store i64 0, i64* %104
%105 = load i32, i32* @SIOCGIFFLAGS
%106 = call i64 @ioctl(i32 %5, i32 %105, %struct.ifreq* %1)
%107 = icmp slt i64 %106, 0
br i1 %107, label %52, label %108
108: ; preds = %94
%109 = load i32, i32* @IFF_UP
%110 = xor i32 %109, -1
%111 = load i32, i32* %17
%112 = and i32 %111, %110
store i32 %112, i32* %17
%113 = load i32, i32* @SIOCSIFFLAGS
%114 = call i64 @ioctl(i32 %5, i32 %113, %struct.ifreq* %1)
%115 = icmp slt i64 %114, 0
br i1 %115, label %66, label %116
116: ; preds = %108, %90, %86, %80
%117 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %81, i64 1
%118 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %81, i64 1, i32 1
%119 = load i64, i64* %118
%120 = icmp eq i64 %119, 0
br i1 %120, label %121, label %80
121: ; preds = %116, %7, %20, %52, %66, %77, %14
%122 = phi i32 [ 0, %14 ], [ 0, %77 ], [ -1, %66 ], [ -1, %52 ], [ -1, %20 ], [ -1, %7 ], [ 0, %116 ]
%123 = call i32 @close(i32 %5)
ret i32 %122
}