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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ removeSubstr(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int main() {
  int y;
  FILE *data;
  char action;
  char line[100];
  int counter = 0;
  char keyword[] = "";
  int result, index = 0;
  struct rule {
    char keyword1[100];
    char keyword2[100];
  } ruleset[10];
  if ((data = fopen("rule", "r")) != NULL) {
    while (fgets(line, sizeof(line), data)) {
      if ((strcmp(line, keyword))) {
        char s[10] = "$,";
        char *token = strtok(line, s);
        while (token != NULL) {
          if (counter == 1) {
            strcpy(ruleset[index].keyword1, token);
          }
          if (counter == 2) {
            strcpy(ruleset[index].keyword2, token);
            index++;
          }
          counter++;
          token = strtok(NULL, s);
        }
      }
    }
  }
  for (y = 0; y < index; y++) {
    removeSubstr(ruleset[y].keyword1, "ARGS|XML:/* \"");
    removeSubstr(ruleset[y].keyword1, "RGS_NAMES|");
    printf("%s ", ruleset[y].keyword1);
    removeSubstr(ruleset[y].keyword2, "\" \"phase:2");
    printf("%s", ruleset[y].keyword2);
    printf("\n");
  }
  fclose(data);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x84(%rbp)
lea    -0x85(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <memset@plt>
movl   $0x0,-0x90(%rbp)
lea    0xe30(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1315 <main+0x185>
jmp    11ef <main+0x5f>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1310 <main+0x180>
lea    -0x80(%rbp),%rdi
lea    -0x85(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     130b <main+0x17b>
mov    0xe08(%rip),%rax
mov    %rax,-0x86a(%rbp)
mov    0xe02(%rip),%ax
mov    %ax,-0x862(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0x86a(%rbp),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x878(%rbp)
cmpq   $0x0,-0x878(%rbp)
je     1306 <main+0x176>
cmpl   $0x1,-0x84(%rbp)
jne    1297 <main+0x107>
movslq -0x90(%rbp),%rax
lea    -0x860(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
mov    -0x878(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x2,-0x84(%rbp)
jne    12db <main+0x14b>
movslq -0x90(%rbp),%rax
lea    -0x860(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
add    $0x64,%rdi
mov    -0x878(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
lea    -0x86a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x878(%rbp)
jmp    1258 <main+0xc8>
jmp    130b <main+0x17b>
jmp    11ef <main+0x5f>
jmp    1315 <main+0x185>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x90(%rbp),%eax
jge    13f8 <main+0x268>
movslq -0x8(%rbp),%rax
lea    -0x860(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
lea    0xcc0(%rip),%rsi
call   1030 <removeSubstr@plt>
movslq -0x8(%rbp),%rax
lea    -0x860(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
lea    0xcad(%rip),%rsi
call   1030 <removeSubstr@plt>
movslq -0x8(%rbp),%rax
lea    -0x860(%rbp),%rsi
imul   $0xc8,%rax,%rax
add    %rax,%rsi
lea    0xc97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x8(%rbp),%rax
lea    -0x860(%rbp),%rdi
imul   $0xc8,%rax,%rax
add    %rax,%rdi
add    $0x64,%rdi
lea    0xc74(%rip),%rsi
call   1030 <removeSubstr@plt>
movslq -0x8(%rbp),%rax
lea    -0x860(%rbp),%rsi
imul   $0xc8,%rax,%rax
add    %rax,%rsi
add    $0x64,%rsi
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    131c <main+0x18c>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x1,%eax
add    $0x880,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x868,%rsp
movb   $0x0,0xf(%rsp)
lea    0xe53(%rip),%rdi
lea    0xe51(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1322 <main+0x192>
lea    0x20(%rsp),%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1322 <main+0x192>
xor    %ebp,%ebp
lea    0x20(%rsp),%r12
lea    0xf(%rsp),%r15
lea    0x10(%rsp),%r13
xor    %ebx,%ebx
jmp    1219 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     129b <main+0x10b>
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1200 <main+0x70>
movw   $0x0,0x18(%rsp)
movq   $0x2c24,0x10(%rsp)
mov    %r12,%rdi
jmp    1265 <main+0xd5>
xchg   %ax,%ax
movslq %ebp,%rbp
imul   $0xc8,%rbp,%rcx
lea    (%rsp,%rcx,1),%rdi
add    $0xf4,%rdi
mov    %rax,%rsi
call   1050 <strcpy@plt>
add    $0x1,%ebp
add    $0x1,%ebx
xor    %edi,%edi
mov    %r13,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1200 <main+0x70>
cmp    $0x2,%ebx
je     1240 <main+0xb0>
cmp    $0x1,%ebx
jne    1260 <main+0xd0>
movslq %ebp,%rcx
imul   $0xc8,%rcx,%rcx
lea    (%rsp,%rcx,1),%rdi
add    $0x90,%rdi
mov    %rax,%rsi
call   1050 <strcpy@plt>
jmp    1260 <main+0xd0>
test   %ebp,%ebp
jle    1322 <main+0x192>
mov    %ebp,%r13d
lea    0x90(%rsp),%rbx
lea    0xd6f(%rip),%rbp
lea    0xd73(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xd3d(%rip),%rsi
call   1030 <removeSubstr@plt>
mov    %rbx,%rdi
lea    0xd3c(%rip),%rsi
call   1030 <removeSubstr@plt>
lea    0xd3b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x64(%rbx),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
call   1030 <removeSubstr@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0xc8,%rbx
add    $0xffffffffffffffff,%r13
jne    12c0 <main+0x130>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    $0x1,%eax
add    $0x868,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.rule = type { [100 x i8], [100 x i8] }
@.str = [5 x i8] c"rule\00"
@.str.1 = [2 x i8] c"r\00"
@__const.main.s = [10 x i8] c"$,\00\00\00\00\00\00\00\00"
@.str.2 = [14 x i8] c"ARGS|XML:/* \22\00"
@.str.3 = [11 x i8] c"RGS_NAMES|\00"
@.str.4 = [4 x i8] c"%s \00"
@.str.5 = [11 x i8] c"\22 \22phase:2\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca [1 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x %struct.rule]
%11 = alloca [10 x i8]
%12 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %6
%13 = bitcast [1 x i8]* %7 to i8*
store i32 0, i32* %9
%14 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %14, i32** %3
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %67
16: ; preds = %0
br label %17
17: ; preds = %65, %16
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i64 @fgets(i8* %18, i32 100, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %66
22: ; preds = %17
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [1 x i8], [1 x i8]* %7, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %65
27: ; preds = %22
%28 = bitcast [10 x i8]* %11 to i8*
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%31 = call i8* @strtok(i8* %29, i8* %30)
store i8* %31, i8** %12
br label %32
32: ; preds = %59, %27
%33 = load i8*, i8** %12
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %64
35: ; preds = %32
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %40
%42 = getelementptr inbounds %struct.rule, %struct.rule* %41, i32 0, i32 0
%43 = getelementptr inbounds [100 x i8], [100 x i8]* %42, i64 0, i64 0
%44 = load i8*, i8** %12
%45 = call i32 @strcpy(i8* %43, i8* %44)
br label %46
46: ; preds = %38, %35
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 2
br i1 %48, label %49, label %59
49: ; preds = %46
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %51
%53 = getelementptr inbounds %struct.rule, %struct.rule* %52, i32 0, i32 1
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %53, i64 0, i64 0
%55 = load i8*, i8** %12
%56 = call i32 @strcpy(i8* %54, i8* %55)
%57 = load i32, i32* %9
%58 = add nsw i32 %57, 1
store i32 %58, i32* %9
br label %59
59: ; preds = %49, %46
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%63 = call i8* @strtok(i8* null, i8* %62)
store i8* %63, i8** %12
br label %32
64: ; preds = %32
br label %65
65: ; preds = %64, %22
br label %17
66: ; preds = %17
br label %67
67: ; preds = %66, %0
store i32 0, i32* %2
br label %68
68: ; preds = %104, %67
%69 = load i32, i32* %2
%70 = load i32, i32* %9
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %107
72: ; preds = %68
%73 = load i32, i32* %2
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %74
%76 = getelementptr inbounds %struct.rule, %struct.rule* %75, i32 0, i32 0
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %76, i64 0, i64 0
%78 = call i32 @removeSubstr(i8* %77, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* %2
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %80
%82 = getelementptr inbounds %struct.rule, %struct.rule* %81, i32 0, i32 0
%83 = getelementptr inbounds [100 x i8], [100 x i8]* %82, i64 0, i64 0
%84 = call i32 @removeSubstr(i8* %83, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%85 = load i32, i32* %2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %86
%88 = getelementptr inbounds %struct.rule, %struct.rule* %87, i32 0, i32 0
%89 = getelementptr inbounds [100 x i8], [100 x i8]* %88, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %89)
%91 = load i32, i32* %2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %92
%94 = getelementptr inbounds %struct.rule, %struct.rule* %93, i32 0, i32 1
%95 = getelementptr inbounds [100 x i8], [100 x i8]* %94, i64 0, i64 0
%96 = call i32 @removeSubstr(i8* %95, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%97 = load i32, i32* %2
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %10, i64 0, i64 %98
%100 = getelementptr inbounds %struct.rule, %struct.rule* %99, i32 0, i32 1
%101 = getelementptr inbounds [100 x i8], [100 x i8]* %100, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %101)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %104
104: ; preds = %72
%105 = load i32, i32* %2
%106 = add nsw i32 %105, 1
store i32 %106, i32* %2
br label %68
107: ; preds = %68
%108 = load i32*, i32** %3
%109 = call i32 @fclose(i32* %108)
ret i32 1
}

LLVM IR (-O2):
%struct.rule = type { [100 x i8], [100 x i8] }
@.str = [5 x i8] c"rule\00"
@.str.1 = [2 x i8] c"r\00"
@__const.main.s = [10 x i8] c"$,\00\00\00\00\00\00\00\00"
@.str.2 = [14 x i8] c"ARGS|XML:/* \22\00"
@.str.3 = [11 x i8] c"RGS_NAMES|\00"
@.str.4 = [4 x i8] c"%s \00"
@.str.5 = [11 x i8] c"\22 \22phase:2\00"
@.str.6 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [1 x i8]
%3 = alloca [10 x %struct.rule]
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %2, i64 0, i64 0
store i8 0, i8* %6
%7 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %3, i64 0, i64 0, i32 0, i64 0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %65, label %10
10: ; preds = %0
%11 = call i64 @fgets(i8* %5, i32 100, i32* %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %65, label %13
13: ; preds = %10
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
br label %15
15: ; preds = %13, %44
%16 = phi i32 [ 0, %13 ], [ %46, %44 ]
%17 = phi i32 [ 0, %13 ], [ %45, %44 ]
%18 = call i64 @strcmp(i8* %5, i8* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %44, label %20
20: ; preds = %15
%21 = call i8* @strtok(i8* %5, i8* %14)
%22 = icmp eq i8* %21, null
br i1 %22, label %41, label %23
23: ; preds = %20, %36
%24 = phi i8* [ %39, %36 ], [ %21, %20 ]
%25 = phi i32 [ %37, %36 ], [ %16, %20 ]
%26 = phi i32 [ %38, %36 ], [ %17, %20 ]
switch i32 %26, label %36 [
i32 1, label %27
i32 2, label %31
]
27: ; preds = %23
%28 = sext i32 %25 to i64
%29 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %3, i64 0, i64 %28, i32 0, i64 0
%30 = call i32 @strcpy(i8* %29, i8* %24)
br label %36
31: ; preds = %23
%32 = sext i32 %25 to i64
%33 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %3, i64 0, i64 %32, i32 1, i64 0
%34 = call i32 @strcpy(i8* %33, i8* %24)
%35 = add nsw i32 %25, 1
br label %36
36: ; preds = %27, %23, %31
%37 = phi i32 [ %35, %31 ], [ %25, %27 ], [ %25, %23 ]
%38 = add nsw i32 %26, 1
%39 = call i8* @strtok(i8* null, i8* %14)
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %23
41: ; preds = %36, %20
%42 = phi i32 [ %17, %20 ], [ %38, %36 ]
%43 = phi i32 [ %16, %20 ], [ %37, %36 ]
br label %44
44: ; preds = %41, %15
%45 = phi i32 [ %42, %41 ], [ %17, %15 ]
%46 = phi i32 [ %43, %41 ], [ %16, %15 ]
%47 = call i64 @fgets(i8* %5, i32 100, i32* %8)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %15
49: ; preds = %44
%50 = icmp sgt i32 %46, 0
br i1 %50, label %51, label %65
51: ; preds = %49
%52 = zext i32 %46 to i64
br label %53
53: ; preds = %51, %53
%54 = phi i64 [ 0, %51 ], [ %63, %53 ]
%55 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %3, i64 0, i64 %54, i32 0, i64 0
%56 = call i32 @removeSubstr(i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%57 = call i32 @removeSubstr(i8* %55, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%59 = getelementptr inbounds [10 x %struct.rule], [10 x %struct.rule]* %3, i64 0, i64 %54, i32 1, i64 0
%60 = call i32 @removeSubstr(i8* %59, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %59)
%62 = call i32 @putchar(i32 10)
%63 = add nuw nsw i64 %54, 1
%64 = icmp eq i64 %63, %52
br i1 %64, label %65, label %53
65: ; preds = %53, %10, %0, %49
%66 = call i32 @fclose(i32* %8)
ret i32 1
}