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

/* Variables and functions */
int atoi(char *);
char decode(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
char *strchr(char *, char);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  int val1, val2;
  char delims[] = " ";
  char *result = NULL;
  char line[256];
  int cnt, index = 0;
  unsigned char num0[10];
  ;
  unsigned char num1[10];
  char *nIndex = 0;
  FILE *f, *out;
  char dec;
  if (argc < 3) {
    printf("usage = %s fileName output\n", argv[0]);
    exit(0);
  }
  cnt = 0;
  memset(num0, 0, sizeof(num0));
  memset(num1, 0, sizeof(num1));
  f = fopen(argv[1], "r");
  out = fopen(argv[2], "w");
  while (fgets(line, 256, f) != NULL) {
    result = strtok(line, delims);
    index = 0;
    while (result != NULL) {
      if (index & 1) {
        if ((nIndex = strchr(result, '\n'))) {
          *nIndex = '\0';
        }
        val2 = atoi(result);
        dec = decode(val1, val2);
        if (dec == '[') {
          cnt++;
        } else if (dec == '0') {
          num0[cnt]++;
        } else if (dec == '1') {
          num1[cnt]++;
        }
        fprintf(out, "%c", dec);
      } else {
        val1 = atoi(result);
      }
      result = strtok(NULL, delims);
      index++;
    }
  }
  cnt++;
  fprintf(out, "]\n");
  fclose(f);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe30(%rip),%ax
mov    %ax,-0x1a(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x138(%rbp)
movq   $0x0,-0x158(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1215 <main+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
movl   $0x0,-0x134(%rbp)
lea    -0x142(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    -0x14c(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdca(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x160(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb1(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x168(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x160(%rbp),%rdx
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     13f8 <main+0x248>
lea    -0x130(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x138(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     13f3 <main+0x243>
mov    -0x138(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     13c2 <main+0x212>
mov    -0x28(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
mov    %rax,-0x158(%rbp)
cmp    $0x0,%rax
je     1301 <main+0x151>
mov    -0x158(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1090 <decode@plt>
mov    %al,-0x169(%rbp)
movsbl -0x169(%rbp),%eax
cmp    $0x5b,%eax
jne    1342 <main+0x192>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    13a1 <main+0x1f1>
movsbl -0x169(%rbp),%eax
cmp    $0x30,%eax
jne    136f <main+0x1bf>
movslq -0x134(%rbp),%rax
mov    -0x142(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x142(%rbp,%rax,1)
jmp    139c <main+0x1ec>
movsbl -0x169(%rbp),%eax
cmp    $0x31,%eax
jne    1397 <main+0x1e7>
movslq -0x134(%rbp),%rax
mov    -0x14c(%rbp,%rax,1),%cl
add    $0x1,%cl
mov    %cl,-0x14c(%rbp,%rax,1)
jmp    139c <main+0x1ec>
jmp    13a1 <main+0x1f1>
mov    -0x168(%rbp),%rdi
movsbl -0x169(%rbp),%edx
lea    0xc6c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13ce <main+0x21e>
mov    -0x28(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    -0x1a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x138(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x138(%rbp)
jmp    12bb <main+0x10b>
jmp    127b <main+0xcb>
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
mov    -0x168(%rbp),%rdi
lea    0xc10(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x160(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x168(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x138,%rsp
mov    %rsi,%rbx
movw   $0x20,0xe(%rsp)
cmp    $0x2,%edi
jle    135c <main+0x19c>
lea    0x26(%rsp),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
lea    0x1c(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <memset@plt>
mov    0x8(%rbx),%rdi
lea    0xe08(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xdf7(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
lea    0x30(%rsp),%rdi
mov    $0x100,%esi
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     131d <main+0x15d>
lea    0x30(%rsp),%rbx
lea    0xe(%rsp),%r13
jmp    1280 <main+0xc0>
nopl   0x0(%rax,%rax,1)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    0x10(%rsp),%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     131d <main+0x15d>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10b0 <strtok@plt>
test   %rax,%rax
je     1260 <main+0xa0>
mov    %rax,%rbx
xor    %r15d,%r15d
jmp    12c0 <main+0x100>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %r13,%rsi
call   10b0 <strtok@plt>
mov    %rax,%rbx
add    $0x1,%r15d
test   %rax,%rax
je     1260 <main+0xa0>
test   $0x1,%r15b
je     12a0 <main+0xe0>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     12db <main+0x11b>
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   10c0 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1090 <decode@plt>
cmp    $0x30,%al
je     1308 <main+0x148>
cmp    $0x31,%al
je     12fe <main+0x13e>
cmp    $0x5b,%al
jne    1310 <main+0x150>
add    $0x1,%r14d
jmp    1310 <main+0x150>
movslq %r14d,%rcx
addb   $0x1,0x1c(%rsp,%rcx,1)
jmp    1310 <main+0x150>
movslq %r14d,%rcx
addb   $0x1,0x26(%rsp,%rcx,1)
movsbl %al,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
jmp    12aa <main+0xea>
lea    0xcfc(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10e0 <fwrite@plt>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xc9a(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@__const.main.delims = [2 x i8] c" \00"
@.str = [28 x i8] c"usage = %s fileName output\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%c\00"
@.str.4 = [3 x i8] c"]\0A\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 [2 x i8]
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca [10 x i8]
%14 = alloca [10 x i8]
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = bitcast [2 x i8]* %8 to i8*
store i8* null, i8** %9
store i32 0, i32* %12
store i8* null, i8** %15
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 3
br i1 %21, label %22, label %28
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %2
store i32 0, i32* %11
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%30 = call i32 @memset(i8* %29, i32 0, i32 10)
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%32 = call i32 @memset(i8* %31, i32 0, i32 10)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %36, i32** %16
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %40, i32** %17
br label %41
41: ; preds = %110, %28
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%43 = load i32*, i32** %16
%44 = call i32* @fgets(i8* %42, i32 256, i32* %43)
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %111
46: ; preds = %41
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%49 = call i8* @strtok(i8* %47, i8* %48)
store i8* %49, i8** %9
store i32 0, i32* %12
br label %50
50: ; preds = %105, %46
%51 = load i8*, i8** %9
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %110
53: ; preds = %50
%54 = load i32, i32* %12
%55 = and i32 %54, 1
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %102
57: ; preds = %53
%58 = load i8*, i8** %9
%59 = call i8* @strchr(i8* %58, i8 signext 10)
store i8* %59, i8** %15
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = load i8*, i8** %15
store i8 0, i8* %62
br label %63
63: ; preds = %61, %57
%64 = load i8*, i8** %9
%65 = call i32 @atoi(i8* %64)
store i32 %65, i32* %7
%66 = load i32, i32* %6
%67 = load i32, i32* %7
%68 = call signext i8 @decode(i32 %66, i32 %67)
store i8 %68, i8* %18
%69 = load i8, i8* %18
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 91
br i1 %71, label %72, label %75
72: ; preds = %63
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %97
75: ; preds = %63
%76 = load i8, i8* %18
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 48
br i1 %78, label %79, label %85
79: ; preds = %75
%80 = load i32, i32* %11
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 %81
%83 = load i8, i8* %82
%84 = add i8 %83, 1
store i8 %84, i8* %82
br label %96
85: ; preds = %75
%86 = load i8, i8* %18
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 49
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = load i32, i32* %11
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = add i8 %93, 1
store i8 %94, i8* %92
br label %95
95: ; preds = %89, %85
br label %96
96: ; preds = %95, %79
br label %97
97: ; preds = %96, %72
%98 = load i32*, i32** %17
%99 = load i8, i8* %18
%100 = sext i8 %99 to i32
%101 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %100)
br label %105
102: ; preds = %53
%103 = load i8*, i8** %9
%104 = call i32 @atoi(i8* %103)
store i32 %104, i32* %6
br label %105
105: ; preds = %102, %97
%106 = getelementptr inbounds [2 x i8], [2 x i8]* %8, i64 0, i64 0
%107 = call i8* @strtok(i8* null, i8* %106)
store i8* %107, i8** %9
%108 = load i32, i32* %12
%109 = add nsw i32 %108, 1
store i32 %109, i32* %12
br label %50
110: ; preds = %50
br label %41
111: ; preds = %41
%112 = load i32, i32* %11
%113 = add nsw i32 %112, 1
store i32 %113, i32* %11
%114 = load i32*, i32** %17
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %114, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%116 = load i32*, i32** %16
%117 = call i32 @fclose(i32* %116)
%118 = load i32*, i32** %17
%119 = call i32 @fclose(i32* %118)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"usage = %s fileName output\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = alloca [256 x i8]
%5 = alloca [10 x i8]
%6 = alloca [10 x i8]
%7 = bitcast i16* %3 to i8*
store i16 32, i16* %3
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %2
%17 = call i32 @memset(i8* %9, i32 0, i32 10)
%18 = call i32 @memset(i8* %10, i32 0, i32 10)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32* @fgets(i8* %8, i32 256, i32* %21)
%26 = icmp eq i32* %25, null
br i1 %26, label %75, label %32
27: ; preds = %69, %32
%28 = phi i32 [ %34, %32 ], [ %70, %69 ]
%29 = phi i32 [ %33, %32 ], [ %71, %69 ]
%30 = call i32* @fgets(i8* %8, i32 256, i32* %21)
%31 = icmp eq i32* %30, null
br i1 %31, label %75, label %32
32: ; preds = %16, %27
%33 = phi i32 [ %29, %27 ], [ undef, %16 ]
%34 = phi i32 [ %28, %27 ], [ 0, %16 ]
%35 = call i8* @strtok(i8* %8, i8* %7)
%36 = icmp eq i8* %35, null
br i1 %36, label %27, label %37
37: ; preds = %32, %69
%38 = phi i32 [ %71, %69 ], [ %33, %32 ]
%39 = phi i8* [ %72, %69 ], [ %35, %32 ]
%40 = phi i32 [ %70, %69 ], [ %34, %32 ]
%41 = phi i32 [ %73, %69 ], [ 0, %32 ]
%42 = and i32 %41, 1
%43 = icmp eq i32 %42, 0
br i1 %43, label %67, label %44
44: ; preds = %37
%45 = call i8* @strchr(i8* %39, i8 signext 10)
%46 = icmp eq i8* %45, null
br i1 %46, label %48, label %47
47: ; preds = %44
store i8 0, i8* %45
br label %48
48: ; preds = %47, %44
%49 = call i32 @atoi(i8* %39)
%50 = call signext i8 @decode(i32 %38, i32 %49)
%51 = sext i8 %50 to i32
switch i8 %50, label %64 [
i8 91, label %52
i8 48, label %54
i8 49, label %59
]
52: ; preds = %48
%53 = add nsw i32 %40, 1
br label %64
54: ; preds = %48
%55 = sext i32 %40 to i64
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = add i8 %57, 1
store i8 %58, i8* %56
br label %64
59: ; preds = %48
%60 = sext i32 %40 to i64
%61 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = add i8 %62, 1
store i8 %63, i8* %61
br label %64
64: ; preds = %48, %54, %59, %52
%65 = phi i32 [ %53, %52 ], [ %40, %54 ], [ %40, %59 ], [ %40, %48 ]
%66 = call i32 @fputc(i32 %51, i32* %24)
br label %69
67: ; preds = %37
%68 = call i32 @atoi(i8* %39)
br label %69
69: ; preds = %67, %64
%70 = phi i32 [ %65, %64 ], [ %40, %67 ]
%71 = phi i32 [ %38, %64 ], [ %68, %67 ]
%72 = call i8* @strtok(i8* null, i8* %7)
%73 = add nuw nsw i32 %41, 1
%74 = icmp eq i8* %72, null
br i1 %74, label %27, label %37
75: ; preds = %27, %16
%76 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 2, i64 1, i32* %24)
%77 = call i32 @fclose(i32* %21)
%78 = call i32 @fclose(i32* %24)
ret i32 0
}