#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");
    return -1;
  }
  if ((ifa = if_nameindex()) == NULL) {
    fprintf(stderr, "ifdown: ");
    perror("if_nameindex");
    return -1;
  }
  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);
        return -1;
      }
      ifr.ifr_flags &= ~(IFF_UP);
      if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
        fprintf(stderr, "ifdown: shutdown ");
        perror(ifp->if_name);
        return -1;
      }
    }
  }
  close(fd);
  return 0;
}


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    11fa <ifdown+0x5a>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xe20(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d2 <ifdown+0x232>
mov    $0x0,%al
call   10a0 <if_nameindex@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    123c <ifdown+0x9c>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xde5(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d2 <ifdown+0x232>
movl   $0x1,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     13c3 <ifdown+0x223>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     13b0 <ifdown+0x210>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xdab(%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     1296 <ifdown+0xf6>
jmp    139f <ifdown+0x1ff>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
lea    0xd80(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12b8 <ifdown+0x118>
jmp    139f <ifdown+0x1ff>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
je     12d8 <ifdown+0x138>
jmp    139f <ifdown+0x1ff>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    0x2cc7(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    -0x24(%rbp),%edi
mov    0x2cce(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    133c <ifdown+0x19c>
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
lea    0xd08(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d2 <ifdown+0x232>
mov    0x2c95(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2ca0(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    139a <ifdown+0x1fa>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xcaa(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d2 <ifdown+0x232>
jmp    139f <ifdown+0x1ff>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    1255 <ifdown+0xb5>
jmp    13b5 <ifdown+0x215>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1243 <ifdown+0xa3>
mov    -0x24(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-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>
test   %eax,%eax
js     13b9 <ifdown+0x219>
mov    %eax,%r14d
xor    %eax,%eax
call   10a0 <if_nameindex@plt>
test   %rax,%rax
je     13d7 <ifdown+0x237>
mov    %rax,%r13
cmpq   $0x0,0x8(%rax)
je     13a0 <ifdown+0x200>
lea    0xe29(%rip),%rbp
lea    0xe29(%rip),%r15
mov    %rsp,%r12
mov    %r13,%rbx
jmp    121f <ifdown+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpq   $0x0,0x18(%rbx)
lea    0x10(%rbx),%rbx
je     12b8 <ifdown+0x118>
mov    (%rbx),%rdi
mov    %rbp,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1210 <ifdown+0x70>
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1210 <ifdown+0x70>
mov    (%rbx),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1210 <ifdown+0x70>
mov    0x4(%rsp),%edi
mov    (%rbx),%rsi
mov    0x2d4c(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %r12,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     1386 <ifdown+0x1e6>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %r12,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    1210 <ifdown+0x70>
jmp    1386 <ifdown+0x1e6>
cmpq   $0x0,0x8(%r13)
je     13a0 <ifdown+0x200>
lea    0xd53(%rip),%rbp
lea    0xd53(%rip),%r15
mov    %rsp,%r12
jmp    12ef <ifdown+0x14f>
cs nopw 0x0(%rax,%rax,1)
cmpq   $0x0,0x18(%r13)
lea    0x10(%r13),%r13
je     13a0 <ifdown+0x200>
mov    0x0(%r13),%rdi
mov    %rbp,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12e0 <ifdown+0x140>
mov    0x0(%r13),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     12e0 <ifdown+0x140>
mov    0x0(%r13),%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12e0 <ifdown+0x140>
mov    0x4(%rsp),%edi
mov    0x0(%r13),%rsi
mov    0x2c78(%rip),%rax
mov    (%rax),%edx
call   1030 <strncpy@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %r12,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     1383 <ifdown+0x1e3>
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%rsp)
mov    0x2c8b(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %r12,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
jns    12e0 <ifdown+0x140>
mov    %r13,%rbx
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
lea    0xc91(%rip),%rsi
call   1090 <fprintf@plt>
mov    (%rbx),%rdi
jmp    13f3 <ifdown+0x253>
mov    %r14d,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
lea    0xc37(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xc34(%rip),%rdi
jmp    13f3 <ifdown+0x253>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xc19(%rip),%rsi
call   1090 <fprintf@plt>
lea    0xc1d(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%eax
jmp    13aa <ifdown+0x20a>

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))
store i32 -1, i32* %1
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))
store i32 -1, i32* %1
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)
store i32 -1, i32* %1
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)
store i32 -1, i32* %1
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 %104
104: ; preds = %101, %86, %69, %18, %11
%105 = load i32, i32* %1
ret i32 %105
}

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 %111
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 %111
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 %111
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 %111
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, %14, %71
%110 = call i32 @close(i32 %5)
br label %111
111: ; preds = %109, %60, %46, %20, %7
%112 = phi i32 [ -1, %7 ], [ -1, %20 ], [ -1, %46 ], [ -1, %60 ], [ 0, %109 ]
ret i32 %112
}