#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: bnc file.txt\n");
    return -1;
  }
  FILE *fp;
  fp = fopen(argv[1], "r");
  if (fp == NULL) {
    fprintf(stderr, "ERROR: Cannot open file %s\n", argv[1]);
    return -1;
  }
  char buffer[128];
  int i;
  while (!feof(fp)) {
    fgets(buffer, 128, fp);
    for (i = 0; i < 128; i++) {
      switch (buffer[i]) {
      case 'l':
        if (buffer[i - 1] == ' ') {
          printf("lud");
        }
        break;
      case 's':
        printf("d");
        break;
      case 'z':
        printf("d");
        break;
      default:
        printf("%c", buffer[i]);
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1196 <main+0x46>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x1c1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe70(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e4 <main+0x94>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x1c1>
jmp    11e9 <main+0x99>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1207 <main+0xb7>
jmp    1311 <main+0x1c1>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1040 <fgets@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x80,-0xa4(%rbp)
jge    130c <main+0x1bc>
movslq -0xa4(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
mov    %eax,-0xa8(%rbp)
sub    $0x6c,%eax
je     1281 <main+0x131>
jmp    1259 <main+0x109>
mov    -0xa8(%rbp),%eax
sub    $0x73,%eax
je     12b0 <main+0x160>
jmp    126d <main+0x11d>
mov    -0xa8(%rbp),%eax
sub    $0x7a,%eax
je     12c3 <main+0x173>
jmp    12d6 <main+0x186>
mov    -0xa4(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0xa0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    12ab <main+0x15b>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f3 <main+0x1a3>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f3 <main+0x1a3>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f3 <main+0x1a3>
movslq -0xa4(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%esi
ff
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f8 <main+0x1a8>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1226 <main+0xd6>
jmp    11e9 <main+0x99>
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x88,%rsp
cmp    $0x2,%edi
jne    119e <main+0x3e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe94(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b7 <main+0x57>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11e6 <main+0x86>
xor    %eax,%eax
jmp    11d7 <main+0x77>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11d2 <main+0x72>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%r14
lea    0xe43(%rip),%r12
jmp    120c <main+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    119a <main+0x3a>
mov    %r14,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
xor    %ebx,%ebx
jmp    1237 <main+0xd7>
mov    $0x64,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
je     1200 <main+0xa0>
movsbl (%rsp,%rbx,1),%edi
cmp    $0x7a,%edi
je     1220 <main+0xc0>
cmp    $0x73,%edi
je     1220 <main+0xc0>
cmp    $0x6c,%edi
jne    1225 <main+0xc5>
cmpb   $0x20,-0x1(%rsp,%rbx,1)
jne    122a <main+0xca>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122a <main+0xca>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: bnc file.txt\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"ERROR: Cannot open file %s\0A\00"
@.str.3 = [4 x i8] c"lud\00"
@.str.4 = [2 x i8] c"d\00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [128 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %73
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = load i32*, i32** %6
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 -1, i32* %3
br label %73
27: ; preds = %14
br label %28
28: ; preds = %72, %27
%29 = load i32*, i32** %6
%30 = call i32 @feof(i32* %29)
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %33, label %73
33: ; preds = %28
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%35 = load i32*, i32** %6
%36 = call i32 @fgets(i8* %34, i32 128, i32* %35)
store i32 0, i32* %8
br label %37
37: ; preds = %69, %33
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 128
br i1 %39, label %40, label %72
40: ; preds = %37
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
switch i32 %45, label %61 [
i32 108, label %46
i32 115, label %57
i32 122, label %59
]
46: ; preds = %40
%47 = load i32, i32* %8
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 32
br i1 %53, label %54, label %56
54: ; preds = %46
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54, %46
br label %68
57: ; preds = %40
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %68
59: ; preds = %40
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %68
61: ; preds = %40
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %61, %59, %57, %56
br label %69
69: ; preds = %68
%70 = load i32, i32* %8
%71 = add nsw i32 %70, 1
store i32 %71, i32* %8
br label %37
72: ; preds = %37
br label %28
73: ; preds = %11, %21, %28
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Usage: bnc file.txt\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"ERROR: Cannot open file %s\0A\00"
@.str.3 = [4 x i8] c"lud\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %48
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %48
17: ; preds = %8
%18 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%19 = call i32 @feof(i32* %11)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %47
21: ; preds = %44
%22 = call i32 @feof(i32* %11)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %47
24: ; preds = %17, %21
%25 = call i32 @fgets(i8* %18, i32 128, i32* %11)
br label %26
26: ; preds = %24, %44
%27 = phi i64 [ 0, %24 ], [ %45, %44 ]
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
switch i32 %30, label %42 [
i32 108, label %31
i32 115, label %38
i32 122, label %40
]
31: ; preds = %26
%32 = add nsw i64 %27, -1
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 32
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %44
38: ; preds = %26
%39 = call i32 @putchar(i32 100)
br label %44
40: ; preds = %26
%41 = call i32 @putchar(i32 100)
br label %44
42: ; preds = %26
%43 = call i32 @putchar(i32 %30)
br label %44
44: ; preds = %38, %40, %42, %36, %31
%45 = add nuw nsw i64 %27, 1
%46 = icmp eq i64 %45, 128
br i1 %46, label %21, label %26
47: ; preds = %21, %17
br label %48
48: ; preds = %13, %47, %5
%49 = phi i32 [ -1, %5 ], [ -1, %13 ], [ 0, %47 ]
ret i32 %49
}