#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_rssi(int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int getWIFIRSSI(int radio, char *buf) {
  int ret = 0;
  char rssitmp[30] = {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_rssi(radio, rssitmp);
    if (-1 == ret) {
      strcpy(buf, "-- dBm");
    } else {
      strcpy(buf, rssitmp);
    }
  } else {
    strcpy(buf, "--");
  }
  return 0;
}


x86 assembly (clang, -O0):
<getWIFIRSSI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
xor    %eax,%eax
cmp    -0x4(%rbp),%eax
jne    11b9 <getWIFIRSSI+0x69>
lea    -0x60(%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 <getWIFIRSSI+0x8c>
lea    -0x60(%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    -0x60(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1239 <getWIFIRSSI+0xe9>
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1070 <get_sta_assoc_rssi@plt>
mov    %eax,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    -0x14(%rbp),%eax
jne    1227 <getWIFIRSSI+0xd7>
mov    -0x10(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1234 <getWIFIRSSI+0xe4>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1249 <getWIFIRSSI+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWIFIRSSI>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xorps  %xmm0,%xmm0
movups %xmm0,0x2e(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
test   %edi,%edi
lea    0xea6(%rip),%rax
lea    0xeb1(%rip),%rdi
cmove  %rax,%rdi
lea    0xea1(%rip),%rdx
mov    %rsp,%rcx
xor    %esi,%esi
mov    $0x20,%r8d
xor    %r9d,%r9d
call   1030 <ezplib_get_attr_val@plt>
mov    $0x65696c63,%eax
xor    (%rsp),%eax
mov    $0x746e65,%ecx
xor    0x3(%rsp),%ecx
or     %eax,%ecx
je     119d <getWIFIRSSI+0x6d>
lea    0xe93(%rip),%rsi
jmp    11bc <getWIFIRSSI+0x8c>
lea    0x20(%rsp),%rsi
mov    %ebp,%edi
call   1050 <get_sta_assoc_rssi@plt>
cmp    $0xffffffff,%eax
je     11b5 <getWIFIRSSI+0x85>
lea    0x20(%rsp),%rsi
jmp    11bc <getWIFIRSSI+0x8c>
lea    0xe6b(%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 = [7 x i8] c"-- dBm\00"
@.str.5 = [3 x i8] c"--\00"
define i32 @getWIFIRSSI(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [30 x i8]
%7 = alloca [32 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
%8 = bitcast [30 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 [30 x i8], [30 x i8]* %6, i64 0, i64 0
%25 = call i32 @get_sta_assoc_rssi(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 ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %35
31: ; preds = %22
%32 = load i8*, i8** %4
%33 = getelementptr inbounds [30 x i8], [30 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 = [7 x i8] c"-- dBm\00"
@.str.5 = [3 x i8] c"--\00"
define i32 @getWIFIRSSI(i32 %0, i8* %1) {
%3 = alloca [30 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [30 x i8], [30 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_rssi(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 ([7 x i8], [7 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
}