#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 /*<<< orphan*/ ezplib_get_attr_val(char *, int /*<<< orphan*/, char *,
                                       char *, int, int /*<<< orphan*/);
int get_sta_assoc_bssid(int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int getAPConnectBSSID(int radio, char *buf) {
  int ret = 0;
  char macBuf[18] = {0};
  char iOpMode[32] = {0};
  if (0 == radio) {
    ezplib_get_attr_val("wl_mode_rule", 0, "mode", iOpMode, 32, 0);
  } else {
    ezplib_get_attr_val("wl1_mode_rule", 0, "mode", iOpMode, 32, 0);
  }
  if (!strcmp(iOpMode, "client")) {
    ret = get_sta_assoc_bssid(radio, macBuf);
    if (-1 == ret) {
      strcpy(buf, "00:00:00:00:00:00");
    } else {
      strcpy(buf, macBuf);
    }
  } else {
    strcpy(buf, "--");
  }
  return 0;
}


x86 assembly (clang, -O0):
<getAPConnectBSSID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1060 <memset@plt>
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    11b9 <getAPConnectBSSID+0x69>
lea    -0x50(%rbp),%rcx
lea    0xe64(%rip),%rdi
xor    %r9d,%r9d
lea    0xe67(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
jmp    11dc <getAPConnectBSSID+0x8c>
lea    -0x50(%rbp),%rcx
lea    0xe4e(%rip),%rdi
xor    %r9d,%r9d
lea    0xe3f(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
lea    -0x50(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1239 <getAPConnectBSSID+0xe9>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <get_sta_assoc_bssid@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1227 <getAPConnectBSSID+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1234 <getAPConnectBSSID+0xe4>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1249 <getAPConnectBSSID+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xdf5(%rip),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAPConnectBSSID>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movw   $0x0,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
test   %edi,%edi
lea    0xea4(%rip),%rax
lea    0xeaf(%rip),%rdi
cmove  %rax,%rdi
lea    0xe9f(%rip),%rdx
lea    0x20(%rsp),%rcx
xor    %esi,%esi
mov    $0x20,%r8d
xor    %r9d,%r9d
call   1030 <ezplib_get_attr_val@plt>
mov    $0x65696c63,%eax
xor    0x20(%rsp),%eax
mov    $0x746e65,%ecx
xor    0x23(%rsp),%ecx
or     %eax,%ecx
je     11a2 <getAPConnectBSSID+0x72>
lea    0xe99(%rip),%rsi
jmp    11bd <getAPConnectBSSID+0x8d>
mov    %rsp,%rsi
mov    %ebp,%edi
call   1050 <get_sta_assoc_bssid@plt>
cmp    $0xffffffff,%eax
je     11b6 <getAPConnectBSSID+0x86>
mov    %rsp,%rsi
jmp    11bd <getAPConnectBSSID+0x8d>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"wl_mode_rule\00"
@.str.1 = [5 x i8] c"mode\00"
@.str.2 = [14 x i8] c"wl1_mode_rule\00"
@.str.3 = [7 x i8] c"client\00"
@.str.4 = [18 x i8] c"00:00:00:00:00:00\00"
@.str.5 = [3 x i8] c"--\00"
define i32 @getAPConnectBSSID(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [18 x i8]
%7 = alloca [32 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%8 = bitcast [18 x i8]* %6 to i8*
%9 = bitcast [32 x i8]* %7 to i8*
%10 = load i32, i32* %3
%11 = icmp eq i32 0, %10
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%14 = call i32 @ezplib_get_attr_val(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 32, i32 0)
br label %18
15: ; preds = %2
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%17 = call i32 @ezplib_get_attr_val(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32 32, i32 0)
br label %18
18: ; preds = %15, %12
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %36, label %22
22: ; preds = %18
%23 = load i32, i32* %3
%24 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%25 = call i32 @get_sta_assoc_bssid(i32 %23, i8* %24)
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp eq i32 -1, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %35
31: ; preds = %22
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [18 x i8], [18 x i8]* %6, i64 0, i64 0
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %31, %28
br label %39
36: ; preds = %18
%37 = load i8*, i8** %4
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %36, %35
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"wl_mode_rule\00"
@.str.1 = [5 x i8] c"mode\00"
@.str.2 = [14 x i8] c"wl1_mode_rule\00"
@.str.3 = [7 x i8] c"client\00"
@.str.4 = [18 x i8] c"00:00:00:00:00:00\00"
@.str.5 = [3 x i8] c"--\00"
define i32 @getAPConnectBSSID(i32 %0, i8* %1) {
%3 = alloca [18 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 0
%8 = select i1 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 @ezplib_get_attr_val(i8* %8, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6, i32 32, i32 0)
%10 = call i32 @bcmp(i8* dereferenceable(7) %6, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = call i32 @get_sta_assoc_bssid(i32 %0, i8* %5)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %21
17: ; preds = %12
%18 = call i32 @strcpy(i8* %1, i8* %5)
br label %21
19: ; preds = %2
%20 = call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %15, %17, %19
ret i32 0
}