#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ isspace(char);
int /*<<< orphan*/ process_line(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc != 3)
    usage();
  FILE *file_in = fopen(argv[1], "r");
  do {
    if (!file_in) {
      fprintf(stderr, "Could not open %s: %s\n", argv[1], strerror(errno));
      exit(1);
    }
  } while (0);
  FILE *file_out = fopen(argv[2], "w+");
  do {
    if (!file_out) {
      fprintf(stderr, "Could not open %s: %s\n", argv[2], strerror(errno));
      exit(1);
    }
  } while (0);
  char buffer[1024];
  char *buf;
  while (fgets(buffer, 1024, file_in) != NULL) {
    buf = buffer;
    while (*buf && isspace(*buf))
      buf++;
    switch (*buf) {
    case 'S':
      process_line(file_out, buf, buffer);
      break;
    case 'W':
    case '#':
    case 0:
      continue;
    default:
      do {
        if (1) {
          fprintf(stderr, "Don't know what to do with: %s\n", buffer);
          exit(1);
        }
      } while (0);
    }
  }
  fclose(file_in);
  fclose(file_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ba <main+0x2a>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1231 <main+0xa1>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x434(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x430(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rdx
mov    %rax,%rcx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1236 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12ad <main+0x11d>
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x444(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x440(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x444(%rbp),%edi
mov    -0x440(%rbp),%rdx
mov    %rax,%rcx
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12b2 <main+0x122>
jmp    12b7 <main+0x127>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     13f1 <main+0x261>
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x445(%rbp)
je     131b <main+0x18b>
mov    -0x428(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x445(%rbp)
mov    -0x445(%rbp),%al
test   $0x1,%al
jne    132e <main+0x19e>
jmp    1345 <main+0x1b5>
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
jmp    12e4 <main+0x154>
mov    -0x428(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x44c(%rbp)
test   %eax,%eax
je     13ba <main+0x22a>
jmp    1362 <main+0x1d2>
mov    -0x44c(%rbp),%eax
sub    $0x23,%eax
je     13ba <main+0x22a>
jmp    1376 <main+0x1e6>
mov    -0x44c(%rbp),%eax
sub    $0x53,%eax
je     139e <main+0x20e>
jmp    138a <main+0x1fa>
mov    -0x44c(%rbp),%eax
sub    $0x57,%eax
je     13ba <main+0x22a>
jmp    13bf <main+0x22f>
mov    -0x20(%rbp),%rdi
mov    -0x428(%rbp),%rsi
lea    -0x420(%rbp),%rdx
call   10b0 <process_line@plt>
jmp    13ec <main+0x25c>
jmp    12b7 <main+0x127>
jmp    13c4 <main+0x234>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    0xc41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    12b7 <main+0x127>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r15
cmp    $0x3,%edi
je     11ad <main+0x1d>
xor    %eax,%eax
call   1070 <usage@plt>
mov    0x8(%r15),%rdi
lea    0xe48(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12a2 <main+0x112>
mov    %rax,%r12
mov    0x10(%r15),%rdi
lea    0xe45(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12b1 <main+0x121>
mov    %rax,%r14
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     125d <main+0xcd>
mov    (%rsp),%al
test   %al,%al
je     11f0 <main+0x60>
mov    %r15,%rbx
nop
movsbl %al,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     1230 <main+0xa0>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1210 <main+0x80>
jmp    11f0 <main+0x60>
nopl   0x0(%rax,%rax,1)
movsbl (%rbx),%eax
cmp    $0x52,%eax
jg     1243 <main+0xb3>
test   %eax,%eax
je     11f0 <main+0x60>
cmp    $0x23,%eax
je     11f0 <main+0x60>
jmp    127e <main+0xee>
cmp    $0x57,%eax
je     11f0 <main+0x60>
cmp    $0x53,%eax
jne    127e <main+0xee>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10b0 <process_line@plt>
jmp    11f0 <main+0x60>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d37(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%r15),%r14
jmp    12be <main+0x12e>
mov    0x2d28(%rip),%rax
mov    (%rax),%ebx
mov    0x10(%r15),%r14
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd2f(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Could not open %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [32 x i8] c"Don't know what to do with: %s\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 [1024 x i8]
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @usage()
br label %14
14: ; preds = %12, %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
br label %19
19: ; preds = %14
%20 = load i32*, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %31, label %22
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %19
br label %32
32: ; preds = %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %7
br label %37
37: ; preds = %32
%38 = load i32*, i32** %7
%39 = icmp ne i32* %38, null
br i1 %39, label %49, label %40
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %44, i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %37
br label %50
50: ; preds = %49
br label %51
51: ; preds = %90, %82, %50
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%53 = load i32*, i32** %6
%54 = call i32* @fgets(i8* %52, i32 1024, i32* %53)
%55 = icmp ne i32* %54, null
br i1 %55, label %56, label %91
56: ; preds = %51
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
store i8* %57, i8** %9
br label %58
58: ; preds = %70, %56
%59 = load i8*, i8** %9
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %58
%64 = load i8*, i8** %9
%65 = load i8, i8* %64
%66 = call i64 @isspace(i8 signext %65)
%67 = icmp ne i64 %66, 0
br label %68
68: ; preds = %63, %58
%69 = phi i1 [ false, %58 ], [ %67, %63 ]
br i1 %69, label %70, label %73
70: ; preds = %68
%71 = load i8*, i8** %9
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %9
br label %58
73: ; preds = %68
%74 = load i8*, i8** %9
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
switch i32 %76, label %83 [
i32 83, label %77
i32 87, label %82
i32 35, label %82
i32 0, label %82
]
77: ; preds = %73
%78 = load i32*, i32** %7
%79 = load i8*, i8** %9
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%81 = call i32 @process_line(i32* %78, i8* %79, i8* %80)
br label %90
82: ; preds = %73, %73, %73
br label %51
83: ; preds = %73
br label %84
84: ; preds = %83
%85 = load i32, i32* @stderr
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%87 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %86)
%88 = call i32 @exit(i32 1)
unreachable
89: ; No predecessors!
br label %90
90: ; preds = %89, %77
br label %51
91: ; preds = %51
%92 = load i32*, i32** %6
%93 = call i32 @fclose(i32* %92)
%94 = load i32*, i32** %7
%95 = call i32 @fclose(i32* %94)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"Could not open %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [32 x i8] c"Don't know what to do with: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (...) @usage()
br label %7
7: ; preds = %5, %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 %19
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = load i32, i32* @errno
%16 = tail call i8* @strerror(i32 %15)
%17 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %7
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %20
%27 = load i32, i32* @errno
%28 = tail call i8* @strerror(i32 %27)
%29 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %28)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %19
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%33 = call i32* @fgets(i8* %32, i32 1024, i32* %10)
%34 = icmp eq i32* %33, null
br i1 %34, label %59, label %35
35: ; preds = %31, %52
%36 = load i8, i8* %32
%37 = icmp eq i8 %36, 0
br i1 %37, label %52, label %38
38: ; preds = %35, %43
%39 = phi i8 [ %45, %43 ], [ %36, %35 ]
%40 = phi i8* [ %44, %43 ], [ %32, %35 ]
%41 = call i64 @isspace(i8 signext %39)
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = getelementptr inbounds i8, i8* %40, i64 1
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %52, label %38
47: ; preds = %38
%48 = load i8, i8* %40
%49 = sext i8 %48 to i32
switch i32 %49, label %55 [
i32 83, label %50
i32 87, label %52
i32 35, label %52
i32 0, label %52
]
50: ; preds = %47
%51 = call i32 @process_line(i32* %22, i8* %40, i8* %32)
br label %52
52: ; preds = %43, %35, %47, %47, %47, %50
%53 = call i32* @fgets(i8* %32, i32 1024, i32* %10)
%54 = icmp eq i32* %53, null
br i1 %54, label %59, label %35
55: ; preds = %47
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %52, %31
%60 = call i32 @fclose(i32* %10)
%61 = call i32 @fclose(i32* %22)
ret i32 0
}