#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 ifr_flags;
  int /*<<< orphan*/ ifr_name;
};
typedef int /*<<< orphan*/ req;

/* Variables and functions */
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ AF_NETLINK;
int IFF_RUNNING;
int IFF_UP;
int /*<<< orphan*/ NETLINK_ROUTE;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ ifup_read_event(int, int *);
int /*<<< orphan*/ ifup_start_listening(int);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ memset(struct ifreq *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int ifup(void) {
  int inet6_fd;
  int netlink_fd;
  struct ifreq req;
  int seen_flags = 0;
  inet6_fd = socket(AF_INET6, SOCK_DGRAM, 0);
  if (inet6_fd < 0) {
    perror("socket");
    return 0;
  }
  netlink_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
  if (netlink_fd < 0) {
    perror("socket");
    close(inet6_fd);
    return 0;
  }
  if (!ifup_start_listening(netlink_fd)) {
    close(netlink_fd);
    close(inet6_fd);
    return 0;
  }
  memset(&req, 0, sizeof(req));
  strcpy(req.ifr_name, "eth0");
  if (ioctl(inet6_fd, SIOCGIFFLAGS, &req) < 0) {
    perror("ioctl");
    close(netlink_fd);
    close(inet6_fd);
    return 0;
  }
  if (!(req.ifr_flags & IFF_UP)) {
    req.ifr_flags |= IFF_UP;
    if (ioctl(inet6_fd, SIOCSIFFLAGS, &req) < 0) {
      perror("ioctl");
      close(netlink_fd);
      close(inet6_fd);
      return 0;
    }
  }
  if (!(req.ifr_flags & IFF_RUNNING)) {
    fputs("netkeyscript: waiting for eth0 to be running with an address "
          "assigned\n",
          stderr);
    while ((seen_flags & (1 | 2)) != (1 | 2)) {
      if (!ifup_read_event(netlink_fd, &seen_flags)) {
        close(netlink_fd);
        close(inet6_fd);
        return 0;
      }
    }
    if (ioctl(inet6_fd, SIOCGIFFLAGS, &req) < 0) {
      perror("ioctl");
      close(netlink_fd);
      close(inet6_fd);
      return 0;
    }
    if (!(req.ifr_flags & IFF_RUNNING)) {
      fputs("netkeyscript: eth0 still not running but continuing "
            "anyway\n",
            stderr);
    }
  }
  close(netlink_fd);
  close(inet6_fd);
  return 1;
}


x86 assembly (clang, -O0):
<ifup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x1c(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11dd <ifup+0x4d>
lea    0xe34(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
mov    0x2d9a(%rip),%rax
mov    (%rax),%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    122a <ifup+0x9a>
lea    0xdef(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
mov    -0xc(%rbp),%edi
call   1090 <ifup_start_listening@plt>
cmp    $0x0,%eax
jne    1257 <ifup+0xc7>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%edi
lea    0xd96(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%edi
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12bd <ifup+0x12d>
lea    0xd70(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
mov    -0x18(%rbp),%eax
mov    0x2d09(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    132d <ifup+0x19d>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1328 <ifup+0x198>
lea    0xd05(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
jmp    132d <ifup+0x19d>
mov    -0x18(%rbp),%eax
mov    0x2ca1(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1412 <ifup+0x282>
mov    0x2c57(%rip),%rax
mov    (%rax),%esi
lea    0xcc0(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x1c(%rbp),%eax
and    $0x3,%eax
cmp    $0x3,%eax
je     139c <ifup+0x20c>
mov    -0xc(%rbp),%edi
lea    -0x1c(%rbp),%rsi
call   1080 <ifup_read_event@plt>
cmp    $0x0,%eax
jne    1397 <ifup+0x207>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
jmp    1357 <ifup+0x1c7>
mov    -0x8(%rbp),%edi
mov    0x2c12(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    13e3 <ifup+0x253>
lea    0xc4a(%rip),%rdi
call   10a0 <perror@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1429 <ifup+0x299>
mov    -0x18(%rbp),%eax
mov    0x2beb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    140d <ifup+0x27d>
mov    0x2ba1(%rip),%rax
mov    (%rax),%esi
lea    0xc51(%rip),%rdi
call   1040 <fputs@plt>
jmp    1412 <ifup+0x282>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ifup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x14(%rsp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
xor    %edx,%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     1320 <ifup+0x190>
mov    %eax,%r14d
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     132e <ifup+0x19e>
mov    %eax,%ebp
mov    %eax,%edi
call   1090 <ifup_start_listening@plt>
test   %eax,%eax
je     1365 <ifup+0x1d5>
lea    0x8(%rsp),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    0xc(%rsp),%edi
lea    0xde1(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2d86(%rip),%r12
mov    (%r12),%esi
mov    %r14d,%edi
mov    %r15,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     133c <ifup+0x1ac>
mov    0x8(%rsp),%eax
mov    0x2d7b(%rip),%rcx
mov    (%rcx),%ecx
test   %eax,%ecx
jne    1284 <ifup+0xf4>
or     %eax,%ecx
mov    %ecx,0x8(%rsp)
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   1060 <ioctl@plt>
test   %rax,%rax
js     1359 <ifup+0x1c9>
mov    0x8(%rsp),%eax
mov    0x2d4d(%rip),%r15
test   %eax,(%r15)
je     12a9 <ifup+0x119>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    $0x1,%ebx
jmp    1376 <ifup+0x1e6>
mov    0x2cf0(%rip),%r13
mov    0x0(%r13),%esi
lea    0xd57(%rip),%rdi
call   1040 <fputs@plt>
lea    0x14(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
call   1080 <ifup_read_event@plt>
test   %eax,%eax
je     1365 <ifup+0x1d5>
mov    0x14(%rsp),%eax
not    %eax
test   $0x3,%al
jne    12d0 <ifup+0x140>
mov    (%r12),%esi
lea    0x8(%rsp),%rdx
mov    %r14d,%edi
call   1060 <ioctl@plt>
test   %rax,%rax
js     1359 <ifup+0x1c9>
mov    (%r15),%eax
test   %eax,0x8(%rsp)
jne    1290 <ifup+0x100>
mov    0x0(%r13),%esi
lea    0xd43(%rip),%rdi
call   1040 <fputs@plt>
jmp    1290 <ifup+0x100>
lea    0xcd9(%rip),%rdi
call   10a0 <perror@plt>
jmp    1376 <ifup+0x1e6>
lea    0xccb(%rip),%rdi
call   10a0 <perror@plt>
jmp    136c <ifup+0x1dc>
lea    0xcc9(%rip),%rdi
call   10a0 <perror@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r14d,%edi
call   1070 <close@plt>
jmp    1376 <ifup+0x1e6>
lea    0xcac(%rip),%rdi
call   10a0 <perror@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r14d,%edi
call   1070 <close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ifreq = type { i32, i32 }
@AF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [7 x i8] c"socket\00"
@AF_NETLINK = global i32 0
@SOCK_RAW = global i32 0
@NETLINK_ROUTE = global i32 0
@.str.1 = [5 x i8] c"eth0\00"
@SIOCGIFFLAGS = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
@IFF_RUNNING = global i32 0
@.str.3 = [71 x i8] c"netkeyscript: waiting for eth0 to be running with an address assigned\0A\00"
@stderr = global i32 0
@.str.4 = [60 x i8] c"netkeyscript: eth0 still not running but continuing anyway\0A\00"
define i32 @ifup() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.ifreq
%5 = alloca i32
store i32 0, i32* %5
%6 = load i32, i32* @AF_INET6
%7 = load i32, i32* @SOCK_DGRAM
%8 = call i32 @socket(i32 %6, i32 %7, i32 0)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %119
13: ; preds = %0
%14 = load i32, i32* @AF_NETLINK
%15 = load i32, i32* @SOCK_RAW
%16 = load i32, i32* @NETLINK_ROUTE
%17 = call i32 @socket(i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
store i32 0, i32* %1
br label %119
24: ; preds = %13
%25 = load i32, i32* %3
%26 = call i32 @ifup_start_listening(i32 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %24
%29 = load i32, i32* %3
%30 = call i32 @close(i32 %29)
%31 = load i32, i32* %2
%32 = call i32 @close(i32 %31)
store i32 0, i32* %1
br label %119
33: ; preds = %24
%34 = call i32 @memset(%struct.ifreq* %4, i32 0, i32 8)
%35 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 1
%36 = load i32, i32* %35
%37 = call i32 @strcpy(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* %2
%39 = load i32, i32* @SIOCGIFFLAGS
%40 = call i64 @ioctl(i32 %38, i32 %39, %struct.ifreq* %4)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %33
%43 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %3
%45 = call i32 @close(i32 %44)
%46 = load i32, i32* %2
%47 = call i32 @close(i32 %46)
store i32 0, i32* %1
br label %119
48: ; preds = %33
%49 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%50 = load i32, i32* %49
%51 = load i32, i32* @IFF_UP
%52 = and i32 %50, %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %70, label %54
54: ; preds = %48
%55 = load i32, i32* @IFF_UP
%56 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%57 = load i32, i32* %56
%58 = or i32 %57, %55
store i32 %58, i32* %56
%59 = load i32, i32* %2
%60 = load i32, i32* @SIOCSIFFLAGS
%61 = call i64 @ioctl(i32 %59, i32 %60, %struct.ifreq* %4)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %69
63: ; preds = %54
%64 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%65 = load i32, i32* %3
%66 = call i32 @close(i32 %65)
%67 = load i32, i32* %2
%68 = call i32 @close(i32 %67)
store i32 0, i32* %1
br label %119
69: ; preds = %54
br label %70
70: ; preds = %69, %48
%71 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%72 = load i32, i32* %71
%73 = load i32, i32* @IFF_RUNNING
%74 = and i32 %72, %73
%75 = icmp ne i32 %74, 0
br i1 %75, label %114, label %76
76: ; preds = %70
%77 = load i32, i32* @stderr
%78 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %92, %76
%80 = load i32, i32* %5
%81 = and i32 %80, 3
%82 = icmp ne i32 %81, 3
br i1 %82, label %83, label %93
83: ; preds = %79
%84 = load i32, i32* %3
%85 = call i32 @ifup_read_event(i32 %84, i32* %5)
%86 = icmp ne i32 %85, 0
br i1 %86, label %92, label %87
87: ; preds = %83
%88 = load i32, i32* %3
%89 = call i32 @close(i32 %88)
%90 = load i32, i32* %2
%91 = call i32 @close(i32 %90)
store i32 0, i32* %1
br label %119
92: ; preds = %83
br label %79
93: ; preds = %79
%94 = load i32, i32* %2
%95 = load i32, i32* @SIOCGIFFLAGS
%96 = call i64 @ioctl(i32 %94, i32 %95, %struct.ifreq* %4)
%97 = icmp slt i64 %96, 0
br i1 %97, label %98, label %104
98: ; preds = %93
%99 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%100 = load i32, i32* %3
%101 = call i32 @close(i32 %100)
%102 = load i32, i32* %2
%103 = call i32 @close(i32 %102)
store i32 0, i32* %1
br label %119
104: ; preds = %93
%105 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %4, i32 0, i32 0
%106 = load i32, i32* %105
%107 = load i32, i32* @IFF_RUNNING
%108 = and i32 %106, %107
%109 = icmp ne i32 %108, 0
br i1 %109, label %113, label %110
110: ; preds = %104
%111 = load i32, i32* @stderr
%112 = call i32 @fputs(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %110, %104
br label %114
114: ; preds = %113, %70
%115 = load i32, i32* %3
%116 = call i32 @close(i32 %115)
%117 = load i32, i32* %2
%118 = call i32 @close(i32 %117)
store i32 1, i32* %1
br label %119
119: ; preds = %114, %98, %87, %63, %42, %28, %20, %11
%120 = load i32, i32* %1
ret i32 %120
}

LLVM IR (-O2):
%struct.ifreq = type { i32, i32 }
@AF_INET6 = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [7 x i8] c"socket\00"
@AF_NETLINK = global i32 0
@SOCK_RAW = global i32 0
@NETLINK_ROUTE = global i32 0
@.str.1 = [5 x i8] c"eth0\00"
@SIOCGIFFLAGS = global i32 0
@.str.2 = [6 x i8] c"ioctl\00"
@IFF_UP = global i32 0
@SIOCSIFFLAGS = global i32 0
@IFF_RUNNING = global i32 0
@.str.3 = [71 x i8] c"netkeyscript: waiting for eth0 to be running with an address assigned\0A\00"
@stderr = global i32 0
@.str.4 = [60 x i8] c"netkeyscript: eth0 still not running but continuing anyway\0A\00"
define i32 @ifup() {
%1 = alloca %struct.ifreq
%2 = alloca i32
%3 = bitcast %struct.ifreq* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = load i32, i32* @AF_INET6
%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 %11
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %92
11: ; preds = %0
%12 = load i32, i32* @AF_NETLINK
%13 = load i32, i32* @SOCK_RAW
%14 = load i32, i32* @NETLINK_ROUTE
%15 = tail call i32 @socket(i32 %12, i32 %13, i32 %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @close(i32 %7)
br label %92
20: ; preds = %11
%21 = tail call i32 @ifup_start_listening(i32 %15)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = tail call i32 @close(i32 %15)
%25 = tail call i32 @close(i32 %7)
br label %92
26: ; preds = %20
%27 = call i32 @memset(%struct.ifreq* %1, i32 0, i32 8)
%28 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %1, i64 0, i32 1
%29 = load i32, i32* %28
%30 = call i32 @strcpy(i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* @SIOCGIFFLAGS
%32 = call i64 @ioctl(i32 %7, i32 %31, %struct.ifreq* %1)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @close(i32 %15)
%37 = call i32 @close(i32 %7)
br label %92
38: ; preds = %26
%39 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %1, i64 0, i32 0
%40 = load i32, i32* %39
%41 = load i32, i32* @IFF_UP
%42 = and i32 %41, %40
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %55
44: ; preds = %38
%45 = or i32 %41, %40
store i32 %45, i32* %39
%46 = load i32, i32* @SIOCSIFFLAGS
%47 = call i64 @ioctl(i32 %7, i32 %46, %struct.ifreq* %1)
%48 = icmp slt i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %44
%50 = load i32, i32* %39
br label %55
51: ; preds = %44
%52 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%53 = call i32 @close(i32 %15)
%54 = call i32 @close(i32 %7)
br label %92
55: ; preds = %49, %38
%56 = phi i32 [ %50, %49 ], [ %40, %38 ]
%57 = load i32, i32* @IFF_RUNNING
%58 = and i32 %57, %56
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %89
60: ; preds = %55
%61 = load i32, i32* @stderr
%62 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %63
63: ; preds = %60, %66
%64 = call i32 @ifup_read_event(i32 %15, i32* %2)
%65 = icmp eq i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %63
%67 = load i32, i32* %2
%68 = and i32 %67, 3
%69 = icmp eq i32 %68, 3
br i1 %69, label %73, label %63
70: ; preds = %63
%71 = call i32 @close(i32 %15)
%72 = call i32 @close(i32 %7)
br label %92
73: ; preds = %66
%74 = load i32, i32* @SIOCGIFFLAGS
%75 = call i64 @ioctl(i32 %7, i32 %74, %struct.ifreq* %1)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %81
77: ; preds = %73
%78 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%79 = call i32 @close(i32 %15)
%80 = call i32 @close(i32 %7)
br label %92
81: ; preds = %73
%82 = load i32, i32* %39
%83 = load i32, i32* @IFF_RUNNING
%84 = and i32 %83, %82
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %81
%87 = load i32, i32* @stderr
%88 = call i32 @fputs(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %87)
br label %89
89: ; preds = %81, %86, %55
%90 = call i32 @close(i32 %15)
%91 = call i32 @close(i32 %7)
br label %92
92: ; preds = %89, %77, %70, %51, %34, %23, %17, %9
%93 = phi i32 [ 0, %9 ], [ 0, %17 ], [ 0, %34 ], [ 1, %89 ], [ 0, %70 ], [ 0, %77 ], [ 0, %51 ], [ 0, %23 ]
ret i32 %93
}