#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*/ system(char *);
void XHTTP_rule(int flag) {
  if (flag == 0) {
    system("iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL "
           "PSH,ACK --dport 80 -j XHTTP");
    system("iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL "
           "PSH,ACK --dport 8080 -j XHTTP");
  } else if (flag == 1) {
    system("iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL "
           "PSH,ACK --dport 80 -j XHTTP");
    system("iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL "
           "PSH,ACK --dport 8080 -j XHTTP");
  } else {
    system("[ \"x$(iptables -t mangle -nvL |grep XHTTP)\" = \"x\" ] && "
           "iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL "
           "PSH,ACK --dport 80 -j XHTTP && iptables -t mangle -I PREROUTING 1 "
           "-i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP");
  }
}


x86 assembly (clang, -O0):
<XHTTP_rule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1142 <XHTTP_rule+0x32>
lea    0xed4(%rip),%rdi
call   1030 <system@plt>
lea    0xf23(%rip),%rdi
call   1030 <system@plt>
jmp    117a <XHTTP_rule+0x6a>
cmpl   $0x1,-0x4(%rbp)
jne    1169 <XHTTP_rule+0x59>
lea    0xf65(%rip),%rdi
call   1030 <system@plt>
lea    0x104d(%rip),%rdi
call   1030 <system@plt>
jmp    1175 <XHTTP_rule+0x65>
lea    0xfa5(%rip),%rdi
call   1030 <system@plt>
jmp    117a <XHTTP_rule+0x6a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XHTTP_rule>:
push   %rbx
test   %edi,%edi
je     112a <XHTTP_rule+0x1a>
cmp    $0x1,%edi
jne    113f <XHTTP_rule+0x2f>
lea    0x108b(%rip),%rbx
lea    0xf90(%rip),%rdi
jmp    1138 <XHTTP_rule+0x28>
lea    0xf2a(%rip),%rbx
lea    0xec8(%rip),%rdi
call   1030 <system@plt>
jmp    1146 <XHTTP_rule+0x36>
lea    0xfcf(%rip),%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <system@plt>

LLVM IR (-O0):
@.str = [91 x i8] c"iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP\00"
@.str.1 = [93 x i8] c"iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
@.str.2 = [93 x i8] c"iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP\00"
@.str.3 = [95 x i8] c"iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
@.str.4 = [246 x i8] c"[ \22x$(iptables -t mangle -nvL |grep XHTTP)\22 = \22x\22 ] && iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP && iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
define void @XHTTP_rule(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = call i32 @system(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @system(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0))
br label %17
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = call i32 @system(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @system(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.3, i64 0, i64 0))
br label %16
14: ; preds = %8
%15 = call i32 @system(i8* getelementptr inbounds ([246 x i8], [246 x i8]* @.str.4, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
br label %17
17: ; preds = %16, %5
ret void
}

LLVM IR (-O2):
@.str = [91 x i8] c"iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP\00"
@.str.1 = [93 x i8] c"iptables -t mangle -D PREROUTING -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
@.str.2 = [93 x i8] c"iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP\00"
@.str.3 = [95 x i8] c"iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
@.str.4 = [246 x i8] c"[ \22x$(iptables -t mangle -nvL |grep XHTTP)\22 = \22x\22 ] && iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 80 -j XHTTP && iptables -t mangle -I PREROUTING 1 -i br0 -p tcp --tcp-flags ALL PSH,ACK --dport 8080 -j XHTTP\00"
define void @XHTTP_rule(i32 %0) {
switch i32 %0, label %7 [
i32 0, label %3
i32 1, label %2
]
2: ; preds = %1
br label %3
3: ; preds = %1, %2
%4 = phi i8* [ getelementptr inbounds ([93 x i8], [93 x i8]* @.str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0), %1 ]
%5 = phi i8* [ getelementptr inbounds ([95 x i8], [95 x i8]* @.str.3, i64 0, i64 0), %2 ], [ getelementptr inbounds ([93 x i8], [93 x i8]* @.str.1, i64 0, i64 0), %1 ]
%6 = tail call i32 @system(i8* %4)
br label %7
7: ; preds = %3, %1
%8 = phi i8* [ getelementptr inbounds ([246 x i8], [246 x i8]* @.str.4, i64 0, i64 0), %1 ], [ %5, %3 ]
%9 = tail call i32 @system(i8* %8)
ret void
}