#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc < 3)
    return -1;
  FILE *f = fopen(argv[1], "r");
  if (f == NULL)
    return -1;
  FILE *fWrite = fopen(argv[2], "wb");
  int c = fgetc(f);
  while (c != EOF) {
    switch (c) {
    case '>':
    case '<':
    case '+':
    case '-':
    case '[':
    case ']':
    case '.':
    case ',':
    case '!':
    case '#': {
      fputc(c, fWrite);
      break;
    }
    }
    c = fgetc(f);
  }
  fclose(f);
  fclose(fWrite);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    116c <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1284 <main+0x144>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119b <main+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1284 <main+0x144>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%eax
je     126b <main+0x12b>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x21,%eax
je     124e <main+0x10e>
jmp    11e5 <main+0xa5>
mov    -0x28(%rbp),%eax
sub    $0x23,%eax
je     124e <main+0x10e>
jmp    11f6 <main+0xb6>
mov    -0x28(%rbp),%eax
add    $0xffffffd5,%eax
sub    $0x4,%eax
jb     124e <main+0x10e>
jmp    120a <main+0xca>
mov    -0x28(%rbp),%eax
sub    $0x3c,%eax
je     124e <main+0x10e>
jmp    121b <main+0xdb>
mov    -0x28(%rbp),%eax
sub    $0x3e,%eax
je     124e <main+0x10e>
jmp    122c <main+0xec>
mov    -0x28(%rbp),%eax
sub    $0x5b,%eax
je     124e <main+0x10e>
jmp    123d <main+0xfd>
mov    -0x28(%rbp),%eax
sub    $0x5d,%eax
jne    125a <main+0x11a>
jmp    124e <main+0x10e>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x24(%rbp)
jmp    11bf <main+0x7f>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
cmp    $0x3,%edi
jl     11e7 <main+0xa7>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e7 <main+0xa7>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    0x2e56(%rip),%rbp
cmp    0x0(%rbp),%eax
je     11d5 <main+0x95>
movabs $0x1400000028003c05,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x21(%rax),%ecx
cmp    $0x3c,%ecx
ja     11c8 <main+0x88>
bt     %rcx,%r15
jae    11c8 <main+0x88>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%eax
jne    11b0 <main+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"wb\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%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 slt i32 %9, 3
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %45
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 -1, i32* %3
br label %45
20: ; preds = %12
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** %6
%26 = call i32 @fgetc(i32* %25)
store i32 %26, i32* %8
br label %27
27: ; preds = %37, %20
%28 = load i32, i32* %8
%29 = load i32, i32* @EOF
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32, i32* %8
switch i32 %32, label %37 [
i32 62, label %33
i32 60, label %33
i32 43, label %33
i32 45, label %33
i32 91, label %33
i32 93, label %33
i32 46, label %33
i32 44, label %33
i32 33, label %33
i32 35, label %33
]
33: ; preds = %31, %31, %31, %31, %31, %31, %31, %31, %31, %31
%34 = load i32, i32* %8
%35 = load i32*, i32** %7
%36 = call i32 @fputc(i32 %34, i32* %35)
br label %37
37: ; preds = %31, %33
%38 = load i32*, i32** %6
%39 = call i32 @fgetc(i32* %38)
store i32 %39, i32* %8
br label %27
40: ; preds = %27
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
store i32 0, i32* %3
br label %45
45: ; preds = %40, %19, %11
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"wb\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %27, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %27, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @fgetc(i32* %7)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %24, label %16
16: ; preds = %9, %20
%17 = phi i32 [ %21, %20 ], [ %13, %9 ]
switch i32 %17, label %20 [
i32 62, label %18
i32 60, label %18
i32 43, label %18
i32 45, label %18
i32 91, label %18
i32 93, label %18
i32 46, label %18
i32 44, label %18
i32 33, label %18
i32 35, label %18
]
18: ; preds = %16, %16, %16, %16, %16, %16, %16, %16, %16, %16
%19 = tail call i32 @fputc(i32 %17, i32* %12)
br label %20
20: ; preds = %16, %18
%21 = tail call i32 @fgetc(i32* %7)
%22 = load i32, i32* @EOF
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %16
24: ; preds = %20, %9
%25 = tail call i32 @fclose(i32* %7)
%26 = tail call i32 @fclose(i32* %12)
br label %27
27: ; preds = %24, %4, %2
%28 = phi i32 [ -1, %2 ], [ 0, %24 ], [ -1, %4 ]
ret i32 %28
}