int set_operation_mode(int radio, int mode_prev, int mode_curr) {
  int ssid_num = 0;
  int i;
  printf("%s(%s, %s, %s)\r\n", __FUNCTION__,
         radio == 0 ? "RADIO_2G" : "RADIO_5G",
         mode_prev == 0 ? "WLAN_MODE_AP" : "WLAN_MODE_STA",
         mode_curr == 0 ? "WLAN_MODE_AP" : "WLAN_MODE_STA");
  do {
    if (!((0 == mode_curr) || (1 == mode_curr)))
      printf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/liutianpingyanxiaoyu/cpe/refs/heads/"
             "master/package/liteon-apps/wlan-middleware/src/mid_func.c"
             ":%u:%s: "
             "Error:Such wlan mode is not supported currently"
             "\n",
             305, __FUNCTION__);
  } while (0);
  do {
    if (!((0 == mode_prev) || (1 == mode_prev)))
      printf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/liutianpingyanxiaoyu/cpe/refs/heads/"
             "master/package/liteon-apps/wlan-middleware/src/mid_func.c"
             ":%u:%s: "
             "Error:Such wlan mode is not supported currently"
             "\n",
             306, __FUNCTION__);
  } while (0);
  wait_for_bridge_setup(radio, mode_curr);
  if ((mode_prev == mode_curr) && (mode_curr == 0)) {
    ssid_num = atoi(nvram_safe_get("wlv_rule_max"));
    for (i = 0; i < ssid_num; i++) {
      set_ap_security(radio, i);
    }
    return 0;
  }
  switch (mode_curr) {
  case 0:
    set_opmode_ap(radio, mode_curr);
    break;
  case 1:
    set_opmode_sta(radio, mode_curr);
    break;
  default:
    printf("Error:Such wlan mode is not supported current, please check it\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_operation_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xe9b(%rip),%rdx
lea    0xe8b(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
mov    -0xc(%rbp),%esi
lea    0xe99(%rip),%rcx
lea    0xe85(%rip),%rax
cmp    $0x0,%esi
cmove  %rax,%rcx
mov    -0x10(%rbp),%esi
lea    0xe81(%rip),%r8
lea    0xe6d(%rip),%rax
cmp    $0x0,%esi
cmove  %rax,%r8
lea    0xe29(%rip),%rdi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%eax
je     1218 <set_operation_mode+0xa8>
mov    $0x1,%eax
cmp    -0x10(%rbp),%eax
je     1218 <set_operation_mode+0xa8>
lea    0xe4c(%rip),%rdi
mov    $0x131,%esi
lea    0xe00(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121d <set_operation_mode+0xad>
jmp    1222 <set_operation_mode+0xb2>
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
je     1255 <set_operation_mode+0xe5>
mov    $0x1,%eax
cmp    -0xc(%rbp),%eax
je     1255 <set_operation_mode+0xe5>
lea    0xe0f(%rip),%rdi
mov    $0x132,%esi
lea    0xdc3(%rip),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <set_operation_mode+0xea>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x0,%al
call   1040 <wait_for_bridge_setup@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    12d1 <set_operation_mode+0x161>
cmpl   $0x0,-0x10(%rbp)
jne    12d1 <set_operation_mode+0x161>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1060 <nvram_safe_get@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12c5 <set_operation_mode+0x155>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x0,%al
call   1080 <set_ap_security@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    129e <set_operation_mode+0x12e>
movl   $0x0,-0x4(%rbp)
jmp    133a <set_operation_mode+0x1ca>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     12f5 <set_operation_mode+0x185>
jmp    12e4 <set_operation_mode+0x174>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
je     1307 <set_operation_mode+0x197>
jmp    1319 <set_operation_mode+0x1a9>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x0,%al
call   1050 <set_opmode_ap@plt>
jmp    1333 <set_operation_mode+0x1c3>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x0,%al
call   1070 <set_opmode_sta@plt>
jmp    1333 <set_operation_mode+0x1c3>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133a <set_operation_mode+0x1ca>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_operation_mode>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r12d
test   %edi,%edi
lea    0xe8d(%rip),%rcx
lea    0xe8f(%rip),%rax
cmove  %rcx,%rax
test   %esi,%esi
lea    0xe8b(%rip),%rsi
lea    0xe91(%rip),%r8
mov    %r8,%rcx
cmove  %rsi,%rcx
mov    %edx,%ebp
test   %edx,%edx
cmove  %rsi,%r8
lea    0xe38(%rip),%rdi
lea    0xe42(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jb     11f8 <set_operation_mode+0x78>
lea    0xe6c(%rip),%rdi
lea    0xe25(%rip),%rdx
mov    $0x131,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r15d
jb     1218 <set_operation_mode+0x98>
lea    0xe4c(%rip),%rdi
lea    0xe05(%rip),%rdx
mov    $0x132,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r14d,%r14d
mov    %r12d,%edi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <wait_for_bridge_setup@plt>
or     %ebp,%r15d
je     1246 <set_operation_mode+0xc6>
cmp    $0x1,%ebp
je     1285 <set_operation_mode+0x105>
test   %ebp,%ebp
jne    1299 <set_operation_mode+0x119>
xor    %r14d,%r14d
mov    %r12d,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <set_opmode_ap@plt>
jmp    12ab <set_operation_mode+0x12b>
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1070 <nvram_safe_get@plt>
mov    %eax,%edi
xor    %eax,%eax
call   10a0 <atoi@plt>
test   %eax,%eax
jle    12ab <set_operation_mode+0x12b>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %ebx,%esi
xor    %eax,%eax
call   1090 <set_ap_security@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1270 <set_operation_mode+0xf0>
jmp    12ab <set_operation_mode+0x12b>
xor    %r14d,%r14d
mov    %r12d,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1080 <set_opmode_sta@plt>
jmp    12ab <set_operation_mode+0x12b>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%s(%s, %s, %s)\0D\0A\00"
@__FUNCTION__.set_operation_mode = [19 x i8] c"set_operation_mode\00"
@.str.1 = [9 x i8] c"RADIO_2G\00"
@.str.2 = [9 x i8] c"RADIO_5G\00"
@.str.3 = [13 x i8] c"WLAN_MODE_AP\00"
@.str.4 = [14 x i8] c"WLAN_MODE_STA\00"
@.str.5 = [240 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/liutianpingyanxiaoyu/cpe/refs/heads/master/package/liteon-apps/wlan-middleware/src/mid_func.c:%u:%s: Error:Such wlan mode is not supported currently\0A\00"
@.str.6 = [13 x i8] c"wlv_rule_max\00"
@.str.7 = [64 x i8] c"Error:Such wlan mode is not supported current, please check it\0A\00"
define i32 @set_operation_mode(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0), i8* %13, i8* %17, i8* %21)
br label %23
23: ; preds = %3
%24 = load i32, i32* %7
%25 = icmp eq i32 0, %24
br i1 %25, label %31, label %26
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp eq i32 1, %27
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([240 x i8], [240 x i8]* @.str.5, i64 0, i64 0), i32 305, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0))
br label %31
31: ; preds = %29, %26, %23
br label %32
32: ; preds = %31
br label %33
33: ; preds = %32
%34 = load i32, i32* %6
%35 = icmp eq i32 0, %34
br i1 %35, label %41, label %36
36: ; preds = %33
%37 = load i32, i32* %6
%38 = icmp eq i32 1, %37
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([240 x i8], [240 x i8]* @.str.5, i64 0, i64 0), i32 306, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0))
br label %41
41: ; preds = %39, %36, %33
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = load i32, i32* %7
%45 = call i32 (i32, i32, ...) bitcast (i32 (...)* @wait_for_bridge_setup to i32 (i32, i32, ...)*)(i32 %43, i32 %44)
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %67
49: ; preds = %42
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %67
52: ; preds = %49
%53 = call i32 (i8*, ...) bitcast (i32 (...)* @nvram_safe_get to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%54 = call i32 (i32, ...) bitcast (i32 (...)* @atoi to i32 (i32, ...)*)(i32 %53)
store i32 %54, i32* %8
store i32 0, i32* %9
br label %55
55: ; preds = %63, %52
%56 = load i32, i32* %9
%57 = load i32, i32* %8
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %66
59: ; preds = %55
%60 = load i32, i32* %5
%61 = load i32, i32* %9
%62 = call i32 (i32, i32, ...) bitcast (i32 (...)* @set_ap_security to i32 (i32, i32, ...)*)(i32 %60, i32 %61)
br label %63
63: ; preds = %59
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
store i32 %65, i32* %9
br label %55
66: ; preds = %55
store i32 0, i32* %4
br label %80
67: ; preds = %49, %42
%68 = load i32, i32* %7
switch i32 %68, label %77 [
i32 0, label %69
i32 1, label %73
]
69: ; preds = %67
%70 = load i32, i32* %5
%71 = load i32, i32* %7
%72 = call i32 (i32, i32, ...) bitcast (i32 (...)* @set_opmode_ap to i32 (i32, i32, ...)*)(i32 %70, i32 %71)
br label %79
73: ; preds = %67
%74 = load i32, i32* %5
%75 = load i32, i32* %7
%76 = call i32 (i32, i32, ...) bitcast (i32 (...)* @set_opmode_sta to i32 (i32, i32, ...)*)(i32 %74, i32 %75)
br label %79
77: ; preds = %67
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %4
br label %80
79: ; preds = %73, %69
store i32 0, i32* %4
br label %80
80: ; preds = %79, %77, %66
%81 = load i32, i32* %4
ret i32 %81
}

LLVM IR (-O2):
@.str = [17 x i8] c"%s(%s, %s, %s)\0D\0A\00"
@__FUNCTION__.set_operation_mode = [19 x i8] c"set_operation_mode\00"
@.str.1 = [9 x i8] c"RADIO_2G\00"
@.str.2 = [9 x i8] c"RADIO_5G\00"
@.str.3 = [13 x i8] c"WLAN_MODE_AP\00"
@.str.4 = [14 x i8] c"WLAN_MODE_STA\00"
@.str.5 = [240 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/liutianpingyanxiaoyu/cpe/refs/heads/master/package/liteon-apps/wlan-middleware/src/mid_func.c:%u:%s: Error:Such wlan mode is not supported currently\0A\00"
@.str.6 = [13 x i8] c"wlv_rule_max\00"
@str = [63 x i8] c"Error:Such wlan mode is not supported current, please check it\00"
define i32 @set_operation_mode(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %0, 0
%5 = select i1 %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%6 = icmp eq i32 %1, 0
%7 = select i1 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%8 = icmp eq i32 %2, 0
%9 = select i1 %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0), i8* %5, i8* %7, i8* %9)
%11 = icmp ult i32 %2, 2
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([240 x i8], [240 x i8]* @.str.5, i64 0, i64 0), i32 305, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0))
br label %14
14: ; preds = %3, %12
%15 = icmp ult i32 %1, 2
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([240 x i8], [240 x i8]* @.str.5, i64 0, i64 0), i32 306, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__FUNCTION__.set_operation_mode, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
%19 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @wait_for_bridge_setup to i32 (i32, i32, ...)*)(i32 %0, i32 %2)
%20 = or i32 %2, %1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = tail call i32 (i8*, ...) bitcast (i32 (...)* @nvram_safe_get to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%24 = tail call i32 (i32, ...) bitcast (i32 (...)* @atoi to i32 (i32, ...)*)(i32 %23)
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %22, %26
%27 = phi i32 [ %29, %26 ], [ 0, %22 ]
%28 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @set_ap_security to i32 (i32, i32, ...)*)(i32 %0, i32 %27)
%29 = add nuw nsw i32 %27, 1
%30 = icmp eq i32 %29, %24
br i1 %30, label %38, label %26
31: ; preds = %18
switch i32 %2, label %36 [
i32 0, label %32
i32 1, label %34
]
32: ; preds = %31
%33 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @set_opmode_ap to i32 (i32, i32, ...)*)(i32 %0, i32 0)
br label %38
34: ; preds = %31
%35 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @set_opmode_sta to i32 (i32, i32, ...)*)(i32 %0, i32 1)
br label %38
36: ; preds = %31
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
br label %38
38: ; preds = %26, %22, %32, %34, %36
%39 = phi i32 [ -1, %36 ], [ 0, %34 ], [ 0, %32 ], [ 0, %22 ], [ 0, %26 ]
ret i32 %39
}