#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 ifWanNum(char *);
int /*<<< orphan*/ va_cmd(char *, int, int /*<<< orphan*/, char *, char *);
void brnfctrl(int trigger, int module) {
  static unsigned int br_nf_flag = 0;
  int total = 0;
  int orig;
  orig = br_nf_flag;
  total = ifWanNum("br");
  if (total == 0) {
    if (br_nf_flag != 0)
      va_cmd("/bin/brctl", 2, 0, "brnf", "off");
    br_nf_flag = 0;
    return;
  }
  if (trigger == 0) {
    br_nf_flag = br_nf_flag & (~module);
    if ((orig != 0) && (br_nf_flag == 0))
      va_cmd("/bin/brctl", 2, 0, "brnf", "off");
  } else {
    br_nf_flag = br_nf_flag | module;
    if ((orig == 0) && (br_nf_flag != 0))
      va_cmd("/bin/brctl", 2, 0, "brnf", "on");
  }
}


x86 assembly (clang, -O0):
<brnfctrl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2ef9(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    0xebb(%rip),%rdi
call   1030 <ifWanNum@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1194 <brnfctrl+0x74>
cmpl   $0x0,0x2ed6(%rip)
je     1185 <brnfctrl+0x65>
lea    0xe98(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
lea    0xe95(%rip),%rcx
lea    0xe93(%rip),%r8
call   1040 <va_cmd@plt>
movl   $0x0,0x2ea5(%rip)
jmp    123b <brnfctrl+0x11b>
cmpl   $0x0,-0x4(%rbp)
jne    11ef <brnfctrl+0xcf>
mov    0x2e90(%rip),%eax
mov    -0x8(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,0x2e82(%rip)
cmpl   $0x0,-0x10(%rbp)
je     11ea <brnfctrl+0xca>
cmpl   $0x0,0x2e71(%rip)
jne    11ea <brnfctrl+0xca>
lea    0xe33(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
lea    0xe30(%rip),%rcx
lea    0xe2e(%rip),%r8
call   1040 <va_cmd@plt>
jmp    123b <brnfctrl+0x11b>
mov    0x2e3f(%rip),%eax
or     -0x8(%rbp),%eax
mov    %eax,0x2e36(%rip)
cmpl   $0x0,-0x10(%rbp)
jne    1236 <brnfctrl+0x116>
cmpl   $0x0,0x2e25(%rip)
je     1236 <brnfctrl+0x116>
lea    0xde7(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
lea    0xde4(%rip),%rcx
lea    0xde6(%rip),%r8
call   1040 <va_cmd@plt>
jmp    123b <brnfctrl+0x11b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<brnfctrl>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2f05(%rip),%r14d
lea    0xeca(%rip),%rdi
call   1030 <ifWanNum@plt>
test   %eax,%eax
je     1171 <brnfctrl+0x51>
mov    0x2eef(%rip),%eax
test   %ebp,%ebp
je     11aa <brnfctrl+0x8a>
or     %ebx,%eax
mov    %eax,0x2ee3(%rip)
test   %r14d,%r14d
jne    11a5 <brnfctrl+0x85>
test   %eax,%eax
je     11a5 <brnfctrl+0x85>
lea    0xea2(%rip),%rdi
lea    0xea6(%rip),%rcx
lea    0xea8(%rip),%r8
jmp    11d2 <brnfctrl+0xb2>
cmpl   $0x0,0x2ebc(%rip)
je     119b <brnfctrl+0x7b>
lea    0xe82(%rip),%rdi
lea    0xe86(%rip),%rcx
lea    0xe84(%rip),%r8
mov    $0x2,%esi
xor    %edx,%edx
call   1040 <va_cmd@plt>
movl   $0x0,0x2e8f(%rip)
pop    %rbx
pop    %r14
pop    %rbp
ret
not    %ebx
and    %ebx,%eax
mov    %eax,0x2e80(%rip)
test   %r14d,%r14d
je     11a5 <brnfctrl+0x85>
test   %eax,%eax
jne    11a5 <brnfctrl+0x85>
lea    0xe3f(%rip),%rdi
lea    0xe43(%rip),%rcx
lea    0xe41(%rip),%r8
mov    $0x2,%esi
xor    %edx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <va_cmd@plt>

LLVM IR (-O0):
@brnfctrl.br_nf_flag = internal global i32 0
@.str = [3 x i8] c"br\00"
@.str.1 = [11 x i8] c"/bin/brctl\00"
@.str.2 = [5 x i8] c"brnf\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"on\00"
define void @brnfctrl(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* @brnfctrl.br_nf_flag
store i32 %7, i32* %6
%8 = call i32 @ifWanNum(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @brnfctrl.br_nf_flag
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
store i32 0, i32* @brnfctrl.br_nf_flag
br label %45
17: ; preds = %2
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = load i32, i32* @brnfctrl.br_nf_flag
%22 = load i32, i32* %4
%23 = xor i32 %22, -1
%24 = and i32 %21, %23
store i32 %24, i32* @brnfctrl.br_nf_flag
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = load i32, i32* @brnfctrl.br_nf_flag
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %27, %20
br label %45
33: ; preds = %17
%34 = load i32, i32* @brnfctrl.br_nf_flag
%35 = load i32, i32* %4
%36 = or i32 %34, %35
store i32 %36, i32* @brnfctrl.br_nf_flag
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %33
%40 = load i32, i32* @brnfctrl.br_nf_flag
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %39, %33
br label %45
45: ; preds = %16, %44, %32
ret void
}

LLVM IR (-O2):
@brnfctrl.br_nf_flag = internal unnamed_addr global i32 0
@.str = [3 x i8] c"br\00"
@.str.1 = [11 x i8] c"/bin/brctl\00"
@.str.2 = [5 x i8] c"brnf\00"
@.str.3 = [4 x i8] c"off\00"
@.str.4 = [3 x i8] c"on\00"
define void @brnfctrl(i32 %0, i32 %1) {
%3 = load i32, i32* @brnfctrl.br_nf_flag
%4 = tail call i32 @ifWanNum(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @brnfctrl.br_nf_flag
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
store i32 0, i32* @brnfctrl.br_nf_flag
br label %30
12: ; preds = %2
%13 = icmp eq i32 %0, 0
%14 = load i32, i32* @brnfctrl.br_nf_flag
br i1 %13, label %15, label %23
15: ; preds = %12
%16 = xor i32 %1, -1
%17 = and i32 %14, %16
store i32 %17, i32* @brnfctrl.br_nf_flag
%18 = icmp ne i32 %3, 0
%19 = icmp eq i32 %17, 0
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %21, label %30
21: ; preds = %15
%22 = tail call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %30
23: ; preds = %12
%24 = or i32 %14, %1
store i32 %24, i32* @brnfctrl.br_nf_flag
%25 = icmp eq i32 %3, 0
%26 = icmp ne i32 %24, 0
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = tail call i32 @va_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %21, %15, %28, %23, %11
ret void
}