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

/* Variables and functions */
int atoi(char *);
int construct_vap(char *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ ezplib_get_attr_val(char *, int /*<<< orphan*/, char *,
                                       char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int get_max_txpower(int radio, int *max_txpower) {
  char str[256] = {0}, c;
  char txpower_s[8] = {0};
  char wifi_name[8] = {0};
  int wlan_mode = 0;
  int ret = 0;
  FILE *fin;
  char cmd[256] = {0};
  char TempBuf_opmode[32] = {0};
  if (0 == radio) {
    ezplib_get_attr_val("wl_mode_rule", 0, "mode", TempBuf_opmode, 32, 0);
  } else if (1 == radio) {
    ezplib_get_attr_val("wl1_mode_rule", 0, "mode", TempBuf_opmode, 32, 0);
  } else {
    printf("ERROR: Radio is Not 2.4G or 5G!\n");
    return -1;
  }
  if (!strcmp(TempBuf_opmode, "ap")) {
    wlan_mode = 0;
  } else if (!strcmp(TempBuf_opmode, "client")) {
    wlan_mode = 1;
  } else {
    printf("ERROR: WLAN OP MODE is Not AP or Client!\n");
    return -1;
  }
  ret = construct_vap(wifi_name, radio, 0, wlan_mode);
  if (-1 == ret) {
    printf("ERROR:Construct VAP failure!\n");
    return -1;
  }
  if ((1 == wlan_mode) && (1 == radio)) {
    printf("Wireless Client Mode: Txpower Shell\n");
    return 0;
  } else {
    if (1 == radio) {
      sprintf(cmd,
              "iwconfig %s txpower %d;sleep 2;iwconfig %s | awk "
              "'/Tx-Power/{print substr($4,10);}' > /tmp/max_txpower",
              wifi_name, 100, wifi_name);
    } else {
      sprintf(cmd,
              "iwpriv wifi0 getTxMaxPower2G | awk "
              "'{gsub(/getTxMaxPower2G:/,\"\");print $2}' > /tmp/max_txpower");
    }
  }
  do {
    printf("\033[1;33;40m");
    printf(cmd);
    printf("\033[0m");
    printf("\n");
    system(cmd);
  } while (0);
  fin = fopen("/tmp/max_txpower", "r");
  memset(cmd, 0, sizeof(cmd));
  if (!fgets(cmd, 16, fin)) {
    fclose(fin);
    printf("ERROR: get max power fail\n");
    return -1;
  }
  *max_txpower = atoi(cmd);
  fclose(fin);
  do {
    printf("\033[1;33;40m");
    printf("rm -f /tmp/max_txpower");
    printf("\033[0m");
    printf("\n");
    system("rm -f /tmp/max_txpower");
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<get_max_txpower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x260,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x119(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
lea    -0x121(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1080 <memset@plt>
movl   $0x0,-0x128(%rbp)
movl   $0x0,-0x12c(%rbp)
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x260(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    126b <get_max_txpower+0xbb>
lea    -0x260(%rbp),%rcx
lea    0xdb2(%rip),%rdi
xor    %r9d,%r9d
lea    0xdb5(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
jmp    12c1 <get_max_txpower+0x111>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    12a4 <get_max_txpower+0xf4>
lea    -0x260(%rbp),%rcx
lea    0xd8b(%rip),%rdi
xor    %r9d,%r9d
lea    0xd7c(%rip),%rdx
mov    $0x20,%r8d
mov    %r9d,%esi
call   1030 <ezplib_get_attr_val@plt>
jmp    12bc <get_max_txpower+0x10c>
lea    0xd75(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <get_max_txpower+0x36c>
jmp    12c1 <get_max_txpower+0x111>
lea    -0x260(%rbp),%rdi
lea    0xd72(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12ec <get_max_txpower+0x13c>
movl   $0x0,-0x128(%rbp)
jmp    1334 <get_max_txpower+0x184>
lea    -0x260(%rbp),%rdi
lea    0xd4a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1317 <get_max_txpower+0x167>
movl   $0x1,-0x128(%rbp)
jmp    132f <get_max_txpower+0x17f>
lea    0xd2d(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <get_max_txpower+0x36c>
jmp    1334 <get_max_txpower+0x184>
lea    -0x121(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x128(%rbp),%ecx
xor    %edx,%edx
call   1040 <construct_vap@plt>
mov    %eax,-0x12c(%rbp)
mov    $0xffffffff,%eax
cmp    -0x12c(%rbp),%eax
jne    137a <get_max_txpower+0x1ca>
lea    0xd0c(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <get_max_txpower+0x36c>
mov    $0x1,%eax
cmp    -0x128(%rbp),%eax
jne    13b1 <get_max_txpower+0x201>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    13b1 <get_max_txpower+0x201>
lea    0xcf3(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    151c <get_max_txpower+0x36c>
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    13ec <get_max_txpower+0x23c>
lea    -0x240(%rbp),%rdi
lea    -0x121(%rbp),%rdx
lea    -0x121(%rbp),%r8
lea    0xcdd(%rip),%rsi
mov    $0x64,%ecx
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1401 <get_max_txpower+0x251>
lea    -0x240(%rbp),%rdi
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1406 <get_max_txpower+0x256>
jmp    140b <get_max_txpower+0x25b>
lea    0xd6c(%rip),%rdi
call   1070 <printf@plt>
lea    -0x240(%rbp),%rdi
call   1070 <printf@plt>
lea    0xd5f(%rip),%rdi
call   1070 <printf@plt>
lea    0xc09(%rip),%rdi
call   1070 <printf@plt>
lea    -0x240(%rbp),%rdi
call   1060 <system@plt>
lea    0xd1f(%rip),%rdi
lea    0xd27(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x138(%rbp)
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x240(%rbp),%rdi
mov    -0x138(%rbp),%rdx
mov    $0x10,%esi
call   1090 <fgets@plt>
cmp    $0x0,%eax
jne    14b9 <get_max_txpower+0x309>
mov    -0x138(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xce6(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    151c <get_max_txpower+0x36c>
lea    -0x240(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x138(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xc9e(%rip),%rdi
call   1070 <printf@plt>
lea    0xcbd(%rip),%rdi
call   1070 <printf@plt>
lea    0xc91(%rip),%rdi
call   1070 <printf@plt>
lea    0xb3b(%rip),%rdi
call   1070 <printf@plt>
lea    0xc99(%rip),%rdi
call   1060 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_max_txpower>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x130,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movq   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
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,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
test   %edi,%edi
je     126d <get_max_txpower+0xad>
cmp    $0x1,%ebp
jne    12ce <get_max_txpower+0x10e>
lea    0xda7(%rip),%rdi
jmp    1274 <get_max_txpower+0xb4>
lea    0xd8c(%rip),%rdi
lea    0xd92(%rip),%rdx
lea    0x10(%rsp),%rcx
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x20,%r8d
xor    %r9d,%r9d
call   1030 <ezplib_get_attr_val@plt>
mov    $0x7061,%eax
xor    0x10(%rsp),%eax
movzbl 0x12(%rsp),%ecx
xor    %r15d,%r15d
or     %ax,%cx
setne  %r12b
je     12df <get_max_txpower+0x11f>
mov    $0x65696c63,%eax
xor    0x10(%rsp),%eax
mov    $0x746e65,%ecx
xor    0x13(%rsp),%ecx
or     %eax,%ecx
je     12da <get_max_txpower+0x11a>
lea    0xec9(%rip),%rdi
jmp    1460 <get_max_txpower+0x2a0>
lea    0xe42(%rip),%rdi
jmp    1460 <get_max_txpower+0x2a0>
mov    $0x1,%ebx
lea    0x8(%rsp),%rdi
mov    %ebp,%esi
xor    %edx,%edx
mov    %ebx,%ecx
call   1050 <construct_vap@plt>
cmp    $0xffffffff,%eax
je     1314 <get_max_txpower+0x154>
cmp    $0x1,%ebp
jne    1320 <get_max_txpower+0x160>
mov    %r12b,%r15b
test   %r15d,%r15d
je     1320 <get_max_txpower+0x160>
lea    0xe49(%rip),%rdi
call   1060 <puts@plt>
xor    %ebp,%ebp
jmp    146a <get_max_txpower+0x2aa>
lea    0xe5a(%rip),%rdi
jmp    1460 <get_max_txpower+0x2a0>
cmp    $0x1,%ebp
jne    1347 <get_max_txpower+0x187>
lea    0xcfe(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    $0x64,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   10e0 <sprintf@plt>
jmp    138f <get_max_txpower+0x1cf>
movups 0xd92(%rip),%xmm0
movups %xmm0,0x7f(%rsp)
movups 0xd77(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movups 0xd5b(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movups 0xd3f(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movups 0xd23(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xd07(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xd5a(%rip),%rdi
call   1090 <printf@plt>
lea    0x30(%rsp),%r15
mov    %r15,%rdi
call   1090 <printf@plt>
lea    0xd4c(%rip),%rdi
call   1090 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1080 <system@plt>
lea    0xd12(%rip),%rdi
lea    0xd1a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
mov    %r15,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %eax,%eax
je     1451 <get_max_txpower+0x291>
lea    0x30(%rsp),%rdi
call   10d0 <atoi@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xcd3(%rip),%rdi
call   1090 <printf@plt>
lea    0xcd7(%rip),%rbx
mov    %rbx,%rdi
call   1090 <printf@plt>
lea    0xcc3(%rip),%rdi
call   1090 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1080 <system@plt>
jmp    146a <get_max_txpower+0x2aa>
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xcd7(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x130,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 = [33 x i8] c"ERROR: Radio is Not 2.4G or 5G!\0A\00"
@.str.4 = [3 x i8] c"ap\00"
@.str.5 = [7 x i8] c"client\00"
@.str.6 = [42 x i8] c"ERROR: WLAN OP MODE is Not AP or Client!\0A\00"
@.str.7 = [30 x i8] c"ERROR:Construct VAP failure!\0A\00"
@.str.8 = [37 x i8] c"Wireless Client Mode: Txpower Shell\0A\00"
@.str.9 = [103 x i8] c"iwconfig %s txpower %d;sleep 2;iwconfig %s | awk '/Tx-Power/{print substr($4,10);}' > /tmp/max_txpower\00"
@.str.10 = [95 x i8] c"iwpriv wifi0 getTxMaxPower2G | awk '{gsub(/getTxMaxPower2G:/,\22\22);print $2}' > /tmp/max_txpower\00"
@.str.11 = [11 x i8] c"\1B[1;33;40m\00"
@.str.12 = [5 x i8] c"\1B[0m\00"
@.str.13 = [2 x i8] c"\0A\00"
@.str.14 = [17 x i8] c"/tmp/max_txpower\00"
@.str.15 = [2 x i8] c"r\00"
@.str.16 = [27 x i8] c"ERROR: get max power fail\0A\00"
@.str.17 = [23 x i8] c"rm -f /tmp/max_txpower\00"
define i32 @get_max_txpower(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca [256 x i8]
%7 = alloca i8
%8 = alloca [8 x i8]
%9 = alloca [8 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca [256 x i8]
%14 = alloca [32 x i8]
store i32 %0, i32* %4
store i32* %1, i32** %5
%15 = bitcast [256 x i8]* %6 to i8*
%16 = bitcast [8 x i8]* %8 to i8*
%17 = bitcast [8 x i8]* %9 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
%18 = bitcast [256 x i8]* %13 to i8*
%19 = bitcast [32 x i8]* %14 to i8*
%20 = load i32, i32* %4
%21 = icmp eq i32 0, %20
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%24 = 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* %23, i32 32, i32 0)
br label %34
25: ; preds = %2
%26 = load i32, i32* %4
%27 = icmp eq i32 1, %26
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%30 = 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* %29, i32 32, i32 0)
br label %33
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %110
33: ; preds = %28
br label %34
34: ; preds = %33, %22
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %34
store i32 0, i32* %10
br label %47
39: ; preds = %34
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %39
store i32 1, i32* %10
br label %46
44: ; preds = %39
%45 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %110
46: ; preds = %43
br label %47
47: ; preds = %46, %38
%48 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%49 = load i32, i32* %4
%50 = load i32, i32* %10
%51 = call i32 @construct_vap(i8* %48, i32 %49, i32 0, i32 %50)
store i32 %51, i32* %11
%52 = load i32, i32* %11
%53 = icmp eq i32 -1, %52
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %110
56: ; preds = %47
%57 = load i32, i32* %10
%58 = icmp eq i32 1, %57
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i32, i32* %4
%61 = icmp eq i32 1, %60
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %110
64: ; preds = %59, %56
%65 = load i32, i32* %4
%66 = icmp eq i32 1, %65
br i1 %66, label %67, label %72
67: ; preds = %64
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%69 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%70 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* %68, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.9, i64 0, i64 0), i8* %69, i32 100, i8* %70)
br label %75
72: ; preds = %64
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%74 = call i32 (i8*, i8*, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.10, i64 0, i64 0))
br label %75
75: ; preds = %72, %67
br label %76
76: ; preds = %75
br label %77
77: ; preds = %76
%78 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%80 = call i32 @printf(i8* %79)
%81 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%82 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%84 = call i32 @system(i8* %83)
br label %85
85: ; preds = %77
%86 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32* %86, i32** %12
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%88 = call i32 @memset(i8* %87, i32 0, i32 256)
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%90 = load i32*, i32** %12
%91 = call i32 @fgets(i8* %89, i32 16, i32* %90)
%92 = icmp ne i32 %91, 0
br i1 %92, label %97, label %93
93: ; preds = %85
%94 = load i32*, i32** %12
%95 = call i32 @fclose(i32* %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0))
store i32 -1, i32* %3
br label %110
97: ; preds = %85
%98 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%99 = call i32 @atoi(i8* %98)
%100 = load i32*, i32** %5
store i32 %99, i32* %100
%101 = load i32*, i32** %12
%102 = call i32 @fclose(i32* %101)
br label %103
103: ; preds = %97
%104 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%105 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%106 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%107 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%108 = call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
br label %109
109: ; preds = %103
store i32 0, i32* %3
br label %110
110: ; preds = %109, %93, %62, %54, %44, %31
%111 = load i32, i32* %3
ret i32 %111
}

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.4 = [3 x i8] c"ap\00"
@.str.5 = [7 x i8] c"client\00"
@.str.9 = [103 x i8] c"iwconfig %s txpower %d;sleep 2;iwconfig %s | awk '/Tx-Power/{print substr($4,10);}' > /tmp/max_txpower\00"
@.str.10 = [95 x i8] c"iwpriv wifi0 getTxMaxPower2G | awk '{gsub(/getTxMaxPower2G:/,\22\22);print $2}' > /tmp/max_txpower\00"
@.str.11 = [11 x i8] c"\1B[1;33;40m\00"
@.str.12 = [5 x i8] c"\1B[0m\00"
@.str.14 = [17 x i8] c"/tmp/max_txpower\00"
@.str.15 = [2 x i8] c"r\00"
@.str.17 = [23 x i8] c"rm -f /tmp/max_txpower\00"
@str = [32 x i8] c"ERROR: Radio is Not 2.4G or 5G!\00"
@str.18 = [26 x i8] c"ERROR: get max power fail\00"
@str.19 = [36 x i8] c"Wireless Client Mode: Txpower Shell\00"
@str.20 = [29 x i8] c"ERROR:Construct VAP failure!\00"
@str.21 = [41 x i8] c"ERROR: WLAN OP MODE is Not AP or Client!\00"
define i32 @get_max_txpower(i32 %0, i32* nocapture writeonly %1) {
%3 = alloca i64
%4 = alloca [256 x i8]
%5 = alloca [32 x i8]
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
switch i32 %0, label %10 [
i32 0, label %12
i32 1, label %9
]
9: ; preds = %2
br label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %59
12: ; preds = %2, %9
%13 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %2 ]
%14 = call i32 @ezplib_get_attr_val(i8* %13, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 32, i32 0)
%15 = call i32 @bcmp(i8* dereferenceable(3) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = call i32 @bcmp(i8* dereferenceable(7) %8, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 7)
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.21, i64 0, i64 0))
br label %59
22: ; preds = %17, %12
%23 = phi i32 [ 0, %12 ], [ 1, %17 ]
%24 = call i32 @construct_vap(i8* %6, i32 %0, i32 0, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.20, i64 0, i64 0))
br label %59
28: ; preds = %22
%29 = xor i1 %16, true
%30 = icmp eq i32 %0, 1
%31 = and i1 %30, %29
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
br label %59
34: ; preds = %28
br i1 %30, label %35, label %37
35: ; preds = %34
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.9, i64 0, i64 0), i64* %3, i32 100, i64* %3)
br label %38
37: ; preds = %34
br label %38
38: ; preds = %37, %35
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%40 = call i32 @printf(i8* %7)
%41 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%42 = call i32 @putchar(i32 10)
%43 = call i32 @system(i8* %7)
%44 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
%45 = call i32 @memset(i8* %7, i32 0, i32 256)
%46 = call i32 @fgets(i8* %7, i32 16, i32* %44)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %38
%49 = call i32 @fclose(i32* %44)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.18, i64 0, i64 0))
br label %59
51: ; preds = %38
%52 = call i32 @atoi(i8* %7)
store i32 %52, i32* %1
%53 = call i32 @fclose(i32* %44)
%54 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
%55 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
%56 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%57 = call i32 @putchar(i32 10)
%58 = call i32 @system(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0))
br label %59
59: ; preds = %51, %48, %32, %26, %20, %10
%60 = phi i32 [ -1, %20 ], [ -1, %26 ], [ 0, %32 ], [ 0, %51 ], [ -1, %48 ], [ -1, %10 ]
ret i32 %60
}