#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*/ kill_all_authentication_daemon(int, int /*<<< orphan*/);
int nvram_get_vap_num(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ radio_up_down(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ set_ap_security(int, int);
int set_ap_security_dfs(int radio) {
  int k = 0;
  int vap_num = 0;
  if (1 != radio) {
    printf("ERROR:5G Security Support DFS\n");
    return -1;
  }
  radio_up_down(1, 0, 0);
  kill_all_authentication_daemon(1, 0);
  vap_num = nvram_get_vap_num(1);
  for (k = 0; k < vap_num; k++) {
    set_ap_security(1, k);
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_ap_security_dfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
je     118f <set_ap_security_dfs+0x3f>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11eb <set_ap_security_dfs+0x9b>
mov    $0x1,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <radio_up_down@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1070 <kill_all_authentication_daemon@plt>
mov    $0x1,%edi
call   1050 <nvram_get_vap_num@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e4 <set_ap_security_dfs+0x94>
mov    -0xc(%rbp),%esi
mov    $0x1,%edi
call   1060 <set_ap_security@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <set_ap_security_dfs+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ap_security_dfs>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jne    11a5 <set_ap_security_dfs+0x55>
xor    %r14d,%r14d
mov    $0x1,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <radio_up_down@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1070 <kill_all_authentication_daemon@plt>
mov    $0x1,%edi
call   1050 <nvram_get_vap_num@plt>
test   %eax,%eax
jle    11b7 <set_ap_security_dfs+0x67>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %ebx,%esi
call   1060 <set_ap_security@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1190 <set_ap_security_dfs+0x40>
jmp    11b7 <set_ap_security_dfs+0x67>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"ERROR:5G Security Support DFS\0A\00"
define i32 @set_ap_security_dfs(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp ne i32 1, %6
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %25
10: ; preds = %1
%11 = call i32 @radio_up_down(i32 1, i32 0, i32 0)
%12 = call i32 @kill_all_authentication_daemon(i32 1, i32 0)
%13 = call i32 @nvram_get_vap_num(i32 1)
store i32 %13, i32* %5
store i32 0, i32* %4
br label %14
14: ; preds = %21, %10
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %4
%20 = call i32 @set_ap_security(i32 1, i32 %19)
br label %21
21: ; preds = %18
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %14
24: ; preds = %14
store i32 0, i32* %2
br label %25
25: ; preds = %24, %8
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@str = [30 x i8] c"ERROR:5G Security Support DFS\00"
define i32 @set_ap_security_dfs(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %15
5: ; preds = %1
%6 = tail call i32 @radio_up_down(i32 1, i32 0, i32 0)
%7 = tail call i32 @kill_all_authentication_daemon(i32 1, i32 0)
%8 = tail call i32 @nvram_get_vap_num(i32 1)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5, %10
%11 = phi i32 [ %13, %10 ], [ 0, %5 ]
%12 = tail call i32 @set_ap_security(i32 1, i32 %11)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %8
br i1 %14, label %15, label %10
15: ; preds = %10, %5, %3
%16 = phi i32 [ -1, %3 ], [ 0, %5 ], [ 0, %10 ]
ret i32 %16
}