#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 construct_vap(char *, int, int, int);
int /*<<< orphan*/ nvram_get_ap_bss_isolation(int, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ system(char *);
int set_bss_isolation(int radio, int mode, int vap_id) {
  char cmd[128];
  int bss_isolation = 0;
  char vap_name[8];
  int ret;
  nvram_get_ap_bss_isolation(radio, vap_id, &bss_isolation);
  ret = construct_vap(vap_name, radio, vap_id, mode);
  sprintf(cmd, "iwpriv %s ap_bridge %d", vap_name, !bss_isolation);
  do {
    printf("\033[1;33;40m");
    printf(cmd);
    printf("\033[0m");
    printf("\n");
    system(cmd);
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<set_bss_isolation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x94(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
lea    -0x94(%rbp),%rdx
call   1040 <nvram_get_ap_bss_isolation@plt>
lea    -0x9c(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1030 <construct_vap@plt>
mov    %eax,-0xa0(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x9c(%rbp),%rdx
cmpl   $0x0,-0x94(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe3f(%rip),%rsi
call   1070 <sprintf@plt>
lea    0xe4a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <printf@plt>
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_bss_isolation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdx
mov    %ebx,%esi
call   1050 <nvram_get_ap_bss_isolation@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
call   1040 <construct_vap@plt>
xor    %ecx,%ecx
cmpl   $0x0,0x4(%rsp)
sete   %cl
lea    0xe53(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   1080 <sprintf@plt>
lea    0xe53(%rip),%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1070 <printf@plt>
lea    0xe4a(%rip),%rdi
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"iwpriv %s ap_bridge %d\00"
@.str.1 = [11 x i8] c"\1B[1;33;40m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @set_bss_isolation(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
%9 = alloca [8 x i8]
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
%11 = load i32, i32* %4
%12 = load i32, i32* %6
%13 = call i32 @nvram_get_ap_bss_isolation(i32 %11, i32 %12, i32* %8)
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%15 = load i32, i32* %4
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = call i32 @construct_vap(i8* %14, i32 %15, i32 %16, i32 %17)
store i32 %18, i32* %10
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %24)
br label %26
26: ; preds = %3
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%29 = call i32 @printf(i8* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%33 = call i32 @system(i8* %32)
br label %34
34: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"iwpriv %s ap_bridge %d\00"
@.str.1 = [11 x i8] c"\1B[1;33;40m\00"
@.str.2 = [5 x i8] c"\1B[0m\00"
define i32 @set_bss_isolation(i32 %0, i32 %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = alloca [8 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%10 = call i32 @nvram_get_ap_bss_isolation(i32 %0, i32 %2, i32* %5)
%11 = call i32 @construct_vap(i8* %9, i32 %0, i32 %2, i32 %1)
%12 = load i32, i32* %5
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9, i32 %14)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @printf(i8* %7)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @putchar(i32 10)
%20 = call i32 @system(i8* %7)
ret i32 0
}