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

/* Variables and functions */
int checkWlanCli(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ getDevTypeByMac(char *, char *);
int /*<<< orphan*/ memcpy(char *, char *, scalar_t__);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int main() {
  FILE *fp;
  int i = 0, ret = 0;
  char hostname[128] = {0}, tmpbuf[128] = {0};
  char mac_str[32] = {0};
  char ip_str[32] = {0}, leaseime_str[32] = {0};
  char typenamebuf[32] = {0}, devtype[32] = {0};
  while (1) {
    fp = fopen("/tmp/dhcp.leases", "r");
    if (NULL == fp) {
      sleep(30);
      continue;
    }
    while (!feof(fp) && (4 == fscanf(fp, " %10s %17s %s %s %*s", leaseime_str,
                                     mac_str, ip_str, hostname))) {
      getDevTypeByMac(mac_str, typenamebuf);
      memcpy(devtype, typenamebuf, strlen(typenamebuf) - 1);
      ret = checkWlanCli(mac_str);
      if (-1 == ret) {
        sleep(30);
        fclose(fp);
        break;
      } else if (0 == ret) {
        continue;
      }
      memset(tmpbuf, 0, sizeof(tmpbuf));
      sprintf(tmpbuf, "echo %s %s %s %s >> /tmp/wlanClientList", hostname,
              mac_str, devtype, leaseime_str);
      system(tmpbuf);
    }
    fclose(fp);
    sleep(57);
    system("rm -fr /tmp/wlanClientList");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    -0x180(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
lea    0xd94(%rip),%rdi
lea    0xd9e(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1297 <main+0xd7>
mov    $0x1e,%edi
call   10e0 <sleep@plt>
jmp    1265 <main+0xa5>
jmp    129c <main+0xdc>
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1c1(%rbp)
jne    12f6 <main+0x136>
mov    -0x10(%rbp),%rdi
lea    -0x180(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    -0x160(%rbp),%r8
lea    -0xa0(%rbp),%r9
lea    0xd34(%rip),%rsi
call   1080 <fscanf@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1c1(%rbp)
mov    -0x1c1(%rbp),%al
test   $0x1,%al
jne    1309 <main+0x149>
jmp    13fb <main+0x23b>
lea    -0x140(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   10c0 <getDevTypeByMac@plt>
lea    -0x1c0(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1d8(%rbp),%rdi
mov    -0x1d0(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   10a0 <memcpy@plt>
lea    -0x140(%rbp),%rdi
call   1060 <checkWlanCli@plt>
mov    %eax,-0x18(%rbp)
mov    $0xffffffff,%eax
cmp    -0x18(%rbp),%eax
jne    1393 <main+0x1d3>
mov    $0x1e,%edi
call   10e0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    13fb <main+0x23b>
xor    %eax,%eax
cmp    -0x18(%rbp),%eax
jne    13a3 <main+0x1e3>
jmp    129c <main+0xdc>
jmp    13a8 <main+0x1e8>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x120(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    -0x1c0(%rbp),%r8
lea    -0x180(%rbp),%r9
lea    0xc43(%rip),%rsi
call   10d0 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1050 <system@plt>
jmp    129c <main+0xdc>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x39,%edi
call   10e0 <sleep@plt>
lea    0xc3b(%rip),%rdi
call   1050 <system@plt>
jmp    1265 <main+0xa5>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x80(%rsp),%rbx
lea    0x120(%rsp),%r14
lea    0x40(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0xa0(%rsp),%rbp
jmp    12ee <main+0x12e>
mov    $0x1e,%edi
call   10e0 <sleep@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    $0x39,%edi
call   10e0 <sleep@plt>
lea    0xd67(%rip),%rdi
call   1050 <system@plt>
lea    0xd0b(%rip),%rdi
lea    0xd15(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13b0 <main+0x1f0>
mov    %rax,%r13
nopl   (%rax)
mov    %r13,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    12d0 <main+0x110>
mov    %r13,%rdi
lea    0xced(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rcx
lea    0x60(%rsp),%r8
mov    %r14,%r9
call   1080 <fscanf@plt>
cmp    $0x4,%eax
jne    12d0 <main+0x110>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10c0 <getDevTypeByMac@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   10a0 <memcpy@plt>
mov    %rbx,%rdi
call   1060 <checkWlanCli@plt>
test   %eax,%eax
je     1310 <main+0x150>
cmp    $0xffffffff,%eax
je     12af <main+0xef>
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
mov    %rbp,%rdi
lea    0xc9a(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r12,%r8
mov    %rsp,%r9
call   10d0 <sprintf@plt>
mov    %rbp,%rdi
call   1050 <system@plt>
jmp    1310 <main+0x150>
nopl   0x0(%rax)
mov    $0x1e,%edi
call   10e0 <sleep@plt>
jmp    12ee <main+0x12e>

LLVM IR (-O0):
@.str = [17 x i8] c"/tmp/dhcp.leases\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c" %10s %17s %s %s %*s\00"
@.str.3 = [40 x i8] c"echo %s %s %s %s >> /tmp/wlanClientList\00"
@.str.4 = [27 x i8] c"rm -fr /tmp/wlanClientList\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca [32 x i8]
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = alloca [32 x i8]
%11 = alloca [32 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%12 = bitcast [128 x i8]* %5 to i8*
%13 = bitcast [128 x i8]* %6 to i8*
%14 = bitcast [32 x i8]* %7 to i8*
%15 = bitcast [32 x i8]* %8 to i8*
%16 = bitcast [32 x i8]* %9 to i8*
%17 = bitcast [32 x i8]* %10 to i8*
%18 = bitcast [32 x i8]* %11 to i8*
br label %19
19: ; preds = %0, %23, %74
%20 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %2
%21 = load i32*, i32** %2
%22 = icmp eq i32* null, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @sleep(i32 30)
br label %19
25: ; preds = %19
br label %26
26: ; preds = %63, %61, %25
%27 = load i32*, i32** %2
%28 = call i32 @feof(i32* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %38, label %30
30: ; preds = %26
%31 = load i32*, i32** %2
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%33 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%36 = call i32 @fscanf(i32* %31, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %33, i8* %34, i8* %35)
%37 = icmp eq i32 4, %36
br label %38
38: ; preds = %30, %26
%39 = phi i1 [ false, %26 ], [ %37, %30 ]
br i1 %39, label %40, label %74
40: ; preds = %38
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%43 = call i32 @getDevTypeByMac(i8* %41, i8* %42)
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%45 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%46 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%47 = call i64 @strlen(i8* %46)
%48 = sub nsw i64 %47, 1
%49 = call i32 @memcpy(i8* %44, i8* %45, i64 %48)
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%51 = call i32 @checkWlanCli(i8* %50)
store i32 %51, i32* %4
%52 = load i32, i32* %4
%53 = icmp eq i32 -1, %52
br i1 %53, label %54, label %58
54: ; preds = %40
%55 = call i32 @sleep(i32 30)
%56 = load i32*, i32** %2
%57 = call i32 @fclose(i32* %56)
br label %74
58: ; preds = %40
%59 = load i32, i32* %4
%60 = icmp eq i32 0, %59
br i1 %60, label %61, label %62
61: ; preds = %58
br label %26
62: ; preds = %58
br label %63
63: ; preds = %62
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%65 = call i32 @memset(i8* %64, i32 0, i32 128)
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%68 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%69 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%70 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%71 = call i32 @sprintf(i8* %66, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %68, i8* %69, i8* %70)
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%73 = call i32 @system(i8* %72)
br label %26
74: ; preds = %54, %38
%75 = load i32*, i32** %2
%76 = call i32 @fclose(i32* %75)
%77 = call i32 @sleep(i32 57)
%78 = call i32 @system(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %19
}

LLVM IR (-O2):
@.str = [17 x i8] c"/tmp/dhcp.leases\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c" %10s %17s %s %s %*s\00"
@.str.3 = [40 x i8] c"echo %s %s %s %s >> /tmp/wlanClientList\00"
@.str.4 = [27 x i8] c"rm -fr /tmp/wlanClientList\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
br label %15
15: ; preds = %23, %0
%16 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32 @feof(i32* %16)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %43
21: ; preds = %15
%22 = call i32 @sleep(i32 30)
br label %23
23: ; preds = %21, %43
br label %15
24: ; preds = %18, %40
%25 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %10, i8* %11, i8* %8)
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %43
27: ; preds = %24
%28 = call i32 @getDevTypeByMac(i8* %10, i8* %13)
%29 = call i64 @strlen(i8* %13)
%30 = add nsw i64 %29, -1
%31 = call i32 @memcpy(i8* %14, i8* %13, i64 %30)
%32 = call i32 @checkWlanCli(i8* %10)
switch i32 %32, label %36 [
i32 -1, label %33
i32 0, label %40
]
33: ; preds = %27
%34 = call i32 @sleep(i32 30)
%35 = call i32 @fclose(i32* %16)
br label %43
36: ; preds = %27
%37 = call i32 @memset(i8* %9, i32 0, i32 128)
%38 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %8, i8* %10, i8* %14, i8* %12)
%39 = call i32 @system(i8* %9)
br label %40
40: ; preds = %36, %27
%41 = call i32 @feof(i32* %16)
%42 = icmp eq i32 %41, 0
br i1 %42, label %24, label %43
43: ; preds = %24, %40, %18, %33
%44 = call i32 @fclose(i32* %16)
%45 = call i32 @sleep(i32 57)
%46 = call i32 @system(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %23
}