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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *stderr;
int main(const int argc, const char **argv) {
  const char *filename = (argc == 1 ? "ProgramCodes.txt" : argv[1]);
  FILE *ifile = fopen(filename, "rb"), *ofile;
  char buff[200], prev_code[5];
  if (!ifile) {
    fprintf(stderr, "Couldn't open %s\n", filename);
    return (-1);
  }
  memset(prev_code, 0, sizeof(prev_code));
  ofile = fopen("progcode.txt", "wb");
  while (fgets(buff, sizeof(buff), ifile))
    if (buff[0] > ' ' && buff[1] > ' ' && buff[2] > ' ' && buff[3] == ' ' &&
        buff[4] > ' ' && buff[5] == ' ' && buff[6] > ' ') {
      if (memcmp(prev_code, buff, 5)) {
        fprintf(ofile, "\nCOD %.5s\n", buff);
        memcpy(prev_code, buff, 5);
      }
      fprintf(ofile, "OBS %s", buff + 6);
    }
  fclose(ifile);
  fclose(ofile);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11a6 <main+0x36>
lea    0xe66(%rip),%rax
mov    %rax,-0x100(%rbp)
jmp    11b5 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x100(%rbp)
mov    -0x100(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1205 <main+0x95>
mov    0x2dfa(%rip),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1348 <main+0x1d8>
lea    -0xf5(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    0xe07(%rip),%rdi
lea    0xe0d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xc8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     132f <main+0x1bf>
movsbl -0xf0(%rbp),%eax
cmp    $0x20,%eax
jle    132a <main+0x1ba>
movsbl -0xef(%rbp),%eax
cmp    $0x20,%eax
jle    132a <main+0x1ba>
movsbl -0xee(%rbp),%eax
cmp    $0x20,%eax
jle    132a <main+0x1ba>
movsbl -0xed(%rbp),%eax
cmp    $0x20,%eax
jne    132a <main+0x1ba>
movsbl -0xec(%rbp),%eax
cmp    $0x20,%eax
jle    132a <main+0x1ba>
movsbl -0xeb(%rbp),%eax
cmp    $0x20,%eax
jne    132a <main+0x1ba>
movsbl -0xea(%rbp),%eax
cmp    $0x20,%eax
jle    132a <main+0x1ba>
lea    -0xf5(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     130f <main+0x19f>
mov    -0x28(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
lea    0xd44(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0xf5(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    $0x5,%edx
call   1080 <memcpy@plt>
mov    -0x28(%rbp),%rdi
lea    -0xf0(%rbp),%rdx
add    $0x6,%rdx
lea    0xd1c(%rip),%rsi
call   1070 <fprintf@plt>
jmp    122f <main+0xbf>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
cmp    $0x1,%edi
jne    118f <main+0x1f>
lea    0xe73(%rip),%rbp
jmp    1193 <main+0x23>
mov    0x8(%rsi),%rbp
lea    0xe77(%rip),%rsi
mov    %rbp,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     12b4 <main+0x144>
mov    %rax,%rbx
lea    0xb(%rsp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1040 <memset@plt>
lea    0xe60(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r13
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12a0 <main+0x130>
lea    0x16(%rsp),%r15
lea    0xb(%rsp),%r12
lea    0x10(%rsp),%rbp
lea    0xe3b(%rip),%r14
jmp    1233 <main+0xc3>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <fprintf@plt>
mov    %rbp,%rdi
mov    $0xc8,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12a0 <main+0x130>
cmpb   $0x21,0x10(%rsp)
jl     121e <main+0xae>
cmpb   $0x21,0x11(%rsp)
jl     121e <main+0xae>
cmpb   $0x21,0x12(%rsp)
jl     121e <main+0xae>
cmpb   $0x20,0x13(%rsp)
jne    121e <main+0xae>
cmpb   $0x21,0x14(%rsp)
jl     121e <main+0xae>
cmpb   $0x20,0x15(%rsp)
jne    121e <main+0xae>
cmpb   $0x21,0x16(%rsp)
jl     121e <main+0xae>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     1210 <main+0xa0>
mov    %r13,%rdi
lea    0xdb3(%rip),%rsi
mov    %rbp,%rdx
call   1070 <fprintf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x5,%edx
call   1080 <memcpy@plt>
jmp    1210 <main+0xa0>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12d2 <main+0x162>
mov    0x2d25(%rip),%rax
mov    (%rax),%rdi
lea    0xd4f(%rip),%rsi
mov    %rbp,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"ProgramCodes.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32* null
@.str.2 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.3 = [13 x i8] c"progcode.txt\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [11 x i8] c"\0ACOD %.5s\0A\00"
@.str.6 = [7 x i8] c"OBS %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca [200 x i8]
%10 = alloca [5 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %2
br label %18
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
br label %18
18: ; preds = %14, %13
%19 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %13 ], [ %17, %14 ]
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %7
%22 = load i32*, i32** %7
%23 = icmp ne i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = load i32*, i32** @stderr
%26 = load i8*, i8** %6
%27 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 -1, i32* %3
br label %95
28: ; preds = %18
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%30 = call i32 @memset(i8* %29, i32 0, i32 5)
%31 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %31, i32** %8
br label %32
32: ; preds = %89, %28
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%34 = load i32*, i32** %7
%35 = call i64 @fgets(i8* %33, i32 200, i32* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %90
37: ; preds = %32
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp sgt i32 %40, 32
br i1 %41, label %42, label %89
42: ; preds = %37
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 1
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp sgt i32 %45, 32
br i1 %46, label %47, label %89
47: ; preds = %42
%48 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 2
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp sgt i32 %50, 32
br i1 %51, label %52, label %89
52: ; preds = %47
%53 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 3
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 32
br i1 %56, label %57, label %89
57: ; preds = %52
%58 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 4
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp sgt i32 %60, 32
br i1 %61, label %62, label %89
62: ; preds = %57
%63 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 5
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 32
br i1 %66, label %67, label %89
67: ; preds = %62
%68 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 6
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp sgt i32 %70, 32
br i1 %71, label %72, label %89
72: ; preds = %67
%73 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%74 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%75 = call i64 @memcmp(i8* %73, i8* %74, i32 5)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %84
77: ; preds = %72
%78 = load i32*, i32** %8
%79 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%80 = call i32 @fprintf(i32* %78, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %79)
%81 = getelementptr inbounds [5 x i8], [5 x i8]* %10, i64 0, i64 0
%82 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%83 = call i32 @memcpy(i8* %81, i8* %82, i32 5)
br label %84
84: ; preds = %77, %72
%85 = load i32*, i32** %8
%86 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%87 = getelementptr inbounds i8, i8* %86, i64 6
%88 = call i32 @fprintf(i32* %85, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %84, %67, %62, %57, %52, %47, %42, %37
br label %32
90: ; preds = %32
%91 = load i32*, i32** %7
%92 = call i32 @fclose(i32* %91)
%93 = load i32*, i32** %8
%94 = call i32 @fclose(i32* %93)
store i32 0, i32* %3
br label %95
95: ; preds = %90, %24
%96 = load i32, i32* %3
ret i32 %96
}

LLVM IR (-O2):
@.str = [17 x i8] c"ProgramCodes.txt\00"
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32* null
@.str.2 = [18 x i8] c"Couldn't open %s\0A\00"
@.str.3 = [13 x i8] c"progcode.txt\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [11 x i8] c"\0ACOD %.5s\0A\00"
@.str.6 = [7 x i8] c"OBS %s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = alloca [5 x i8]
%5 = icmp eq i32 %0, 1
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %8, %6 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%14 = icmp eq i32* %11, null
br i1 %14, label %15, label %18
15: ; preds = %9
%16 = load i32*, i32** @stderr
%17 = tail call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %65
18: ; preds = %9
%19 = call i32 @memset(i8* %13, i32 0, i32 5)
%20 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%21 = call i64 @fgets(i8* %12, i32 200, i32* %11)
%22 = icmp eq i64 %21, 0
br i1 %22, label %62, label %23
23: ; preds = %18
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 1
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 2
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 3
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 4
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 5
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 6
br label %30
30: ; preds = %23, %59
%31 = load i8, i8* %12
%32 = icmp sgt i8 %31, 32
%33 = load i8, i8* %24
%34 = icmp sgt i8 %33, 32
%35 = select i1 %32, i1 %34, i1 false
%36 = load i8, i8* %25
%37 = icmp sgt i8 %36, 32
%38 = select i1 %35, i1 %37, i1 false
%39 = load i8, i8* %26
%40 = icmp eq i8 %39, 32
%41 = select i1 %38, i1 %40, i1 false
%42 = load i8, i8* %27
%43 = icmp sgt i8 %42, 32
%44 = select i1 %41, i1 %43, i1 false
%45 = load i8, i8* %28
%46 = icmp eq i8 %45, 32
%47 = select i1 %44, i1 %46, i1 false
%48 = load i8, i8* %29
%49 = icmp sgt i8 %48, 32
%50 = select i1 %47, i1 %49, i1 false
br i1 %50, label %51, label %59
51: ; preds = %30
%52 = call i64 @memcmp(i8* %13, i8* %12, i32 5)
%53 = icmp eq i64 %52, 0
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%56 = call i32 @memcpy(i8* %13, i8* %12, i32 5)
br label %57
57: ; preds = %54, %51
%58 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %29)
br label %59
59: ; preds = %57, %30
%60 = call i64 @fgets(i8* %12, i32 200, i32* %11)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %30
62: ; preds = %59, %18
%63 = call i32 @fclose(i32* %11)
%64 = call i32 @fclose(i32* %20)
br label %65
65: ; preds = %62, %15
%66 = phi i32 [ 0, %62 ], [ -1, %15 ]
ret i32 %66
}