#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 */
typedef int /*<<< orphan*/ sysCmd;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int send_rarp_request(char *, char *, char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *);
scalar_t__ strlen(char *);
int scanWiFiAssoc() {
  FILE *p;
  char sysCmd[64];
  char buf[256];
  int i = 0;
  int res = -1;
  snprintf(sysCmd, sizeof(sysCmd), "wl -i eth1 assoclist");
  if ((p = popen(sysCmd, "r")) != NULL) {
    while (fgets(buf, sizeof(buf), p)) {
      if (0 != strlen(buf)) {
        printf("wifi0: assoc:%s\n", buf);
        res = send_rarp_request("192.168.1.1", "C8:D7:19:52:72:54", "0.0.0.0",
                                "00:1B:77:D6:76:60", 1);
        if (!res)
          printf("Resolved ip from %s\n", buf);
      }
    }
    pclose(p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<scanWiFiAssoc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
movl   $0x0,-0x154(%rbp)
movl   $0xffffffff,-0x158(%rbp)
ff ff ff
lea    -0x50(%rbp),%rdi
mov    $0x40,%esi
lea    0xe61(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x50(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1273 <scanWiFiAssoc+0x103>
jmp    11c7 <scanWiFiAssoc+0x57>
lea    -0x150(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     126a <scanWiFiAssoc+0xfa>
lea    -0x150(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1265 <scanWiFiAssoc+0xf5>
lea    -0x150(%rbp),%rsi
lea    0xe09(%rip),%rdi
call   1040 <printf@plt>
lea    0xe0e(%rip),%rdi
lea    0xe13(%rip),%rsi
lea    0xe1e(%rip),%rdx
lea    0xe1f(%rip),%rcx
mov    $0x1,%r8d
call   1070 <send_rarp_request@plt>
mov    %eax,-0x158(%rbp)
cmpl   $0x0,-0x158(%rbp)
jne    1260 <scanWiFiAssoc+0xf0>
lea    -0x150(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
jmp    1265 <scanWiFiAssoc+0xf5>
jmp    11c7 <scanWiFiAssoc+0x57>
mov    -0x8(%rbp),%rdi
call   1050 <pclose@plt>
xor    %eax,%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scanWiFiAssoc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
lea    0xe88(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1050 <snprintf@plt>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1080 <popen@plt>
test   %rax,%rax
je     124f <scanWiFiAssoc+0xef>
mov    %rax,%rbx
lea    0x40(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1247 <scanWiFiAssoc+0xe7>
lea    0x40(%rsp),%r14
lea    0xe5e(%rip),%r12
lea    0xe63(%rip),%r13
lea    0xe6e(%rip),%rbp
lea    0xe6f(%rip),%r15
jmp    1205 <scanWiFiAssoc+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1247 <scanWiFiAssoc+0xe7>
cmpb   $0x0,0x40(%rsp)
je     11f0 <scanWiFiAssoc+0x90>
lea    0xe04(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    $0x1,%r8d
call   1060 <send_rarp_request@plt>
test   %eax,%eax
jne    11f0 <scanWiFiAssoc+0x90>
lea    0xe23(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
jmp    11f0 <scanWiFiAssoc+0x90>
mov    %rbx,%rdi
call   1040 <pclose@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"wl -i eth1 assoclist\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"wifi0: assoc:%s\0A\00"
@.str.3 = [12 x i8] c"192.168.1.1\00"
@.str.4 = [18 x i8] c"C8:D7:19:52:72:54\00"
@.str.5 = [8 x i8] c"0.0.0.0\00"
@.str.6 = [18 x i8] c"00:1B:77:D6:76:60\00"
@.str.7 = [21 x i8] c"Resolved ip from %s\0A\00"
define i32 @scanWiFiAssoc() {
%1 = alloca i32*
%2 = alloca [64 x i8]
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
store i32 -1, i32* %5
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%7 = call i32 @snprintf(i8* %6, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%9 = call i32* @popen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %1
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %35
11: ; preds = %0
br label %12
12: ; preds = %31, %11
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = load i32*, i32** %1
%15 = call i64 @fgets(i8* %13, i32 256, i32* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %32
17: ; preds = %12
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%19 = call i64 @strlen(i8* %18)
%20 = icmp ne i64 0, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @send_rarp_request(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 1)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %21
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%29 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %21
br label %31
31: ; preds = %30, %17
br label %12
32: ; preds = %12
%33 = load i32*, i32** %1
%34 = call i32 @pclose(i32* %33)
br label %35
35: ; preds = %32, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"wl -i eth1 assoclist\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [17 x i8] c"wifi0: assoc:%s\0A\00"
@.str.3 = [12 x i8] c"192.168.1.1\00"
@.str.4 = [18 x i8] c"C8:D7:19:52:72:54\00"
@.str.5 = [8 x i8] c"0.0.0.0\00"
@.str.6 = [18 x i8] c"00:1B:77:D6:76:60\00"
@.str.7 = [21 x i8] c"Resolved ip from %s\0A\00"
define i32 @scanWiFiAssoc() {
%1 = alloca [64 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = call i32 @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %25, label %8
8: ; preds = %0
%9 = call i64 @fgets(i8* %4, i32 256, i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %23, label %11
11: ; preds = %8, %20
%12 = load i8, i8* %4
%13 = icmp eq i8 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%16 = call i32 @send_rarp_request(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 1)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %20
20: ; preds = %14, %18, %11
%21 = call i64 @fgets(i8* %4, i32 256, i32* %6)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %11
23: ; preds = %20, %8
%24 = call i32 @pclose(i32* %6)
br label %25
25: ; preds = %23, %0
ret i32 0
}