#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*/ err(int, char *, char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ system(char *);
void setup_ipfw_rules() {
  static char *ipfw_cmds[] = {
      "/sbin/ipfw 60 add divert 666 tcp from any to any 80",
      "/sbin/ipfw 61 add divert 666 tcp from any 80 to any",
      "/sbin/ipfw 62 add divert 666 tcp from any to any 7777",
      "/sbin/ipfw 63 add divert 666 tcp from any 7777 to any", NULL};
  int i;
  printf("Setting up ipfw rules...\n");
  for (i = 0; ipfw_cmds[i] != NULL; ++i) {
    if (system(ipfw_cmds[i]))
      err(1, "%s", ipfw_cmds[i]);
  }
}


x86 assembly (clang, -O0):
<setup_ipfw_rules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xf95(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rcx
lea    0x2eea(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
je     11b2 <setup_ipfw_rules+0x82>
movslq -0x4(%rbp),%rcx
lea    0x2ed4(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1030 <system@plt>
cmp    $0x0,%rax
je     119f <setup_ipfw_rules+0x6f>
movslq -0x4(%rbp),%rcx
lea    0x2eb6(%rip),%rax
mov    (%rax,%rcx,8),%rdx
mov    $0x1,%edi
lea    0xf54(%rip),%rsi
call   1050 <err@plt>
jmp    11a4 <setup_ipfw_rules+0x74>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114b <setup_ipfw_rules+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_ipfw_rules>:
push   %rax
lea    0xf9f(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1040 <system@plt>
test   %rax,%rax
je     1166 <setup_ipfw_rules+0x36>
lea    0xf7f(%rip),%rsi
lea    0xea4(%rip),%rdx
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xec7(%rip),%rdi
call   1040 <system@plt>
test   %rax,%rax
je     118f <setup_ipfw_rules+0x5f>
lea    0xf56(%rip),%rsi
lea    0xeaf(%rip),%rdx
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xed2(%rip),%rdi
call   1040 <system@plt>
test   %rax,%rax
je     11b8 <setup_ipfw_rules+0x88>
lea    0xf2d(%rip),%rsi
lea    0xeba(%rip),%rdx
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xedf(%rip),%rdi
call   1040 <system@plt>
test   %rax,%rax
je     11e2 <setup_ipfw_rules+0xb2>
lea    0xf04(%rip),%rsi
lea    0xec7(%rip),%rdx
mov    $0x1,%edi
pop    %rax
jmp    1050 <err@plt>
pop    %rax
ret

LLVM IR (-O0):
@setup_ipfw_rules.ipfw_cmds = internal global [5 x i8*] [i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i32 0, i32 0), i8* null]
@.str = [52 x i8] c"/sbin/ipfw 60 add divert 666 tcp from any to any 80\00"
@.str.1 = [52 x i8] c"/sbin/ipfw 61 add divert 666 tcp from any 80 to any\00"
@.str.2 = [54 x i8] c"/sbin/ipfw 62 add divert 666 tcp from any to any 7777\00"
@.str.3 = [54 x i8] c"/sbin/ipfw 63 add divert 666 tcp from any 7777 to any\00"
@.str.4 = [26 x i8] c"Setting up ipfw rules...\0A\00"
@.str.5 = [3 x i8] c"%s\00"
define void @setup_ipfw_rules() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %3
3: ; preds = %23, %0
%4 = load i32, i32* %1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* @setup_ipfw_rules.ipfw_cmds, i64 0, i64 %5
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %26
9: ; preds = %3
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* @setup_ipfw_rules.ipfw_cmds, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i64 @system(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %9
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* @setup_ipfw_rules.ipfw_cmds, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %16, %9
br label %23
23: ; preds = %22
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %3
26: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [52 x i8] c"/sbin/ipfw 60 add divert 666 tcp from any to any 80\00"
@.str.1 = [52 x i8] c"/sbin/ipfw 61 add divert 666 tcp from any 80 to any\00"
@.str.2 = [54 x i8] c"/sbin/ipfw 62 add divert 666 tcp from any to any 7777\00"
@.str.3 = [54 x i8] c"/sbin/ipfw 63 add divert 666 tcp from any 7777 to any\00"
@.str.5 = [3 x i8] c"%s\00"
@str = [25 x i8] c"Setting up ipfw rules...\00"
define void @setup_ipfw_rules() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%2 = tail call i64 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %0, %4
%7 = tail call i64 @system(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = tail call i64 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = tail call i64 @system(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
ret void
}