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


x86 assembly (clang, -O0):
<set_ap_isolation>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
lea    -0x9c(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
movl   $0x0,-0xa0(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xa0(%rbp),%rsi
call   1040 <nvram_get_ap_isolation@plt>
lea    -0x9c(%rbp),%rdi
mov    -0x4(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <construct_vap@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x9c(%rbp),%rdx
mov    -0xa0(%rbp),%ecx
lea    0xe1f(%rip),%rsi
call   1080 <sprintf@plt>
lea    0xe2c(%rip),%rdi
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1060 <printf@plt>
lea    0xe1f(%rip),%rdi
call   1060 <printf@plt>
lea    0xe18(%rip),%rdi
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1050 <system@plt>
mov    -0x94(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_ap_isolation>:
push   %rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
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)
movq   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
call   1050 <nvram_get_ap_isolation@plt>
lea    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <construct_vap@plt>
mov    %eax,%ebp
mov    0x4(%rsp),%ecx
lea    0xe2a(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
lea    0xe2c(%rip),%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1070 <printf@plt>
lea    0xe23(%rip),%rdi
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %ebp,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"iwpriv %s apisolation %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_ap_isolation(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca [8 x i8]
%6 = alloca i32
store i32 %0, i32* %2
%7 = bitcast [128 x i8]* %3 to i8*
%8 = bitcast [8 x i8]* %5 to i8*
store i32 0, i32* %6
%9 = load i32, i32* %2
%10 = call i32 @nvram_get_ap_isolation(i32 %9, i32* %6)
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%12 = load i32, i32* %2
%13 = call i32 @construct_vap(i8* %11, i32 %12, i32 0, i32 0)
store i32 %13, i32* %4
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%16 = load i32, i32* %6
%17 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %16)
br label %18
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%21 = call i32 @printf(i8* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%25 = call i32 @system(i8* %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@.str = [25 x i8] c"iwpriv %s apisolation %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_ap_isolation(i32 %0) {
%2 = alloca [128 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = call i32 @nvram_get_ap_isolation(i32 %0, i32* %4)
%9 = call i32 @construct_vap(i8* %6, i32 %0, i32 0, i32 0)
%10 = load i32, i32* %4
%11 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %10)
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* %5)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @putchar(i32 10)
%16 = call i32 @system(i8* %5)
ret i32 %9
}