#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 ifc_len;
  char *ifc_buf;
  char *ifr_name;
  int ifr_flags;
};
struct ifconf {
  int ifc_len;
  char *ifc_buf;
  char *ifr_name;
  int ifr_flags;
};
typedef int /*<<< orphan*/ ifr_buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int IFF_UP;
int /*<<< orphan*/ SIOCGIFCONF;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
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__ strncmp(char *, char *, int);
int ifdown(void) {
  char ifr_buf[sizeof(struct ifreq) * 64];
  char *ifr_end;
  struct ifconf ifc;
  int fd;
  int shaper;
  if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    fprintf(stderr, "ifdown: ");
    perror("socket");
    return -1;
  }
  ifc.ifc_len = sizeof(ifr_buf);
  ifc.ifc_buf = ifr_buf;
  if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
    fprintf(stderr, "ifdown: ");
    perror("SIOCGIFCONF");
    close(fd);
    return -1;
  }
  ifr_end = ifr_buf + ifc.ifc_len;
  for (shaper = 1; shaper >= 0; shaper--) {
    char *ifr_next = ifr_buf;
    while (ifr_next < ifr_end) {
      struct ifreq *ifr;
      int flags;
      ifr = (struct ifreq *)ifr_next;
      ifr_next += sizeof(struct ifreq);
      if ((strncmp(ifr->ifr_name, "shaper", 6) == 0) != shaper)
        continue;
      if (strncmp(ifr->ifr_name, "lo", 2) == 0)
        continue;
      if (strchr(ifr->ifr_name, ':') != NULL)
        continue;
      if (ioctl(fd, SIOCGIFFLAGS, ifr) < 0) {
        fprintf(stderr, "ifdown: shutdown ");
        perror(ifr->ifr_name);
        continue;
      }
      flags = ifr->ifr_flags;
      if (flags & IFF_UP) {
        flags &= ~(IFF_UP);
        ifr->ifr_flags = flags;
        if (ioctl(fd, SIOCSIFFLAGS, ifr) < 0) {
          fprintf(stderr, "ifdown: shutdown ");
          perror(ifr->ifr_name);
        }
      }
    }
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<ifdown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0x83c(%rbp)
cmp    $0x0,%eax
jge    11d0 <ifdown+0x60>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xe4a(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145c <ifdown+0x2ec>
movl   $0x800,-0x838(%rbp)
lea    -0x810(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x83c(%rbp),%edi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
lea    -0x838(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1245 <ifdown+0xd5>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xde7(%rip),%rdi
call   1080 <perror@plt>
mov    -0x83c(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    145c <ifdown+0x2ec>
lea    -0x810(%rbp),%rax
movslq -0x838(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x818(%rbp)
movl   $0x1,-0x840(%rbp)
cmpl   $0x0,-0x840(%rbp)
jl     144a <ifdown+0x2da>
lea    -0x810(%rbp),%rax
mov    %rax,-0x848(%rbp)
mov    -0x848(%rbp),%rax
cmp    -0x818(%rbp),%rax
jae    1431 <ifdown+0x2c1>
mov    -0x848(%rbp),%rax
mov    %rax,-0x850(%rbp)
mov    -0x848(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x848(%rbp)
mov    -0x850(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd54(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmp    -0x840(%rbp),%eax
je     12ef <ifdown+0x17f>
jmp    1282 <ifdown+0x112>
mov    -0x850(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd22(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    131a <ifdown+0x1aa>
jmp    1282 <ifdown+0x112>
mov    -0x850(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     133e <ifdown+0x1ce>
jmp    1282 <ifdown+0x112>
mov    -0x83c(%rbp),%edi
mov    0x2c7d(%rip),%rax
mov    (%rax),%esi
mov    -0x850(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    138d <ifdown+0x21d>
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
lea    0xcb3(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x850(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <perror@plt>
jmp    1282 <ifdown+0x112>
mov    -0x850(%rbp),%rax
mov    0x18(%rax),%eax
mov    %eax,-0x854(%rbp)
mov    -0x854(%rbp),%eax
mov    0x2c2e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     142c <ifdown+0x2bc>
mov    0x2c1c(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x854(%rbp),%eax
mov    %eax,-0x854(%rbp)
mov    -0x854(%rbp),%ecx
mov    -0x850(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x83c(%rbp),%edi
mov    0x2c0e(%rip),%rax
mov    (%rax),%esi
mov    -0x850(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1427 <ifdown+0x2b7>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
lea    0xc14(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x850(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <perror@plt>
jmp    142c <ifdown+0x2bc>
jmp    1282 <ifdown+0x112>
jmp    1436 <ifdown+0x2c6>
mov    -0x840(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x840(%rbp)
jmp    1267 <ifdown+0xf7>
mov    -0x83c(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ifdown>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
test   %eax,%eax
js     13d1 <ifdown+0x261>
mov    %eax,%r12d
movl   $0x800,0x10(%rsp)
lea    0x30(%rsp),%r15
mov    %r15,0x18(%rsp)
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %r12d,%edi
call   1050 <ioctl@plt>
test   %rax,%rax
js     13f9 <ifdown+0x289>
movslq 0x10(%rsp),%rax
test   %rax,%rax
jle    13b5 <ifdown+0x245>
mov    %rax,0x8(%rsp)
lea    (%rsp,%rax,1),%r14
add    $0x30,%r14
lea    0xe24(%rip),%r13
lea    0xe24(%rip),%rbx
jmp    1229 <ifdown+0xb9>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x10(%rbp),%rdi
call   1080 <perror@plt>
nop
cmp    %r14,%r15
jae    12c5 <ifdown+0x155>
mov    %r15,%rbp
add    $0x20,%r15
mov    0x10(%rbp),%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1220 <ifdown+0xb0>
mov    0x10(%rbp),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1220 <ifdown+0xb0>
mov    0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1220 <ifdown+0xb0>
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %rbp,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
js     1201 <ifdown+0x91>
mov    0x18(%rbp),%eax
mov    0x2d42(%rip),%rcx
mov    (%rcx),%ecx
test   %eax,%ecx
je     1220 <ifdown+0xb0>
not    %ecx
and    %ecx,%eax
mov    %eax,0x18(%rbp)
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %rbp,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
jns    1220 <ifdown+0xb0>
jmp    1201 <ifdown+0x91>
cmpl   $0x0,0x8(%rsp)
jle    13b5 <ifdown+0x245>
lea    0x30(%rsp),%rbx
lea    0xd40(%rip),%r13
lea    0xd40(%rip),%r15
jmp    1319 <ifdown+0x1a9>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x10(%rbp),%rdi
call   1080 <perror@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r14,%rbx
jae    13b5 <ifdown+0x245>
mov    %rbx,%rbp
add    $0x20,%rbx
mov    0x10(%rbp),%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1310 <ifdown+0x1a0>
mov    0x10(%rbp),%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1310 <ifdown+0x1a0>
mov    0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1310 <ifdown+0x1a0>
mov    0x2c62(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %rbp,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
js     12e5 <ifdown+0x175>
mov    0x18(%rbp),%eax
mov    0x2c52(%rip),%rcx
mov    (%rcx),%ecx
test   %eax,%ecx
je     1310 <ifdown+0x1a0>
not    %ecx
and    %ecx,%eax
mov    %eax,0x18(%rbp)
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %rbp,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
jns    1310 <ifdown+0x1a0>
jmp    12e5 <ifdown+0x175>
mov    %r12d,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2be0(%rip),%rax
mov    (%rax),%edi
lea    0xc1f(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xc1c(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%eax
jmp    13bf <ifdown+0x24f>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
lea    0xbf7(%rip),%rsi
call   1070 <fprintf@plt>
lea    0xbfb(%rip),%rdi
call   1080 <perror@plt>
mov    %r12d,%edi
call   1060 <close@plt>
mov    $0xffffffff,%eax
jmp    13bf <ifdown+0x24f>

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

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