int getAPConnectStatus(int radio, int *associated) {
  int ret = 0;
  int assotmp = 0;
  char iOpMode[32] = {0};
  if (0 == radio) {
    ezplib_get_attr_val("wl_mode_rule", 0, "mode", iOpMode, sizeof(iOpMode), 0);
  } else {
    ezplib_get_attr_val("wl1_mode_rule", 0, "mode", iOpMode, sizeof(iOpMode),
                        0);
  }
  if (!strcmp(iOpMode, "client")) {
    printf("%s:%d, iOpMode = %s\n", __FUNCTION__, 989, iOpMode);
    ret = get_sta_assoc_status(radio, &assotmp);
    printf("%s:%d, assotmp = %d\n", __FUNCTION__, 991, assotmp);
    if (-1 == ret) {
      *associated = 2;
    } else {
      *associated = assotmp;
    }
  } else {
    *associated = 3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getAPConnectStatus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    11b2 <getAPConnectStatus+0x62>
lea    -0x40(%rbp),%rcx
lea    0xe6d(%rip),%rdi
xor    %r9d,%r9d
lea    0xe70(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
mov    $0x0,%al
call   1030 <ezplib_get_attr_val@plt>
jmp    11d7 <getAPConnectStatus+0x87>
lea    -0x40(%rbp),%rcx
lea    0xe55(%rip),%rdi
xor    %r9d,%r9d
lea    0xe46(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
mov    $0x0,%al
call   1030 <ezplib_get_attr_val@plt>
lea    -0x40(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1267 <getAPConnectStatus+0x117>
lea    -0x40(%rbp),%rcx
lea    0xe2c(%rip),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x3dd,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <get_sta_assoc_status@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%ecx
lea    0xe26(%rip),%rdi
lea    0xe0c(%rip),%rsi
mov    $0x3df,%edx
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1259 <getAPConnectStatus+0x109>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    1262 <getAPConnectStatus+0x112>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1271 <getAPConnectStatus+0x121>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAPConnectStatus>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
test   %edi,%edi
lea    0xea5(%rip),%rax
lea    0xeb0(%rip),%rdi
cmove  %rax,%rdi
lea    0xea0(%rip),%rdx
lea    0x10(%rsp),%rcx
mov    $0x20,%r8d
xor    %esi,%esi
xor    %r9d,%r9d
xor    %eax,%eax
call   1030 <ezplib_get_attr_val@plt>
mov    $0x65696c63,%eax
xor    0x10(%rsp),%eax
mov    $0x746e65,%ecx
xor    0x13(%rsp),%ecx
or     %eax,%ecx
mov    $0x3,%eax
jne    11f9 <getAPConnectStatus+0xc9>
lea    0xe81(%rip),%rdi
lea    0xe8f(%rip),%r14
lea    0x10(%rsp),%rcx
mov    %r14,%rsi
mov    $0x3dd,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <get_sta_assoc_status@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%ecx
lea    0xe73(%rip),%rdi
mov    %r14,%rsi
mov    $0x3df,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%eax
cmp    $0xffffffff,%ebp
je     11f9 <getAPConnectStatus+0xc9>
mov    0xc(%rsp),%eax
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
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 = [21 x i8] c"%s:%d, iOpMode = %s\0A\00"
@__FUNCTION__.getAPConnectStatus = [19 x i8] c"getAPConnectStatus\00"
@.str.5 = [21 x i8] c"%s:%d, assotmp = %d\0A\00"
define i32 @getAPConnectStatus(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
store i32 0, i32* %6
%8 = bitcast [32 x i8]* %7 to i8*
%9 = load i32, i32* %3
%10 = icmp eq i32 0, %9
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%13 = call i32 (i8*, i32, i8*, i8*, i64, i32, ...) bitcast (i32 (...)* @ezplib_get_attr_val to i32 (i8*, i32, i8*, i8*, i64, i32, ...)*)(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* %12, i64 32, i32 0)
br label %17
14: ; preds = %2
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%16 = call i32 (i8*, i32, i8*, i8*, i64, i32, ...) bitcast (i32 (...)* @ezplib_get_attr_val to i32 (i8*, i32, i8*, i8*, i64, i32, ...)*)(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* %15, i64 32, i32 0)
br label %17
17: ; preds = %14, %11
%18 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %36, label %21
21: ; preds = %17
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.getAPConnectStatus, i64 0, i64 0), i32 989, i8* %22)
%24 = load i32, i32* %3
%25 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_sta_assoc_status to i32 (i32, i32*, ...)*)(i32 %24, i32* %6)
store i32 %25, i32* %5
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.getAPConnectStatus, i64 0, i64 0), i32 991, i32 %26)
%28 = load i32, i32* %5
%29 = icmp eq i32 -1, %28
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = load i32*, i32** %4
store i32 2, i32* %31
br label %35
32: ; preds = %21
%33 = load i32, i32* %6
%34 = load i32*, i32** %4
store i32 %33, i32* %34
br label %35
35: ; preds = %32, %30
br label %38
36: ; preds = %17
%37 = load i32*, i32** %4
store i32 3, i32* %37
br label %38
38: ; 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 = [21 x i8] c"%s:%d, iOpMode = %s\0A\00"
@__FUNCTION__.getAPConnectStatus = [19 x i8] c"getAPConnectStatus\00"
@.str.5 = [21 x i8] c"%s:%d, assotmp = %d\0A\00"
define i32 @getAPConnectStatus(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca [32 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%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 (i8*, i32, i8*, i8*, i64, i32, ...) bitcast (i32 (...)* @ezplib_get_attr_val to i32 (i8*, i32, i8*, i8*, i64, i32, ...)*)(i8* %8, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6, i64 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 %20
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.getAPConnectStatus, i64 0, i64 0), i32 989, i8* %6)
%14 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_sta_assoc_status to i32 (i32, i32*, ...)*)(i32 %0, i32* %3)
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.getAPConnectStatus, i64 0, i64 0), i32 991, i32 %15)
%17 = icmp eq i32 %14, -1
%18 = load i32, i32* %3
%19 = select i1 %17, i32 2, i32 %18
br label %20
20: ; preds = %12, %2
%21 = phi i32 [ 3, %2 ], [ %19, %12 ]
store i32 %21, i32* %1
ret i32 0
}