#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ mode;
};
struct iwreq {
  int ifr_flags;
  TYPE_1__ u;
  int /*<<< orphan*/ ifr_name;
};
struct ifreq {
  int ifr_flags;
  TYPE_1__ u;
  int /*<<< orphan*/ ifr_name;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int IFF_BROADCAST;
int IFF_MULTICAST;
int IFF_RUNNING;
int IFF_UP;
int /*<<< orphan*/ IW_MODE_MONITOR;
int /*<<< orphan*/ SIOCGIFFLAGS;
int /*<<< orphan*/ SIOCGIWMODE;
int /*<<< orphan*/ SIOCSIFFLAGS;
int /*<<< orphan*/ SIOCSIWMODE;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(struct iwreq *);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct iwreq *);
struct iwreq *malloc(int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int setmonitor(char *intname) {
  int sock;
  struct iwreq *iwr;
  struct ifreq *ifr;
  iwr = malloc(sizeof(struct iwreq));
  if (iwr == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  strncpy(iwr->ifr_name, intname, strlen(intname));
  ifr = malloc(sizeof(struct ifreq));
  if (ifr == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  strncpy(ifr->ifr_name, intname, strlen(intname));
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("can't open socket");
    exit(1);
  }
  if (ioctl(sock, SIOCGIWMODE, iwr) < 0) {
    close(sock);
    free(iwr);
    perror("can't read mode");
    exit(1);
  }
  iwr->u.mode = IW_MODE_MONITOR;
  if (ioctl(sock, SIOCSIWMODE, iwr) < 0) {
    close(sock);
    free(iwr);
    perror("can't read mode");
    exit(1);
  }
  if (ioctl(sock, SIOCGIFFLAGS, ifr) < 0) {
    close(sock);
    free(ifr);
    perror("can't read interface state");
    exit(1);
  }
  ifr->ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_MULTICAST;
  if (ioctl(sock, SIOCSIFFLAGS, ifr) < 0) {
    close(sock);
    free(ifr);
    perror("can't read interface state");
    exit(1);
  }
  free(iwr);
  free(ifr);
  close(sock);
  return (0);
}


x86 assembly (clang, -O0):
<setmonitor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xc,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cb <setmonitor+0x3b>
lea    0xe44(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    $0xc,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1223 <setmonitor+0x93>
lea    0xdec(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    1287 <setmonitor+0xf7>
lea    0xd9e(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0xc(%rbp),%edi
mov    0x2d07(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    12cd <setmonitor+0x13d>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xd6a(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2d0c(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%edi
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1323 <setmonitor+0x193>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xd14(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0xc(%rbp),%edi
mov    0x2c83(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    1369 <setmonitor+0x1d9>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xcde(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2c50(%rip),%rax
mov    (%rax),%ecx
mov    0x2c27(%rip),%rax
or     (%rax),%ecx
mov    0x2c46(%rip),%rax
or     (%rax),%ecx
mov    0x2c45(%rip),%rax
or     (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%edi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
call   1060 <ioctl@plt>
cmp    $0x0,%rax
jge    13d9 <setmonitor+0x249>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xc6e(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setmonitor>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    $0xc,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     12db <setmonitor+0x14b>
mov    %rax,%r14
mov    0x8(%rax),%ebx
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    $0xc,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     12db <setmonitor+0x14b>
mov    %rax,%r15
mov    0x8(%rax),%ebx
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     1314 <setmonitor+0x184>
mov    %eax,%ebp
mov    0x2d7a(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     12e4 <setmonitor+0x154>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%r14)
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r14,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     12e4 <setmonitor+0x154>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r15,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     12fc <setmonitor+0x16c>
mov    0x2d41(%rip),%rax
mov    0x2d1a(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d37(%rip),%rax
or     (%rax),%ecx
mov    0x2d36(%rip),%rax
or     (%rax),%ecx
mov    %ecx,(%r15)
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
mov    %r15,%rdx
call   1060 <ioctl@plt>
test   %rax,%rax
js     12fc <setmonitor+0x16c>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1e(%rip),%rdi
jmp    131b <setmonitor+0x18b>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xd2e(%rip),%rdi
jmp    131b <setmonitor+0x18b>
mov    %ebp,%edi
call   1070 <close@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0xd26(%rip),%rdi
jmp    131b <setmonitor+0x18b>
lea    0xcfb(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.iwreq = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.ifreq = type { i32, %struct.TYPE_2__, i32 }
@.str = [22 x i8] c"can't allocate memory\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [18 x i8] c"can't open socket\00"
@SIOCGIWMODE = global i32 0
@.str.2 = [16 x i8] c"can't read mode\00"
@IW_MODE_MONITOR = global i32 0
@SIOCSIWMODE = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.3 = [27 x i8] c"can't read interface state\00"
@IFF_UP = global i32 0
@IFF_BROADCAST = global i32 0
@IFF_RUNNING = global i32 0
@IFF_MULTICAST = global i32 0
@SIOCSIFFLAGS = global i32 0
define i32 @setmonitor(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca %struct.iwreq*
%5 = alloca %struct.ifreq*
store i8* %0, i8** %2
%6 = call %struct.iwreq* @malloc(i32 12)
store %struct.iwreq* %6, %struct.iwreq** %4
%7 = load %struct.iwreq*, %struct.iwreq** %4
%8 = icmp eq %struct.iwreq* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = load %struct.iwreq*, %struct.iwreq** %4
%14 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %13, i32 0, i32 2
%15 = load i32, i32* %14
%16 = load i8*, i8** %2
%17 = load i8*, i8** %2
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @strncpy(i32 %15, i8* %16, i32 %18)
%20 = call %struct.iwreq* @malloc(i32 12)
%21 = bitcast %struct.iwreq* %20 to %struct.ifreq*
store %struct.ifreq* %21, %struct.ifreq** %5
%22 = load %struct.ifreq*, %struct.ifreq** %5
%23 = icmp eq %struct.ifreq* %22, null
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %12
%28 = load %struct.ifreq*, %struct.ifreq** %5
%29 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %28, i32 0, i32 2
%30 = load i32, i32* %29
%31 = load i8*, i8** %2
%32 = load i8*, i8** %2
%33 = call i32 @strlen(i8* %32)
%34 = call i32 @strncpy(i32 %30, i8* %31, i32 %33)
%35 = load i32, i32* @AF_INET
%36 = load i32, i32* @SOCK_DGRAM
%37 = call i32 @socket(i32 %35, i32 %36, i32 0)
store i32 %37, i32* %3
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %27
%40 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %27
%43 = load i32, i32* %3
%44 = load i32, i32* @SIOCGIWMODE
%45 = load %struct.iwreq*, %struct.iwreq** %4
%46 = call i64 @ioctl(i32 %43, i32 %44, %struct.iwreq* %45)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %42
%49 = load i32, i32* %3
%50 = call i32 @close(i32 %49)
%51 = load %struct.iwreq*, %struct.iwreq** %4
%52 = call i32 @free(%struct.iwreq* %51)
%53 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %42
%56 = load i32, i32* @IW_MODE_MONITOR
%57 = load %struct.iwreq*, %struct.iwreq** %4
%58 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %57, i32 0, i32 1
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
store i32 %56, i32* %59
%60 = load i32, i32* %3
%61 = load i32, i32* @SIOCSIWMODE
%62 = load %struct.iwreq*, %struct.iwreq** %4
%63 = call i64 @ioctl(i32 %60, i32 %61, %struct.iwreq* %62)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %72
65: ; preds = %55
%66 = load i32, i32* %3
%67 = call i32 @close(i32 %66)
%68 = load %struct.iwreq*, %struct.iwreq** %4
%69 = call i32 @free(%struct.iwreq* %68)
%70 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %55
%73 = load i32, i32* %3
%74 = load i32, i32* @SIOCGIFFLAGS
%75 = load %struct.ifreq*, %struct.ifreq** %5
%76 = bitcast %struct.ifreq* %75 to %struct.iwreq*
%77 = call i64 @ioctl(i32 %73, i32 %74, %struct.iwreq* %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %87
79: ; preds = %72
%80 = load i32, i32* %3
%81 = call i32 @close(i32 %80)
%82 = load %struct.ifreq*, %struct.ifreq** %5
%83 = bitcast %struct.ifreq* %82 to %struct.iwreq*
%84 = call i32 @free(%struct.iwreq* %83)
%85 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %72
%88 = load i32, i32* @IFF_UP
%89 = load i32, i32* @IFF_BROADCAST
%90 = or i32 %88, %89
%91 = load i32, i32* @IFF_RUNNING
%92 = or i32 %90, %91
%93 = load i32, i32* @IFF_MULTICAST
%94 = or i32 %92, %93
%95 = load %struct.ifreq*, %struct.ifreq** %5
%96 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %95, i32 0, i32 0
store i32 %94, i32* %96
%97 = load i32, i32* %3
%98 = load i32, i32* @SIOCSIFFLAGS
%99 = load %struct.ifreq*, %struct.ifreq** %5
%100 = bitcast %struct.ifreq* %99 to %struct.iwreq*
%101 = call i64 @ioctl(i32 %97, i32 %98, %struct.iwreq* %100)
%102 = icmp slt i64 %101, 0
br i1 %102, label %103, label %111
103: ; preds = %87
%104 = load i32, i32* %3
%105 = call i32 @close(i32 %104)
%106 = load %struct.ifreq*, %struct.ifreq** %5
%107 = bitcast %struct.ifreq* %106 to %struct.iwreq*
%108 = call i32 @free(%struct.iwreq* %107)
%109 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %87
%112 = load %struct.iwreq*, %struct.iwreq** %4
%113 = call i32 @free(%struct.iwreq* %112)
%114 = load %struct.ifreq*, %struct.ifreq** %5
%115 = bitcast %struct.ifreq* %114 to %struct.iwreq*
%116 = call i32 @free(%struct.iwreq* %115)
%117 = load i32, i32* %3
%118 = call i32 @close(i32 %117)
ret i32 0
}

LLVM IR (-O2):
%struct.iwreq = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@.str = [22 x i8] c"can't allocate memory\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [18 x i8] c"can't open socket\00"
@SIOCGIWMODE = global i32 0
@.str.2 = [16 x i8] c"can't read mode\00"
@IW_MODE_MONITOR = global i32 0
@SIOCSIWMODE = global i32 0
@SIOCGIFFLAGS = global i32 0
@.str.3 = [27 x i8] c"can't read interface state\00"
@IFF_UP = global i32 0
@IFF_BROADCAST = global i32 0
@IFF_RUNNING = global i32 0
@IFF_MULTICAST = global i32 0
@SIOCSIFFLAGS = global i32 0
define i32 @setmonitor(i8* %0) {
%2 = tail call %struct.iwreq* @malloc(i32 12)
%3 = icmp eq %struct.iwreq* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %2, i64 0, i32 2
%9 = load i32, i32* %8
%10 = tail call i32 @strlen(i8* %0)
%11 = tail call i32 @strncpy(i32 %9, i8* %0, i32 %10)
%12 = tail call %struct.iwreq* @malloc(i32 12)
%13 = icmp eq %struct.iwreq* %12, null
br i1 %13, label %14, label %17
14: ; preds = %7
%15 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %7
%18 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %12, i64 0, i32 2
%19 = load i32, i32* %18
%20 = tail call i32 @strlen(i8* %0)
%21 = tail call i32 @strncpy(i32 %19, i8* %0, i32 %20)
%22 = load i32, i32* @AF_INET
%23 = load i32, i32* @SOCK_DGRAM
%24 = tail call i32 @socket(i32 %22, i32 %23, i32 0)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %17
%27 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %17
%30 = load i32, i32* @SIOCGIWMODE
%31 = tail call i64 @ioctl(i32 %24, i32 %30, %struct.iwreq* %2)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = tail call i32 @close(i32 %24)
%35 = tail call i32 @free(%struct.iwreq* %2)
%36 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i32, i32* @IW_MODE_MONITOR
%40 = getelementptr inbounds %struct.iwreq, %struct.iwreq* %2, i64 0, i32 1, i32 0
store i32 %39, i32* %40
%41 = load i32, i32* @SIOCSIWMODE
%42 = tail call i64 @ioctl(i32 %24, i32 %41, %struct.iwreq* %2)
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %38
%45 = tail call i32 @close(i32 %24)
%46 = tail call i32 @free(%struct.iwreq* %2)
%47 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %38
%50 = load i32, i32* @SIOCGIFFLAGS
%51 = tail call i64 @ioctl(i32 %24, i32 %50, %struct.iwreq* %12)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = tail call i32 @close(i32 %24)
%55 = tail call i32 @free(%struct.iwreq* %12)
%56 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%57 = tail call i32 @exit(i32 1)
unreachable
58: ; preds = %49
%59 = load i32, i32* @IFF_UP
%60 = load i32, i32* @IFF_BROADCAST
%61 = or i32 %60, %59
%62 = load i32, i32* @IFF_RUNNING
%63 = or i32 %61, %62
%64 = load i32, i32* @IFF_MULTICAST
%65 = or i32 %63, %64
%66 = getelementptr %struct.iwreq, %struct.iwreq* %12, i64 0, i32 0
store i32 %65, i32* %66
%67 = load i32, i32* @SIOCSIFFLAGS
%68 = tail call i64 @ioctl(i32 %24, i32 %67, %struct.iwreq* %12)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %58
%71 = tail call i32 @close(i32 %24)
%72 = tail call i32 @free(%struct.iwreq* %12)
%73 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%74 = tail call i32 @exit(i32 1)
unreachable
75: ; preds = %58
%76 = tail call i32 @free(%struct.iwreq* %2)
%77 = tail call i32 @free(%struct.iwreq* %12)
%78 = tail call i32 @close(i32 %24)
ret i32 0
}