#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getRandByte();
int getRandWord();
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
char *strdup(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int i;
  int n = 0;
  char *fname = NULL;
  FILE *f;
  srand48(time(NULL));
  while ((i = getopt(argc, argv, "n:f:h?")) != -1) {
    if ((i != '?') && (i != 'h')) {
      switch (i) {
      case 'n':
        n = atoi(optarg);
        break;
      case 'f':
        fname = strdup(optarg);
        break;
      default:
        break;
      }
    } else {
      usage();
    }
  }
  if (fname == NULL) {
    usage();
    exit(1);
  }
  f = fopen(fname, "w");
  fprintf(f, "<!DOCTYPE RULESET SYSTEM \"rulefile.dtd\">\n");
  fprintf(f, "<RULESET ID=\"1\">\n");
  fprintf(f, "<GLOBAL>\n");
  fprintf(f, "<PREF NAME=\"Duration\">1000</PREF>\n");
  fprintf(f, "<PREF NAME=\"Interval\">1</PREF>\n");
  fprintf(f, "<ACTION NAME=\"count\"></ACTION>\n");
  fprintf(f, "<EXPORT NAME=\"text_file\">\n");
  fprintf(f, "<PREF NAME=\"Filename\">/tmp/netmate-results</PREF>\n");
  fprintf(f, "</EXPORT>\n");
  fprintf(f, "</GLOBAL>\n");
  for (i = 1; i < n; i++) {
    fprintf(f, "<RULE ID=\"%d\">\n", i);
    fprintf(f, "<FILTER NAME=\"SrcIP\">%d.%d.%d.%d</FILTER>\n", getRandByte(),
            getRandByte(), getRandByte(), getRandByte());
    fprintf(f, "<FILTER NAME=\"DstIP\">%d.%d.%d.%d</FILTER>\n", getRandByte(),
            getRandByte(), getRandByte(), getRandByte());
    fprintf(f, "<FILTER NAME=\"Proto\">%d</FILTER>\n", getRandByte());
    fprintf(f, "<FILTER NAME=\"SrcPort\">%d</FILTER>\n", getRandWord());
    fprintf(f, "<FILTER NAME=\"DstPort\">%d</FILTER>\n", getRandWord());
    fprintf(f, "</RULE>\n");
  }
  fprintf(f, "<RULE ID=\"%d\">\n", n);
  fprintf(f, "<FILTER NAME=\"SrcIP\">192.168.60.1</FILTER>\n");
  fprintf(f, "<FILTER NAME=\"DstIP\">192.168.60.3</FILTER>\n");
  fprintf(f, "<FILTER NAME=\"Proto\">udp</FILTER>\n");
  fprintf(f, "<FILTER NAME=\"SrcPort\">1024</FILTER>\n");
  fprintf(f, "<FILTER NAME=\"DstPort\">1025</FILTER>\n");
  fprintf(f, "</RULE>\n");
  fprintf(f, "</RULESET>");
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1070 <srand48@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdfa(%rip),%rdx
call   10a0 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1293 <main+0xd3>
cmpl   $0x3f,-0x14(%rbp)
je     1287 <main+0xc7>
cmpl   $0x68,-0x14(%rbp)
je     1287 <main+0xc7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x66,%eax
je     1266 <main+0xa6>
jmp    123f <main+0x7f>
mov    -0x2c(%rbp),%eax
sub    $0x6e,%eax
jne    127d <main+0xbd>
jmp    1250 <main+0x90>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    1282 <main+0xc2>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   10e0 <strdup@plt>
mov    %rax,-0x20(%rbp)
jmp    1282 <main+0xc2>
jmp    1282 <main+0xc2>
jmp    128e <main+0xce>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    11f8 <main+0x38>
cmpq   $0x0,-0x20(%rbp)
jne    12af <main+0xef>
mov    $0x0,%al
call   1080 <usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xd4d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xda2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    14c0 <main+0x300>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x6c(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x68(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x64(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    -0x78(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x64(%rbp),%r8d
mov    %eax,%r9d
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    %eax,%r9d
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1050 <getRandByte@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%edx
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   10b0 <getRandWord@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%edx
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   10b0 <getRandWord@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd3b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    137e <main+0x1be>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xc48(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd0f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd29(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd54(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xcac(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1070 <srand48@plt>
lea    0xe0b(%rip),%r15
mov    0x2dfc(%rip),%r14
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    121c <main+0x4c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x3f,%eax
jne    124a <main+0x7a>
xor    %eax,%eax
call   1080 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10a0 <getopt@plt>
cmp    $0x65,%eax
jle    1210 <main+0x40>
cmp    $0x68,%eax
je     1215 <main+0x45>
cmp    $0x66,%eax
je     1251 <main+0x81>
cmp    $0x6e,%eax
jne    121c <main+0x4c>
mov    (%r14),%edi
call   10c0 <atoi@plt>
mov    %eax,%r13d
jmp    121c <main+0x4c>
cmp    $0xffffffff,%eax
jne    121c <main+0x4c>
jmp    125e <main+0x8e>
mov    (%r14),%edi
call   10f0 <strdup@plt>
mov    %rax,%r12
jmp    121c <main+0x4c>
test   %r12,%r12
je     157b <main+0x3ab>
lea    0xd99(%rip),%rsi
mov    %r12,%rdi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xd89(%rip),%rdi
mov    $0x29,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
lea    0xd9a(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd93(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd84(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd8e(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd95(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd9c(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd9e(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xdb8(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xdaa(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
cmp    $0x2,%r13d
jl     149f <main+0x2cf>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
lea    0xd7c(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %r13d,%ebx
mov    %eax,%r13d
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %r14,%rdi
lea    0xd51(%rip),%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %ebx,%r13d
mov    %r15d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %r14,%rdi
lea    0xd38(%rip),%rsi
mov    %r15d,%edx
mov    %r12d,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1050 <getRandByte@plt>
mov    %r14,%rdi
lea    0xd3f(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   10b0 <getRandWord@plt>
mov    %r14,%rdi
lea    0xd47(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   10b0 <getRandWord@plt>
mov    %r14,%rdi
lea    0xd51(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x8,%esi
mov    $0x1,%edx
lea    0xd5b(%rip),%rdi
mov    %r14,%rcx
call   10e0 <fwrite@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    1390 <main+0x1c0>
lea    0xc70(%rip),%rsi
mov    %r14,%rdi
mov    %r13d,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xd35(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd48(%rip),%rdi
mov    $0x2b,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd5b(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd65(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd72(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xcaf(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
lea    0xd66(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1080 <usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"n:f:h?\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [42 x i8] c"<!DOCTYPE RULESET SYSTEM \22rulefile.dtd\22>\0A\00"
@.str.3 = [18 x i8] c"<RULESET ID=\221\22>\0A\00"
@.str.4 = [10 x i8] c"<GLOBAL>\0A\00"
@.str.5 = [35 x i8] c"<PREF NAME=\22Duration\22>1000</PREF>\0A\00"
@.str.6 = [32 x i8] c"<PREF NAME=\22Interval\22>1</PREF>\0A\00"
@.str.7 = [32 x i8] c"<ACTION NAME=\22count\22></ACTION>\0A\00"
@.str.8 = [27 x i8] c"<EXPORT NAME=\22text_file\22>\0A\00"
@.str.9 = [51 x i8] c"<PREF NAME=\22Filename\22>/tmp/netmate-results</PREF>\0A\00"
@.str.10 = [11 x i8] c"</EXPORT>\0A\00"
@.str.11 = [11 x i8] c"</GLOBAL>\0A\00"
@.str.12 = [16 x i8] c"<RULE ID=\22%d\22>\0A\00"
@.str.13 = [43 x i8] c"<FILTER NAME=\22SrcIP\22>%d.%d.%d.%d</FILTER>\0A\00"
@.str.14 = [43 x i8] c"<FILTER NAME=\22DstIP\22>%d.%d.%d.%d</FILTER>\0A\00"
@.str.15 = [34 x i8] c"<FILTER NAME=\22Proto\22>%d</FILTER>\0A\00"
@.str.16 = [36 x i8] c"<FILTER NAME=\22SrcPort\22>%d</FILTER>\0A\00"
@.str.17 = [36 x i8] c"<FILTER NAME=\22DstPort\22>%d</FILTER>\0A\00"
@.str.18 = [9 x i8] c"</RULE>\0A\00"
@.str.19 = [44 x i8] c"<FILTER NAME=\22SrcIP\22>192.168.60.1</FILTER>\0A\00"
@.str.20 = [44 x i8] c"<FILTER NAME=\22DstIP\22>192.168.60.3</FILTER>\0A\00"
@.str.21 = [35 x i8] c"<FILTER NAME=\22Proto\22>udp</FILTER>\0A\00"
@.str.22 = [38 x i8] c"<FILTER NAME=\22SrcPort\22>1024</FILTER>\0A\00"
@.str.23 = [38 x i8] c"<FILTER NAME=\22DstPort\22>1025</FILTER>\0A\00"
@.str.24 = [11 x i8] c"</RULESET>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8* null, i8** %8
%10 = call i32 @time(i32* null)
%11 = call i32 @srand48(i32 %10)
br label %12
12: ; preds = %35, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %36
17: ; preds = %12
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 63
br i1 %19, label %20, label %33
20: ; preds = %17
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 104
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %6
switch i32 %24, label %31 [
i32 110, label %25
i32 102, label %28
]
25: ; preds = %23
%26 = load i32, i32* @optarg
%27 = call i32 @atoi(i32 %26)
store i32 %27, i32* %7
br label %32
28: ; preds = %23
%29 = load i32, i32* @optarg
%30 = call i8* @strdup(i32 %29)
store i8* %30, i8** %8
br label %32
31: ; preds = %23
br label %32
32: ; preds = %31, %28, %25
br label %35
33: ; preds = %20, %17
%34 = call i32 (...) @usage()
br label %35
35: ; preds = %33, %32
br label %12
36: ; preds = %12
%37 = load i8*, i8** %8
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 (...) @usage()
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %36
%43 = load i8*, i8** %8
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %44, i32** %9
%45 = load i32*, i32** %9
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32*, i32** %9
%48 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%49 = load i32*, i32** %9
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %49, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%51 = load i32*, i32** %9
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
%53 = load i32*, i32** %9
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%55 = load i32*, i32** %9
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
%57 = load i32*, i32** %9
%58 = call i32 (i32*, i8*, ...) @fprintf(i32* %57, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%59 = load i32*, i32** %9
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0))
%61 = load i32*, i32** %9
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %61, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%63 = load i32*, i32** %9
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %6
br label %65
65: ; preds = %96, %42
%66 = load i32, i32* %6
%67 = load i32, i32* %7
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %99
69: ; preds = %65
%70 = load i32*, i32** %9
%71 = load i32, i32* %6
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %70, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %71)
%73 = load i32*, i32** %9
%74 = call i32 (...) @getRandByte()
%75 = call i32 (...) @getRandByte()
%76 = call i32 (...) @getRandByte()
%77 = call i32 (...) @getRandByte()
%78 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.13, i64 0, i64 0), i32 %74, i32 %75, i32 %76, i32 %77)
%79 = load i32*, i32** %9
%80 = call i32 (...) @getRandByte()
%81 = call i32 (...) @getRandByte()
%82 = call i32 (...) @getRandByte()
%83 = call i32 (...) @getRandByte()
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %79, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i32 %80, i32 %81, i32 %82, i32 %83)
%85 = load i32*, i32** %9
%86 = call i32 (...) @getRandByte()
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i32 %86)
%88 = load i32*, i32** %9
%89 = call i32 (...) @getRandWord()
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0), i32 %89)
%91 = load i32*, i32** %9
%92 = call i32 (...) @getRandWord()
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i32 %92)
%94 = load i32*, i32** %9
%95 = call i32 (i32*, i8*, ...) @fprintf(i32* %94, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0))
br label %96
96: ; preds = %69
%97 = load i32, i32* %6
%98 = add nsw i32 %97, 1
store i32 %98, i32* %6
br label %65
99: ; preds = %65
%100 = load i32*, i32** %9
%101 = load i32, i32* %7
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %101)
%103 = load i32*, i32** %9
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0))
%105 = load i32*, i32** %9
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %105, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0))
%107 = load i32*, i32** %9
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.21, i64 0, i64 0))
%109 = load i32*, i32** %9
%110 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0))
%111 = load i32*, i32** %9
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0))
%113 = load i32*, i32** %9
%114 = call i32 (i32*, i8*, ...) @fprintf(i32* %113, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0))
%115 = load i32*, i32** %9
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0))
%117 = load i32*, i32** %9
%118 = call i32 @fclose(i32* %117)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"n:f:h?\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [42 x i8] c"<!DOCTYPE RULESET SYSTEM \22rulefile.dtd\22>\0A\00"
@.str.3 = [18 x i8] c"<RULESET ID=\221\22>\0A\00"
@.str.4 = [10 x i8] c"<GLOBAL>\0A\00"
@.str.5 = [35 x i8] c"<PREF NAME=\22Duration\22>1000</PREF>\0A\00"
@.str.6 = [32 x i8] c"<PREF NAME=\22Interval\22>1</PREF>\0A\00"
@.str.7 = [32 x i8] c"<ACTION NAME=\22count\22></ACTION>\0A\00"
@.str.8 = [27 x i8] c"<EXPORT NAME=\22text_file\22>\0A\00"
@.str.9 = [51 x i8] c"<PREF NAME=\22Filename\22>/tmp/netmate-results</PREF>\0A\00"
@.str.10 = [11 x i8] c"</EXPORT>\0A\00"
@.str.11 = [11 x i8] c"</GLOBAL>\0A\00"
@.str.12 = [16 x i8] c"<RULE ID=\22%d\22>\0A\00"
@.str.13 = [43 x i8] c"<FILTER NAME=\22SrcIP\22>%d.%d.%d.%d</FILTER>\0A\00"
@.str.14 = [43 x i8] c"<FILTER NAME=\22DstIP\22>%d.%d.%d.%d</FILTER>\0A\00"
@.str.15 = [34 x i8] c"<FILTER NAME=\22Proto\22>%d</FILTER>\0A\00"
@.str.16 = [36 x i8] c"<FILTER NAME=\22SrcPort\22>%d</FILTER>\0A\00"
@.str.17 = [36 x i8] c"<FILTER NAME=\22DstPort\22>%d</FILTER>\0A\00"
@.str.18 = [9 x i8] c"</RULE>\0A\00"
@.str.19 = [44 x i8] c"<FILTER NAME=\22SrcIP\22>192.168.60.1</FILTER>\0A\00"
@.str.20 = [44 x i8] c"<FILTER NAME=\22DstIP\22>192.168.60.3</FILTER>\0A\00"
@.str.21 = [35 x i8] c"<FILTER NAME=\22Proto\22>udp</FILTER>\0A\00"
@.str.22 = [38 x i8] c"<FILTER NAME=\22SrcPort\22>1024</FILTER>\0A\00"
@.str.23 = [38 x i8] c"<FILTER NAME=\22DstPort\22>1025</FILTER>\0A\00"
@.str.24 = [11 x i8] c"</RULESET>\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand48(i32 %3)
br label %5
5: ; preds = %13, %2
%6 = phi i32 [ %15, %13 ], [ 0, %2 ]
%7 = phi i8* [ %9, %13 ], [ null, %2 ]
br label %8
8: ; preds = %5, %16
%9 = phi i8* [ %7, %5 ], [ %18, %16 ]
br label %10
10: ; preds = %12, %8
%11 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %11, label %12 [
i32 -1, label %21
i32 104, label %19
i32 63, label %19
i32 110, label %13
i32 102, label %16
]
12: ; preds = %10, %19
br label %10
13: ; preds = %10
%14 = load i32, i32* @optarg
%15 = tail call i32 @atoi(i32 %14)
br label %5
16: ; preds = %10
%17 = load i32, i32* @optarg
%18 = tail call i8* @strdup(i32 %17)
br label %8
19: ; preds = %10, %10
%20 = tail call i32 (...) @usage()
br label %12
21: ; preds = %10
%22 = icmp eq i8* %9, null
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = tail call i32 (...) @usage()
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %21
%27 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i64 @fwrite(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i64 41, i64 1, i32* %27)
%29 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i64 17, i64 1, i32* %27)
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i64 9, i64 1, i32* %27)
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i64 34, i64 1, i32* %27)
%32 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i64 31, i64 1, i32* %27)
%33 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i64 31, i64 1, i32* %27)
%34 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i64 26, i64 1, i32* %27)
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), i64 50, i64 1, i32* %27)
%36 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0), i64 10, i64 1, i32* %27)
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i64 10, i64 1, i32* %27)
%38 = icmp sgt i32 %6, 1
br i1 %38, label %39, label %61
39: ; preds = %26, %39
%40 = phi i32 [ %59, %39 ], [ 1, %26 ]
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %40)
%42 = tail call i32 (...) @getRandByte()
%43 = tail call i32 (...) @getRandByte()
%44 = tail call i32 (...) @getRandByte()
%45 = tail call i32 (...) @getRandByte()
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.13, i64 0, i64 0), i32 %42, i32 %43, i32 %44, i32 %45)
%47 = tail call i32 (...) @getRandByte()
%48 = tail call i32 (...) @getRandByte()
%49 = tail call i32 (...) @getRandByte()
%50 = tail call i32 (...) @getRandByte()
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i32 %47, i32 %48, i32 %49, i32 %50)
%52 = tail call i32 (...) @getRandByte()
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0), i32 %52)
%54 = tail call i32 (...) @getRandWord()
%55 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0), i32 %54)
%56 = tail call i32 (...) @getRandWord()
%57 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.17, i64 0, i64 0), i32 %56)
%58 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i64 8, i64 1, i32* %27)
%59 = add nuw nsw i32 %40, 1
%60 = icmp eq i32 %59, %6
br i1 %60, label %61, label %39
61: ; preds = %39, %26
%62 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i32 %6)
%63 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.19, i64 0, i64 0), i64 43, i64 1, i32* %27)
%64 = tail call i64 @fwrite(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.20, i64 0, i64 0), i64 43, i64 1, i32* %27)
%65 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.21, i64 0, i64 0), i64 34, i64 1, i32* %27)
%66 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.22, i64 0, i64 0), i64 37, i64 1, i32* %27)
%67 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.23, i64 0, i64 0), i64 37, i64 1, i32* %27)
%68 = tail call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i64 8, i64 1, i32* %27)
%69 = tail call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.24, i64 0, i64 0), i64 10, i64 1, i32* %27)
%70 = tail call i32 @fclose(i32* %27)
ret i32 0
}