#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 */

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ findWiface(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strdup(int /*<<< orphan*/);
char *strtok(char *, char *);
int checkMon(char *mon) {
  char *iface, *token;
  int flag;
  flag = 1;
  if ((iface = strdup(findWiface(0))) == NULL)
    fprintf(stderr, "Error: can't determine network intefaces.\n");
  else {
    token = strtok(iface, " ");
    while (token && flag) {
      if (strcmp(token, mon) == 0)
        flag = 0;
      token = strtok(NULL, " ");
    }
    if (token == NULL && flag) {
      fprintf(stderr,
              "Error: wireless interface \"%s\" not found, no such device.\n",
              mon);
      free(iface);
      return (EXIT_FAILURE);
    }
  }
  free(iface);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<checkMon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
xor    %edi,%edi
call   1040 <findWiface@plt>
mov    %eax,%edi
call   1080 <strdup@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ab <checkMon+0x4b>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    126f <checkMon+0x10f>
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x25(%rbp)
je     11d9 <checkMon+0x79>
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11e9 <checkMon+0x89>
jmp    1220 <checkMon+0xc0>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1207 <checkMon+0xa7>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe19(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    11bf <checkMon+0x5f>
cmpq   $0x0,-0x20(%rbp)
jne    126a <checkMon+0x10a>
cmpl   $0x0,-0x24(%rbp)
je     126a <checkMon+0x10a>
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1284 <checkMon+0x124>
jmp    126f <checkMon+0x10f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkMon>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
xor    %edi,%edi
call   1040 <findWiface@plt>
mov    %eax,%edi
call   1080 <strdup@plt>
mov    %rax,%r14
test   %rax,%rax
je     11f7 <checkMon+0x97>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     11cc <checkMon+0x6c>
lea    0xe8f(%rip),%r15
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11c2 <checkMon+0x62>
test   %rbx,%rbx
jne    11a0 <checkMon+0x40>
test   %rax,%rax
jne    120e <checkMon+0xae>
test   %rbx,%rbx
je     120e <checkMon+0xae>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2de3(%rip),%rax
jmp    121d <checkMon+0xbd>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"Error: can't determine network intefaces.\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [59 x i8] c"Error: wireless interface \22%s\22 not found, no such device.\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @checkMon(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 1, i32* %6
%7 = call i32 @findWiface(i32 0)
%8 = call i8* @strdup(i32 %7)
store i8* %8, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %46
13: ; preds = %1
%14 = load i8*, i8** %4
%15 = call i8* @strtok(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %5
br label %16
16: ; preds = %30, %13
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ false, %16 ], [ %21, %19 ]
br i1 %23, label %24, label %32
24: ; preds = %22
%25 = load i8*, i8** %5
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* %25, i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %6
br label %30
30: ; preds = %29, %24
%31 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %31, i8** %5
br label %16
32: ; preds = %22
%33 = load i8*, i8** %5
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i32, i32* %6
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %3
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = load i8*, i8** %4
%43 = call i32 @free(i8* %42)
%44 = load i32, i32* @EXIT_FAILURE
store i32 %44, i32* %2
br label %50
45: ; preds = %35, %32
br label %46
46: ; preds = %45, %10
%47 = load i8*, i8** %4
%48 = call i32 @free(i8* %47)
%49 = load i32, i32* @EXIT_SUCCESS
store i32 %49, i32* %2
br label %50
50: ; preds = %46, %38
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"Error: can't determine network intefaces.\0A\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [59 x i8] c"Error: wireless interface \22%s\22 not found, no such device.\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @checkMon(i8* %0) {
%2 = tail call i32 @findWiface(i32 0)
%3 = tail call i8* @strdup(i32 %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %25
8: ; preds = %1
%9 = tail call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %8, %11
%12 = phi i8* [ %15, %11 ], [ %9, %8 ]
%13 = tail call i64 @strcmp(i8* %12, i8* %0)
%14 = icmp ne i64 %13, 0
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i8* %15, null
%17 = and i1 %16, %14
br i1 %17, label %11, label %18
18: ; preds = %11
%19 = icmp eq i8* %15, null
%20 = and i1 %19, %14
br i1 %20, label %21, label %25
21: ; preds = %8, %18
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%24 = tail call i32 @free(i8* %3)
br label %27
25: ; preds = %18, %5
%26 = tail call i32 @free(i8* %3)
br label %27
27: ; preds = %25, %21
%28 = phi i32* [ @EXIT_SUCCESS, %25 ], [ @EXIT_FAILURE, %21 ]
%29 = load i32, i32* %28
ret i32 %29
}