#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *saferead(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int main(int argc, char *argv[]) {
  FILE *f;
  char c;
  char *buf;
  int x = 0;
  if (argc < 2)
    f = stdin;
  else {
    f = fopen(argv[1], "r");
    if (f == NULL) {
      fprintf(stderr, "Could not read %s\n", argv[1]);
      exit(EXIT_FAILURE);
    }
  }
  buf = saferead(f);
  if (argc < 3)
    f = stdout;
  else
    f = fopen(argv[2], "w");
  while ((c = buf[x]) != 0) {
    if (!(c == '\n' || c == ' ' || c == '\t'))
      fputc((int)c, f);
    x++;
  }
  fclose(f);
  free(buf);
  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)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11aa <main+0x3a>
mov    0x2e4a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11fd <main+0x8d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe47(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f8 <main+0x88>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe1d(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    11fd <main+0x8d>
mov    -0x18(%rbp),%rdi
call   1070 <saferead@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1227 <main+0xb7>
mov    0x2dad(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    123f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddf(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
jmp    1244 <main+0xd4>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     12a0 <main+0x130>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     1292 <main+0x122>
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
je     1292 <main+0x122>
movsbl -0x19(%rbp),%eax
cmp    $0x9,%eax
je     1292 <main+0x122>
movsbl -0x19(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1244 <main+0xd4>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     118d <main+0x1d>
mov    0x2e68(%rip),%rax
mov    (%rax),%rdi
call   1070 <saferead@plt>
mov    %rax,%r14
jmp    11b7 <main+0x47>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     121c <main+0xac>
mov    %rax,%rdi
call   1070 <saferead@plt>
mov    %rax,%r14
cmp    $0x2,%ebp
ja     11c3 <main+0x53>
mov    0x2e0a(%rip),%rax
mov    (%rax),%rbx
jmp    11d6 <main+0x66>
mov    0x10(%rbx),%rdi
lea    0xe47(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rbp
jmp    11e4 <main+0x74>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
movzbl 0x0(%rbp),%eax
lea    -0x9(%rax),%ecx
cmp    $0x2,%cl
jb     11e0 <main+0x70>
cmp    $0x20,%al
je     11e0 <main+0x70>
test   %al,%al
je     1205 <main+0x95>
movsbl %al,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
jmp    11e0 <main+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdd2(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Could not read %s\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32* null
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32*, i32** @stdin
store i32* %13, i32** %6
br label %30
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, 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 %29
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 @fprintf(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %14
br label %30
30: ; preds = %29, %12
%31 = load i32*, i32** %6
%32 = call i8* @saferead(i32* %31)
store i8* %32, i8** %8
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 3
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i32*, i32** @stdout
store i32* %36, i32** %6
br label %42
37: ; preds = %30
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %41, i32** %6
br label %42
42: ; preds = %37, %35
br label %43
43: ; preds = %68, %42
%44 = load i8*, i8** %8
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
store i8 %48, i8* %7
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %71
51: ; preds = %43
%52 = load i8, i8* %7
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 10
br i1 %54, label %68, label %55
55: ; preds = %51
%56 = load i8, i8* %7
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 32
br i1 %58, label %68, label %59
59: ; preds = %55
%60 = load i8, i8* %7
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 9
br i1 %62, label %68, label %63
63: ; preds = %59
%64 = load i8, i8* %7
%65 = sext i8 %64 to i32
%66 = load i32*, i32** %6
%67 = call i32 @fputc(i32 %65, i32* %66)
br label %68
68: ; preds = %63, %59, %55, %51
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %43
71: ; preds = %43
%72 = load i32*, i32** %6
%73 = call i32 @fclose(i32* %72)
%74 = load i8*, i8** %8
%75 = call i32 @free(i8* %74)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"Could not read %s\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32* null
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32*, i32** @stdin
%6 = tail call i8* @saferead(i32* %5)
br label %21
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %7
%19 = tail call i8* @saferead(i32* %10)
%20 = icmp ult i32 %0, 3
br i1 %20, label %21, label %24
21: ; preds = %4, %18
%22 = phi i8* [ %6, %4 ], [ %19, %18 ]
%23 = load i32*, i32** @stdout
br label %28
24: ; preds = %18
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %24, %21
%29 = phi i8* [ %22, %21 ], [ %19, %24 ]
%30 = phi i32* [ %23, %21 ], [ %27, %24 ]
br label %31
31: ; preds = %38, %28
%32 = phi i64 [ %39, %38 ], [ 0, %28 ]
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i8, i8* %33
switch i8 %34, label %35 [
i8 0, label %40
i8 32, label %38
i8 10, label %38
i8 9, label %38
]
35: ; preds = %31
%36 = sext i8 %34 to i32
%37 = tail call i32 @fputc(i32 %36, i32* %30)
br label %38
38: ; preds = %31, %31, %31, %35
%39 = add nuw i64 %32, 1
br label %31
40: ; preds = %31
%41 = tail call i32 @fclose(i32* %30)
%42 = tail call i32 @free(i8* %29)
ret i32 0
}