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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IFF_UP;
int /*<<< orphan*/ 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(int /*<<< orphan*/, char *, int /*<<< orphan*/);
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);
      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,-0x24(%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    13bb <ifdown+0x21b>
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    13bb <ifdown+0x21b>
movl   $0x1,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     13a7 <ifdown+0x207>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1394 <ifdown+0x1f4>
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    -0x28(%rbp),%eax
je     1288 <ifdown+0xe8>
jmp    1383 <ifdown+0x1e3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd8e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12aa <ifdown+0x10a>
jmp    1383 <ifdown+0x1e3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     12ca <ifdown+0x12a>
jmp    1383 <ifdown+0x1e3>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    0x2cd5(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x24(%rbp),%edi
mov    0x2cdc(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1327 <ifdown+0x187>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
jmp    13bb <ifdown+0x21b>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2cb5(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    137e <ifdown+0x1de>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
lea    0xcbf(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
jmp    13bb <ifdown+0x21b>
jmp    1383 <ifdown+0x1e3>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    1247 <ifdown+0xa7>
jmp    1399 <ifdown+0x1f9>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1235 <ifdown+0x95>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    13ca <ifdown+0x22a>
mov    -0x24(%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
push   %rax
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    0x2e15(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
js     13b8 <ifdown+0x218>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <if_nameindex@plt>
test   %rax,%rax
je     13d6 <ifdown+0x236>
mov    %rax,%r14
cmpq   $0x0,0x8(%rax)
je     139f <ifdown+0x1ff>
lea    0xe27(%rip),%rbx
lea    0xe27(%rip),%r12
mov    %rsp,%r13
mov    %r14,%rbp
jmp    121f <ifdown+0x7f>
cs nopw 0x0(%rax,%rax,1)
nop
cmpq   $0x0,0x18(%rbp)
lea    0x10(%rbp),%rbp
je     12bc <ifdown+0x11c>
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    0x4(%rsp),%edi
mov    0x0(%rbp),%rsi
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r13,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     1382 <ifdown+0x1e2>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2d57(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r13,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    1210 <ifdown+0x70>
jmp    1382 <ifdown+0x1e2>
cmpq   $0x0,0x8(%r14)
je     139d <ifdown+0x1fd>
lea    0xd4f(%rip),%rbx
lea    0xd4f(%rip),%r12
mov    %rsp,%r13
jmp    12ef <ifdown+0x14f>
nopw   0x0(%rax,%rax,1)
cmpq   $0x0,0x18(%r14)
lea    0x10(%r14),%r14
je     139d <ifdown+0x1fd>
mov    (%r14),%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12e0 <ifdown+0x140>
mov    (%r14),%rdi
mov    %r12,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12e0 <ifdown+0x140>
mov    (%r14),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12e0 <ifdown+0x140>
mov    0x4(%rsp),%edi
mov    (%r14),%rsi
mov    0x2c7c(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r13,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     137f <ifdown+0x1df>
mov    0x2c7d(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
mov    %r13,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    12e0 <ifdown+0x140>
mov    %r14,%rbp
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x0(%rbp),%rdi
jmp    13f2 <ifdown+0x252>
xor    %ebx,%ebx
mov    %r15d,%edi
call   1070 <close@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xc35(%rip),%rdi
jmp    13f2 <ifdown+0x252>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
lea    0xc1a(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xc1e(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    139f <ifdown+0x1ff>

LLVM IR (-O0):
%struct.if_nameindex = type { i8*, i64 }
%struct.ifreq = type { i32, i32 }
@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 %104
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 %104
22: ; preds = %15
store i32 1, i32* %6
br label %23
23: ; preds = %98, %22
%24 = load i32, i32* %6
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %101
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 = %94, %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 %97
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 %94
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 %94
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 %94
57: ; preds = %50
%58 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%59 = load i32, i32* %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 = call i32 @strncpy(i32 %59, i8* %62, i32 %63)
%65 = load i32, i32* %5
%66 = load i32, i32* @SIOCGIFFLAGS
%67 = call i64 @ioctl(i32 %65, i32 %66, %struct.ifreq* %4)
%68 = icmp slt i64 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %57
%70 = load i32, i32* @stderr
%71 = call i32 @fprintf(i32 %70, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%72 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%73 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %72, i32 0, i32 0
%74 = load i8*, i8** %73
%75 = call i32 @perror(i8* %74)
br label %104
76: ; preds = %57
%77 = load i32, i32* @IFF_UP
%78 = xor i32 %77, -1
%79 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%80 = load i32, i32* %79
%81 = and i32 %80, %78
store i32 %81, i32* %79
%82 = load i32, i32* %5
%83 = load i32, i32* @SIOCSIFFLAGS
%84 = call i64 @ioctl(i32 %82, i32 %83, %struct.ifreq* %4)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %93
86: ; preds = %76
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%89 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%90 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %89, i32 0, i32 0
%91 = load i8*, i8** %90
%92 = call i32 @perror(i8* %91)
br label %104
93: ; preds = %76
br label %94
94: ; preds = %93, %56, %49, %42
%95 = load %struct.if_nameindex*, %struct.if_nameindex** %3
%96 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %95, i32 1
store %struct.if_nameindex* %96, %struct.if_nameindex** %3
br label %28
97: ; preds = %28
br label %98
98: ; preds = %97
%99 = load i32, i32* %6
%100 = add nsw i32 %99, -1
store i32 %100, i32* %6
br label %23
101: ; preds = %23
%102 = load i32, i32* %5
%103 = call i32 @close(i32 %102)
store i32 0, i32* %1
br label %107
104: ; preds = %86, %69, %18, %11
%105 = load i32, i32* %5
%106 = call i32 @close(i32 %105)
store i32 -1, i32* %1
br label %107
107: ; preds = %104, %101
%108 = load i32, i32* %1
ret i32 %108
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
%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 %109
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 %109, 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 %109
24: ; preds = %14, %66
%25 = phi %struct.if_nameindex* [ %67, %66 ], [ %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 %66
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 %66, 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 %66
38: ; preds = %34
%39 = load i32, i32* %16
%40 = load i8*, i8** %26
%41 = load i32, i32* @IFNAMSIZ
%42 = call i32 @strncpy(i32 %39, i8* %40, i32 %41)
%43 = load i32, i32* @SIOCGIFFLAGS
%44 = call i64 @ioctl(i32 %5, i32 %43, %struct.ifreq* %1)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %38, %88
%47 = phi i8** [ %76, %88 ], [ %26, %38 ]
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%50 = load i8*, i8** %47
%51 = call i32 @perror(i8* %50)
br label %109
52: ; preds = %38
%53 = load i32, i32* @IFF_UP
%54 = xor i32 %53, -1
%55 = load i32, i32* %17
%56 = and i32 %55, %54
store i32 %56, i32* %17
%57 = load i32, i32* @SIOCSIFFLAGS
%58 = call i64 @ioctl(i32 %5, i32 %57, %struct.ifreq* %1)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %52, %96
%61 = phi i8** [ %76, %96 ], [ %26, %52 ]
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%64 = load i8*, i8** %61
%65 = call i32 @perror(i8* %64)
br label %109
66: ; preds = %52, %34, %30, %24
%67 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %25, i64 1
%68 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %25, i64 1, i32 1
%69 = load i64, i64* %68
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %24
71: ; preds = %66
%72 = load i64, i64* %15
%73 = icmp eq i64 %72, 0
br i1 %73, label %109, label %74
74: ; preds = %71, %104
%75 = phi %struct.if_nameindex* [ %105, %104 ], [ %12, %71 ]
%76 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %75, i64 0, i32 0
%77 = load i8*, i8** %76
%78 = call i64 @strncmp(i8* %77, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%79 = icmp eq i64 %78, 0
br i1 %79, label %104, label %80
80: ; preds = %74
%81 = load i8*, i8** %76
%82 = call i64 @strcmp(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%83 = icmp eq i64 %82, 0
br i1 %83, label %104, label %84
84: ; preds = %80
%85 = load i8*, i8** %76
%86 = call i32* @strchr(i8* %85, i8 signext 58)
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %104
88: ; preds = %84
%89 = load i32, i32* %16
%90 = load i8*, i8** %76
%91 = load i32, i32* @IFNAMSIZ
%92 = call i32 @strncpy(i32 %89, i8* %90, i32 %91)
%93 = load i32, i32* @SIOCGIFFLAGS
%94 = call i64 @ioctl(i32 %5, i32 %93, %struct.ifreq* %1)
%95 = icmp slt i64 %94, 0
br i1 %95, label %46, label %96
96: ; preds = %88
%97 = load i32, i32* @IFF_UP
%98 = xor i32 %97, -1
%99 = load i32, i32* %17
%100 = and i32 %99, %98
store i32 %100, i32* %17
%101 = load i32, i32* @SIOCSIFFLAGS
%102 = call i64 @ioctl(i32 %5, i32 %101, %struct.ifreq* %1)
%103 = icmp slt i64 %102, 0
br i1 %103, label %60, label %104
104: ; preds = %96, %84, %80, %74
%105 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %75, i64 1
%106 = getelementptr inbounds %struct.if_nameindex, %struct.if_nameindex* %75, i64 1, i32 1
%107 = load i64, i64* %106
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %74
109: ; preds = %104, %7, %20, %46, %60, %71, %14
%110 = phi i32 [ 0, %14 ], [ 0, %71 ], [ -1, %60 ], [ -1, %46 ], [ -1, %20 ], [ -1, %7 ], [ 0, %104 ]
%111 = call i32 @close(i32 %5)
ret i32 %110
}