#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_status(int, int *);
int /*<<< orphan*/ strcmp(char *, char *);
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, 32, 0);
  } else {
    ezplib_get_attr_val("wl1_mode_rule", 0, "mode", iOpMode, 32, 0);
  }
  if (!strcmp(iOpMode, "client")) {
    ret = get_sta_assoc_status(radio, &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   1040 <memset@plt>
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    11a0 <getAPConnectStatus+0x60>
lea    -0x40(%rbp),%rcx
lea    0xe7d(%rip),%rdi
xor    %r9d,%r9d
lea    0xe80(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
jmp    11c3 <getAPConnectStatus+0x83>
lea    -0x40(%rbp),%rcx
lea    0xe67(%rip),%rdi
xor    %r9d,%r9d
lea    0xe58(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
lea    -0x40(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1216 <getAPConnectStatus+0xd6>
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1060 <get_sta_assoc_status@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1208 <getAPConnectStatus+0xc8>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
jmp    1211 <getAPConnectStatus+0xd1>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1220 <getAPConnectStatus+0xe0>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAPConnectStatus>:
push   %rbp
push   %rbx
sub    $0x38,%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    0xeb7(%rip),%rax
lea    0xec2(%rip),%rdi
cmove  %rax,%rdi
lea    0xeb2(%rip),%rdx
lea    0x10(%rsp),%rcx
xor    %esi,%esi
mov    $0x20,%r8d
xor    %r9d,%r9d
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,%ecx
jne    11a5 <getAPConnectStatus+0x85>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
call   1040 <get_sta_assoc_status@plt>
mov    $0x2,%ecx
cmp    $0xffffffff,%eax
je     11a5 <getAPConnectStatus+0x85>
mov    0xc(%rsp),%ecx
mov    %ecx,(%rbx)
xor    %eax,%eax
add    $0x38,%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"
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 @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* %12, i32 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 @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* %15, i32 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 %32, label %21
21: ; preds = %17
%22 = load i32, i32* %3
%23 = call i32 @get_sta_assoc_status(i32 %22, i32* %6)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp eq i32 -1, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i32*, i32** %4
store i32 2, i32* %27
br label %31
28: ; preds = %21
%29 = load i32, i32* %6
%30 = load i32*, i32** %4
store i32 %29, i32* %30
br label %31
31: ; preds = %28, %26
br label %34
32: ; preds = %17
%33 = load i32*, i32** %4
store i32 3, i32* %33
br label %34
34: ; preds = %32, %31
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"
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 @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 %17
12: ; preds = %2
%13 = call i32 @get_sta_assoc_status(i32 %0, i32* %3)
%14 = icmp eq i32 %13, -1
%15 = load i32, i32* %3
%16 = select i1 %14, i32 2, i32 %15
br label %17
17: ; preds = %12, %2
%18 = phi i32 [ 3, %2 ], [ %16, %12 ]
store i32 %18, i32* %1
ret i32 0
}