#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(char *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char Input[102400] = {0};
  int substrs = 0;
  int n = 0;
  int passes = 0;
  int NumStrs = 0;
  char *src = NULL;
  char *dest = NULL;
  char *tmp = NULL;
  char Ans_Arrays[2][102400] = {0};
  char Characters[3] = {0};
  char Strings[3][102400] = {0};
  char *destwlkr;
  char *srcwlkr;
  srcwlkr = src = Ans_Arrays[0];
  destwlkr = dest = Ans_Arrays[1];
  fp = fopen(argv[1], "r");
  while (!feof(fp) && (NumStrs < 3)) {
    if (fgets(Input, 102400, fp) == NULL)
      continue;
    Input[strlen(Input) - 2] = '\0';
    switch (Input[0]) {
    case 'n':
      n = atoi(&Input[2]);
      break;
    case 'w':
      strcpy(src, &Input[2]);
      break;
    default:
      Characters[NumStrs] = Input[0];
      strcpy(Strings[NumStrs], &Input[2]);
      NumStrs++;
      break;
    }
  }
  printf("Number of passes: n=%d\n", n);
  printf("Initial String: w = %s\n", src);
  printf("Substitution Strings:\n");
  for (substrs = 0; substrs < NumStrs; substrs++)
    printf("                       %c = %s\n", Characters[substrs],
           Strings[substrs]);
  printf("\n");
  for (passes = 0; passes < n; passes++) {
    printf("Pass %d = %s\n", passes, srcwlkr);
    while (*srcwlkr != '\0') {
      for (substrs = 0; substrs < NumStrs; substrs++) {
        if (*srcwlkr == Characters[substrs]) {
          strcpy(destwlkr, Strings[substrs]);
          destwlkr += strlen(Strings[substrs]);
          *destwlkr = '\0';
          substrs = NumStrs + 1;
        }
      }
      if (substrs == NumStrs) {
        *destwlkr = *srcwlkr;
        *(destwlkr + 1) = '\0';
        destwlkr++;
      }
      srcwlkr++;
    }
    tmp = src;
    srcwlkr = src = dest;
    destwlkr = dest = tmp;
  }
  printf("\n");
  printf("Results = %s\n", src);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x96080,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x19020(%rbp),%rdi
xor    %esi,%esi
mov    $0x19000,%edx
call   1060 <memset@plt>
movl   $0x0,-0x19024(%rbp)
movl   $0x0,-0x19028(%rbp)
movl   $0x0,-0x1902c(%rbp)
movl   $0x0,-0x19030(%rbp)
movq   $0x0,-0x19038(%rbp)
movq   $0x0,-0x19040(%rbp)
movq   $0x0,-0x19048(%rbp)
lea    -0x4b050(%rbp),%rdi
xor    %esi,%esi
mov    $0x32000,%edx
call   1060 <memset@plt>
lea    -0x4b053(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1060 <memset@plt>
lea    -0x96060(%rbp),%rdi
xor    %esi,%esi
mov    $0x4b000,%edx
call   1060 <memset@plt>
lea    -0x4b050(%rbp),%rax
mov    %rax,-0x19038(%rbp)
mov    %rax,-0x96070(%rbp)
lea    -0x4b050(%rbp),%rax
add    $0x19000,%rax
mov    %rax,-0x19040(%rbp)
mov    %rax,-0x96068(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd93(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x96071(%rbp)
jne    12a2 <main+0x122>
cmpl   $0x3,-0x19030(%rbp)
setl   %al
mov    %al,-0x96071(%rbp)
mov    -0x96071(%rbp),%al
test   $0x1,%al
jne    12b5 <main+0x135>
jmp    13a8 <main+0x228>
lea    -0x19020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x19000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    12d9 <main+0x159>
jmp    1276 <main+0xf6>
lea    -0x19020(%rbp),%rdi
call   1040 <strlen@plt>
add    $0xfffffffe,%eax
cltq
movb   $0x0,-0x19020(%rbp,%rax,1)
movsbl -0x19020(%rbp),%eax
mov    %eax,-0x96078(%rbp)
sub    $0x6e,%eax
je     1321 <main+0x1a1>
jmp    130d <main+0x18d>
mov    -0x96078(%rbp),%eax
sub    $0x77,%eax
je     133c <main+0x1bc>
jmp    1358 <main+0x1d8>
lea    -0x19020(%rbp),%rdi
add    $0x2,%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x19028(%rbp)
jmp    13a3 <main+0x223>
mov    -0x19038(%rbp),%rdi
lea    -0x19020(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
jmp    13a3 <main+0x223>
mov    -0x19020(%rbp),%cl
movslq -0x19030(%rbp),%rax
mov    %cl,-0x4b053(%rbp,%rax,1)
movslq -0x19030(%rbp),%rax
lea    -0x96060(%rbp),%rdi
imul   $0x19000,%rax,%rax
add    %rax,%rdi
lea    -0x19020(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
mov    -0x19030(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19030(%rbp)
jmp    1276 <main+0xf6>
mov    -0x19028(%rbp),%esi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x19038(%rbp),%rsi
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x19024(%rbp)
mov    -0x19024(%rbp),%eax
cmp    -0x19030(%rbp),%eax
jge    1444 <main+0x2c4>
movslq -0x19024(%rbp),%rax
movsbl -0x4b053(%rbp,%rax,1),%esi
ff
movslq -0x19024(%rbp),%rax
lea    -0x96060(%rbp),%rdx
imul   $0x19000,%rax,%rax
add    %rax,%rdx
lea    0xc20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x19024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19024(%rbp)
jmp    13e9 <main+0x269>
lea    0xbfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1902c(%rbp)
mov    -0x1902c(%rbp),%eax
cmp    -0x19028(%rbp),%eax
jge    1606 <main+0x486>
mov    -0x1902c(%rbp),%esi
mov    -0x96070(%rbp),%rdx
lea    0xbe7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x96070(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     15ba <main+0x43a>
movl   $0x0,-0x19024(%rbp)
mov    -0x19024(%rbp),%eax
cmp    -0x19030(%rbp),%eax
jge    1562 <main+0x3e2>
mov    -0x96070(%rbp),%rax
movsbl (%rax),%eax
movslq -0x19024(%rbp),%rcx
movsbl -0x4b053(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
jne    1549 <main+0x3c9>
mov    -0x96068(%rbp),%rdi
movslq -0x19024(%rbp),%rax
lea    -0x96060(%rbp),%rsi
imul   $0x19000,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
movslq -0x19024(%rbp),%rax
lea    -0x96060(%rbp),%rdi
imul   $0x19000,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x96068(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x96068(%rbp)
mov    -0x96068(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x19030(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19024(%rbp)
jmp    154e <main+0x3ce>
mov    -0x19024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19024(%rbp)
jmp    14a6 <main+0x326>
mov    -0x19024(%rbp),%eax
cmp    -0x19030(%rbp),%eax
jne    15a3 <main+0x423>
mov    -0x96070(%rbp),%rax
mov    (%rax),%cl
mov    -0x96068(%rbp),%rax
mov    %cl,(%rax)
mov    -0x96068(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x96068(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x96068(%rbp)
mov    -0x96070(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x96070(%rbp)
jmp    1489 <main+0x309>
mov    -0x19038(%rbp),%rax
mov    %rax,-0x19048(%rbp)
mov    -0x19040(%rbp),%rax
mov    %rax,-0x19038(%rbp)
mov    %rax,-0x96070(%rbp)
mov    -0x19048(%rbp),%rax
mov    %rax,-0x19040(%rbp)
mov    %rax,-0x96068(%rbp)
mov    -0x1902c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1902c(%rbp)
jmp    145c <main+0x2dc>
lea    0xa3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x19038(%rbp),%rsi
lea    0xa55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x96080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x96028,%rsp
mov    %rsi,%rbx
lea    0x20(%rsp),%r14
movl   $0x0,0xc(%rsp)
mov    $0x19000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
lea    0x19020(%rsp),%r15
mov    $0x32000,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
movb   $0x0,0xa(%rsp)
movw   $0x0,0x8(%rsp)
lea    0x4b020(%rsp),%rbp
mov    $0x4b000,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    0x8(%rbx),%rdi
lea    0xdeb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0x22(%rsp),%r13
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    12c2 <main+0x122>
cmp    $0x2,%r12d
jg     12c2 <main+0x122>
mov    %r14,%rdi
mov    $0x19000,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1230 <main+0x90>
mov    %r14,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x2(%rax,%r14,1)
movzbl 0x20(%rsp),%eax
movsbl %al,%ecx
cmp    $0x77,%ecx
jne    1285 <main+0xe5>
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
jmp    1230 <main+0x90>
cmp    $0x6e,%ecx
jne    1298 <main+0xf8>
mov    %r13,%rdi
call   10c0 <atoi@plt>
mov    %eax,0xc(%rsp)
jmp    1230 <main+0x90>
movslq %r12d,%rcx
mov    %al,0x8(%rsp,%rcx,1)
imul   $0x19000,%rcx,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x4b020,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r12d
jmp    1230 <main+0x90>
lea    0xd39(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd3f(%rip),%rdi
lea    0x19020(%rsp),%r13
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd7a(%rip),%rdi
call   1050 <puts@plt>
test   %r12d,%r12d
jle    1332 <main+0x192>
mov    %r12d,%r15d
lea    0xd2a(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl 0x8(%rsp,%rbx,1),%esi
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbx
add    $0x19000,%rbp
cmp    %rbx,%r15
jne    1310 <main+0x170>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    143c <main+0x29c>
lea    0x32020(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0x19020(%rsp),%rbx
lea    0x1(%r12),%r15d
xor    %ebp,%ebp
jmp    1385 <main+0x1e5>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    0x18(%rsp),%r13
mov    %r13,%rbx
cmp    0xc(%rsp),%ebp
je     143c <main+0x29c>
mov    0x10(%rsp),%rcx
mov    %rcx,0x18(%rsp)
lea    0xcbc(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,0x10(%rsp)
mov    (%rbx),%cl
test   %cl,%cl
je     1370 <main+0x1d0>
mov    0x10(%rsp),%r13
mov    0x18(%rsp),%rbx
jmp    13cc <main+0x22c>
nopl   0x0(%rax)
mov    0x1(%r13),%cl
add    $0x1,%r13
test   %cl,%cl
je     1370 <main+0x1d0>
xor    %eax,%eax
test   %r12d,%r12d
jg     13e5 <main+0x245>
jmp    1427 <main+0x287>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x0(%r13),%ecx
movslq %eax,%rdx
cmp    0x8(%rsp,%rdx,1),%cl
jne    141f <main+0x27f>
imul   $0x19000,%rdx,%rax
lea    (%rsp,%rax,1),%r14
add    $0x4b020,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,(%rbx,%rax,1)
add    %rax,%rbx
mov    %r15d,%eax
add    $0x1,%eax
cmp    %r12d,%eax
jl     13e0 <main+0x240>
cmp    %r12d,%eax
jne    13c0 <main+0x220>
mov    0x0(%r13),%al
mov    %al,(%rbx)
movb   $0x0,0x1(%rbx)
add    $0x1,%rbx
jmp    13c0 <main+0x220>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc13(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x96028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Number of passes: n=%d\0A\00"
@.str.2 = [24 x i8] c"Initial String: w = %s\0A\00"
@.str.3 = [23 x i8] c"Substitution Strings:\0A\00"
@.str.4 = [32 x i8] c" %c = %s\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [14 x i8] c"Pass %d = %s\0A\00"
@.str.7 = [14 x i8] c"Results = %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [102400 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [2 x [102400 x i8]]
%16 = alloca [3 x i8]
%17 = alloca [3 x [102400 x i8]]
%18 = alloca i8*
%19 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = bitcast [102400 x i8]* %7 to i8*
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8* null, i8** %12
store i8* null, i8** %13
store i8* null, i8** %14
%21 = bitcast [2 x [102400 x i8]]* %15 to i8*
%22 = bitcast [3 x i8]* %16 to i8*
%23 = bitcast [3 x [102400 x i8]]* %17 to i8*
%24 = getelementptr inbounds [2 x [102400 x i8]], [2 x [102400 x i8]]* %15, i64 0, i64 0
%25 = getelementptr inbounds [102400 x i8], [102400 x i8]* %24, i64 0, i64 0
store i8* %25, i8** %12
store i8* %25, i8** %19
%26 = getelementptr inbounds [2 x [102400 x i8]], [2 x [102400 x i8]]* %15, i64 0, i64 1
%27 = getelementptr inbounds [102400 x i8], [102400 x i8]* %26, i64 0, i64 0
store i8* %27, i8** %13
store i8* %27, i8** %18
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %31, i32** %6
br label %32
32: ; preds = %77, %46, %2
%33 = load i32*, i32** %6
%34 = call i32 @feof(i32* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %32
%37 = load i32, i32* %11
%38 = icmp slt i32 %37, 3
br label %39
39: ; preds = %36, %32
%40 = phi i1 [ false, %32 ], [ %38, %36 ]
br i1 %40, label %41, label %78
41: ; preds = %39
%42 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%43 = load i32*, i32** %6
%44 = call i32* @fgets(i8* %42, i32 102400, i32* %43)
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %47
46: ; preds = %41
br label %32
47: ; preds = %41
%48 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = sub nsw i32 %49, 2
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 %51
store i8 0, i8* %52
%53 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
switch i32 %55, label %63 [
i32 110, label %56
i32 119, label %59
]
56: ; preds = %47
%57 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 2
%58 = call i32 @atoi(i8* %57)
store i32 %58, i32* %9
br label %77
59: ; preds = %47
%60 = load i8*, i8** %12
%61 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 2
%62 = call i32 @strcpy(i8* %60, i8* %61)
br label %77
63: ; preds = %47
%64 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%65 = load i8, i8* %64
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 %67
store i8 %65, i8* %68
%69 = load i32, i32* %11
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %17, i64 0, i64 %70
%72 = getelementptr inbounds [102400 x i8], [102400 x i8]* %71, i64 0, i64 0
%73 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 2
%74 = call i32 @strcpy(i8* %72, i8* %73)
%75 = load i32, i32* %11
%76 = add nsw i32 %75, 1
store i32 %76, i32* %11
br label %77
77: ; preds = %63, %59, %56
br label %32
78: ; preds = %39
%79 = load i32, i32* %9
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %79)
%81 = load i8*, i8** %12
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %84
84: ; preds = %99, %78
%85 = load i32, i32* %8
%86 = load i32, i32* %11
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %102
88: ; preds = %84
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = load i32, i32* %8
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %17, i64 0, i64 %95
%97 = getelementptr inbounds [102400 x i8], [102400 x i8]* %96, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %93, i8* %97)
br label %99
99: ; preds = %88
%100 = load i32, i32* %8
%101 = add nsw i32 %100, 1
store i32 %101, i32* %8
br label %84
102: ; preds = %84
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %10
br label %104
104: ; preds = %173, %102
%105 = load i32, i32* %10
%106 = load i32, i32* %9
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %176
108: ; preds = %104
%109 = load i32, i32* %10
%110 = load i8*, i8** %19
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %109, i8* %110)
br label %112
112: ; preds = %166, %108
%113 = load i8*, i8** %19
%114 = load i8, i8* %113
%115 = sext i8 %114 to i32
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %169
117: ; preds = %112
store i32 0, i32* %8
br label %118
118: ; preds = %151, %117
%119 = load i32, i32* %8
%120 = load i32, i32* %11
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %154
122: ; preds = %118
%123 = load i8*, i8** %19
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = load i32, i32* %8
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [3 x i8], [3 x i8]* %16, i64 0, i64 %127
%129 = load i8, i8* %128
%130 = sext i8 %129 to i32
%131 = icmp eq i32 %125, %130
br i1 %131, label %132, label %150
132: ; preds = %122
%133 = load i8*, i8** %18
%134 = load i32, i32* %8
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %17, i64 0, i64 %135
%137 = getelementptr inbounds [102400 x i8], [102400 x i8]* %136, i64 0, i64 0
%138 = call i32 @strcpy(i8* %133, i8* %137)
%139 = load i32, i32* %8
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %17, i64 0, i64 %140
%142 = getelementptr inbounds [102400 x i8], [102400 x i8]* %141, i64 0, i64 0
%143 = call i32 @strlen(i8* %142)
%144 = load i8*, i8** %18
%145 = sext i32 %143 to i64
%146 = getelementptr inbounds i8, i8* %144, i64 %145
store i8* %146, i8** %18
%147 = load i8*, i8** %18
store i8 0, i8* %147
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %8
br label %150
150: ; preds = %132, %122
br label %151
151: ; preds = %150
%152 = load i32, i32* %8
%153 = add nsw i32 %152, 1
store i32 %153, i32* %8
br label %118
154: ; preds = %118
%155 = load i32, i32* %8
%156 = load i32, i32* %11
%157 = icmp eq i32 %155, %156
br i1 %157, label %158, label %166
158: ; preds = %154
%159 = load i8*, i8** %19
%160 = load i8, i8* %159
%161 = load i8*, i8** %18
store i8 %160, i8* %161
%162 = load i8*, i8** %18
%163 = getelementptr inbounds i8, i8* %162, i64 1
store i8 0, i8* %163
%164 = load i8*, i8** %18
%165 = getelementptr inbounds i8, i8* %164, i32 1
store i8* %165, i8** %18
br label %166
166: ; preds = %158, %154
%167 = load i8*, i8** %19
%168 = getelementptr inbounds i8, i8* %167, i32 1
store i8* %168, i8** %19
br label %112
169: ; preds = %112
%170 = load i8*, i8** %12
store i8* %170, i8** %14
%171 = load i8*, i8** %13
store i8* %171, i8** %12
store i8* %171, i8** %19
%172 = load i8*, i8** %14
store i8* %172, i8** %13
store i8* %172, i8** %18
br label %173
173: ; preds = %169
%174 = load i32, i32* %10
%175 = add nsw i32 %174, 1
store i32 %175, i32* %10
br label %104
176: ; preds = %104
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%178 = load i8*, i8** %12
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %178)
%180 = load i32, i32* %3
ret i32 %180
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [24 x i8] c"Number of passes: n=%d\0A\00"
@.str.2 = [24 x i8] c"Initial String: w = %s\0A\00"
@.str.4 = [32 x i8] c" %c = %s\0A\00"
@.str.6 = [14 x i8] c"Pass %d = %s\0A\00"
@.str.7 = [14 x i8] c"Results = %s\0A\00"
@str = [22 x i8] c"Substitution Strings:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [102400 x i8]
%4 = alloca [2 x [102400 x i8]]
%5 = alloca [3 x i8]
%6 = alloca [3 x [102400 x i8]]
%7 = getelementptr inbounds [102400 x i8], [102400 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [2 x [102400 x i8]], [2 x [102400 x i8]]* %4, i64 0, i64 0, i64 0
%9 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %6, i64 0, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [102400 x i8], [102400 x i8]* %3, i64 0, i64 2
br label %15
15: ; preds = %36, %2
%16 = phi i32 [ %37, %36 ], [ 0, %2 ]
%17 = phi i32 [ %19, %36 ], [ 0, %2 ]
br label %18
18: ; preds = %15, %40
%19 = phi i32 [ %17, %15 ], [ %45, %40 ]
%20 = icmp slt i32 %19, 3
br label %21
21: ; preds = %18, %38
br label %22
22: ; preds = %21, %26
%23 = call i32 @feof(i32* %13)
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i1 %20, i1 false
br i1 %25, label %26, label %46
26: ; preds = %22
%27 = call i32* @fgets(i8* %7, i32 102400, i32* %13)
%28 = icmp eq i32* %27, null
br i1 %28, label %22, label %29
29: ; preds = %26
%30 = call i32 @strlen(i8* %7)
%31 = add nsw i32 %30, -2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [102400 x i8], [102400 x i8]* %3, i64 0, i64 %32
store i8 0, i8* %33
%34 = load i8, i8* %7
%35 = sext i8 %34 to i32
switch i32 %35, label %40 [
i32 110, label %36
i32 119, label %38
]
36: ; preds = %29
%37 = call i32 @atoi(i8* %14)
br label %15
38: ; preds = %29
%39 = call i32 @strcpy(i8* %8, i8* %14)
br label %21
40: ; preds = %29
%41 = sext i32 %19 to i64
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %41
store i8 %34, i8* %42
%43 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %6, i64 0, i64 %41, i64 0
%44 = call i32 @strcpy(i8* %43, i8* %14)
%45 = add nsw i32 %19, 1
br label %18
46: ; preds = %22
%47 = getelementptr inbounds [2 x [102400 x i8]], [2 x [102400 x i8]]* %4, i64 0, i64 1, i64 0
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%51 = icmp sgt i32 %19, 0
br i1 %51, label %52, label %63
52: ; preds = %46
%53 = zext i32 %19 to i64
br label %54
54: ; preds = %52, %54
%55 = phi i64 [ 0, %52 ], [ %61, %54 ]
%56 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %6, i64 0, i64 %55, i64 0
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %58, i8* %59)
%61 = add nuw nsw i64 %55, 1
%62 = icmp eq i64 %61, %53
br i1 %62, label %63, label %54
63: ; preds = %54, %46
%64 = call i32 @putchar(i32 10)
%65 = icmp sgt i32 %16, 0
br i1 %65, label %66, label %115
66: ; preds = %63
%67 = add nsw i32 %19, 1
br label %68
68: ; preds = %66, %112
%69 = phi i8* [ %8, %66 ], [ %70, %112 ]
%70 = phi i8* [ %47, %66 ], [ %69, %112 ]
%71 = phi i32 [ 0, %66 ], [ %113, %112 ]
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %71, i8* %69)
%73 = load i8, i8* %69
%74 = icmp eq i8 %73, 0
br i1 %74, label %112, label %75
75: ; preds = %68, %107
%76 = phi i8 [ %110, %107 ], [ %73, %68 ]
%77 = phi i8* [ %109, %107 ], [ %69, %68 ]
%78 = phi i8* [ %108, %107 ], [ %70, %68 ]
br i1 %51, label %79, label %100
79: ; preds = %75, %98
%80 = phi i8 [ %99, %98 ], [ %76, %75 ]
%81 = phi i8* [ %95, %98 ], [ %78, %75 ]
%82 = phi i32 [ %96, %98 ], [ 0, %75 ]
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 %83
%85 = load i8, i8* %84
%86 = icmp eq i8 %80, %85
br i1 %86, label %87, label %93
87: ; preds = %79
%88 = getelementptr inbounds [3 x [102400 x i8]], [3 x [102400 x i8]]* %6, i64 0, i64 %83, i64 0
%89 = call i32 @strcpy(i8* %81, i8* %88)
%90 = call i32 @strlen(i8* %88)
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i8, i8* %81, i64 %91
store i8 0, i8* %92
br label %93
93: ; preds = %79, %87
%94 = phi i32 [ %67, %87 ], [ %82, %79 ]
%95 = phi i8* [ %92, %87 ], [ %81, %79 ]
%96 = add nsw i32 %94, 1
%97 = icmp slt i32 %96, %19
br i1 %97, label %98, label %100
98: ; preds = %93
%99 = load i8, i8* %77
br label %79
100: ; preds = %93, %75
%101 = phi i32 [ 0, %75 ], [ %96, %93 ]
%102 = phi i8* [ %78, %75 ], [ %95, %93 ]
%103 = icmp eq i32 %101, %19
br i1 %103, label %104, label %107
104: ; preds = %100
%105 = load i8, i8* %77
store i8 %105, i8* %102
%106 = getelementptr inbounds i8, i8* %102, i64 1
store i8 0, i8* %106
br label %107
107: ; preds = %104, %100
%108 = phi i8* [ %106, %104 ], [ %102, %100 ]
%109 = getelementptr inbounds i8, i8* %77, i64 1
%110 = load i8, i8* %109
%111 = icmp eq i8 %110, 0
br i1 %111, label %112, label %75
112: ; preds = %107, %68
%113 = add nuw nsw i32 %71, 1
%114 = icmp eq i32 %113, %16
br i1 %114, label %115, label %68
115: ; preds = %112, %63
%116 = phi i8* [ %8, %63 ], [ %70, %112 ]
%117 = call i32 @putchar(i32 10)
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %116)
ret i32 0
}