#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("wl_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    0xd79(%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    0xd67(%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    0xd64(%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    0xd3c(%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    0xd1f(%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    0xcfe(%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    0xce5(%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    0xccf(%rip),%rsi
mov    $0x64,%ecx
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1401 <get_max_txpower+0x251>
lea    -0x240(%rbp),%rdi
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
jmp    1406 <get_max_txpower+0x256>
jmp    140b <get_max_txpower+0x25b>
lea    0xd5e(%rip),%rdi
call   1070 <printf@plt>
lea    -0x240(%rbp),%rdi
call   1070 <printf@plt>
lea    0xd51(%rip),%rdi
call   1070 <printf@plt>
lea    0xbfb(%rip),%rdi
call   1070 <printf@plt>
lea    -0x240(%rbp),%rdi
call   1060 <system@plt>
lea    0xd11(%rip),%rdi
lea    0xd19(%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    0xcd8(%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    0xc90(%rip),%rdi
call   1070 <printf@plt>
lea    0xcaf(%rip),%rdi
call   1070 <printf@plt>
lea    0xc83(%rip),%rdi
call   1070 <printf@plt>
lea    0xb2d(%rip),%rdi
call   1070 <printf@plt>
lea    0xc8b(%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
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)
cmp    $0x2,%edi
jae    12be <get_max_txpower+0xfe>
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xd99(%rip),%rdi
lea    0xd9f(%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    %r14d,%r14d
or     %ax,%cx
setne  %r12b
je     12e6 <get_max_txpower+0x126>
mov    $0x65696c63,%eax
xor    0x10(%rsp),%eax
mov    $0x746e65,%ecx
xor    0x13(%rsp),%ecx
or     %eax,%ecx
je     12e1 <get_max_txpower+0x121>
lea    0xec8(%rip),%rdi
jmp    12c5 <get_max_txpower+0x105>
lea    0xe44(%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
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     1318 <get_max_txpower+0x158>
cmp    $0x1,%ebp
jne    1321 <get_max_txpower+0x161>
mov    %r12b,%r14b
test   %r14d,%r14d
je     1321 <get_max_txpower+0x161>
lea    0xe34(%rip),%rdi
call   1060 <puts@plt>
xor    %ebp,%ebp
jmp    12cf <get_max_txpower+0x10f>
lea    0xe48(%rip),%rdi
jmp    12c5 <get_max_txpower+0x105>
cmp    $0x1,%ebp
jne    1348 <get_max_txpower+0x188>
lea    0xcef(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0x8(%rsp),%rdx
mov    $0x64,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   10e0 <sprintf@plt>
jmp    1390 <get_max_txpower+0x1d0>
movups 0xd83(%rip),%xmm0
movups %xmm0,0x7f(%rsp)
movups 0xd68(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movups 0xd4c(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movups 0xd30(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movups 0xd14(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movups 0xcf8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0xd4b(%rip),%rdi
call   1090 <printf@plt>
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   1090 <printf@plt>
lea    0xd3d(%rip),%rdi
call   1090 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1080 <system@plt>
lea    0xd03(%rip),%rdi
lea    0xd0b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   10a0 <memset@plt>
mov    %r14,%rdi
mov    $0x10,%esi
mov    %rbx,%rdx
call   10b0 <fgets@plt>
test   %eax,%eax
je     1455 <get_max_txpower+0x295>
lea    0x30(%rsp),%rdi
call   10d0 <atoi@plt>
mov    %eax,(%r15)
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xcc4(%rip),%rdi
call   1090 <printf@plt>
lea    0xcc8(%rip),%rbx
mov    %rbx,%rdi
call   1090 <printf@plt>
lea    0xcb4(%rip),%rdi
call   1090 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %rbx,%rdi
call   1080 <system@plt>
jmp    12cf <get_max_txpower+0x10f>
mov    %rbx,%rdi
call   1070 <fclose@plt>
lea    0xcc5(%rip),%rdi
jmp    12c5 <get_max_txpower+0x105>

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