#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 */
char EOF;
char *GetComment(int /*<<< orphan*/ *);
int /*<<< orphan*/ PrintUsage();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasestr(char *, char *);
int main(int argc, char *argv[]) {
  FILE *input;
  char *comment;
  char scanChar;
  bool in_quote = false;
  if (argc != 2) {
    PrintUsage();
    exit(1);
  }
  input = fopen(argv[1], "r");
  if (!input) {
    fprintf(stderr, "Unable to open %s!\n", argv[1]);
    exit(2);
  }
  scanChar = '/';
  while (!feof(input)) {
    char c;
    c = fgetc(input);
    if (in_quote) {
      if (c == '"') {
        in_quote = false;
      }
      if (c != EOF)
        printf("%c", c);
      continue;
    } else {
      if (c == '"')
        in_quote = true;
    }
    if (c != '/') {
      if (c != EOF)
        printf("%c", c);
      continue;
    }
    if ((c = fgetc(input)) != '*') {
      if (c != EOF)
        printf("/%c", c);
      continue;
    }
    comment = GetComment(input);
    if (!comment) {
      fprintf(stderr, "Malformed C file.  Unable "
                      "to find end of comment\n");
      exit(3);
    }
    if (!strcasestr(comment, "Editor Settings") &&
        !strcasestr(comment, "This program is free software")) {
      printf("/*%s*/", comment);
      continue;
    }
    free(comment);
    comment = NULL;
  }
  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,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d8 <main+0x38>
mov    $0x0,%al
call   1050 <PrintUsage@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe19(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1224 <main+0x84>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>
movb   $0x2f,-0x21(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1246 <main+0xa6>
jmp    13cd <main+0x22d>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     129d <main+0xfd>
movsbl -0x29(%rbp),%eax
cmp    $0x22,%eax
jne    1270 <main+0xd0>
movl   $0x0,-0x28(%rbp)
movsbl -0x29(%rbp),%eax
mov    0x2d6d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1298 <main+0xf8>
movsbl -0x29(%rbp),%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1228 <main+0x88>
movsbl -0x29(%rbp),%eax
cmp    $0x22,%eax
jne    12b1 <main+0x111>
movl   $0x1,-0x28(%rbp)
jmp    12b6 <main+0x116>
movsbl -0x29(%rbp),%eax
cmp    $0x2f,%eax
je     12f0 <main+0x150>
movsbl -0x29(%rbp),%eax
mov    0x2d1a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12eb <main+0x14b>
movsbl -0x29(%rbp),%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1228 <main+0x88>
mov    -0x18(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x29(%rbp)
movsbl %al,%eax
cmp    $0x2a,%eax
je     1335 <main+0x195>
movsbl -0x29(%rbp),%eax
mov    0x2cd5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1330 <main+0x190>
movsbl -0x29(%rbp),%esi
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1228 <main+0x88>
mov    -0x18(%rbp),%rdi
call   1040 <GetComment@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    136e <main+0x1ce>
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
lea    0xcbd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x3,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xcd3(%rip),%rsi
call   10b0 <strcasestr@plt>
cmp    $0x0,%eax
jne    13b7 <main+0x217>
mov    -0x20(%rbp),%rdi
lea    0xcca(%rip),%rsi
call   10b0 <strcasestr@plt>
cmp    $0x0,%eax
jne    13b7 <main+0x217>
mov    -0x20(%rbp),%rsi
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1228 <main+0x88>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
jmp    1228 <main+0x88>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1303 <main+0x153>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe2e(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1314 <main+0x164>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     1200 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe45(%rip),%r14
mov    0x2dda(%rip),%r12
lea    0xe01(%rip),%r13
xor    %ebp,%ebp
jmp    1240 <main+0x90>
mov    %rbp,%rdi
call   1030 <free@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %r15b,%ebp
mov    %rbx,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    11ef <main+0x3f>
mov    %rbx,%rdi
call   1080 <fgetc@plt>
test   %ebp,%ebp
je     1260 <main+0xb0>
cmp    $0x22,%al
setne  %r15b
jmp    12d0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x22,%al
sete   %r15b
cmp    $0x2f,%al
jne    12d0 <main+0x120>
mov    %rbx,%rdi
call   1080 <fgetc@plt>
cmp    $0x2a,%al
jne    12e7 <main+0x137>
mov    %rbx,%rdi
call   1050 <GetComment@plt>
test   %rax,%rax
je     1339 <main+0x189>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
call   10c0 <strcasestr@plt>
test   %eax,%eax
jne    1219 <main+0x69>
mov    %rbp,%rdi
lea    0xdb9(%rip),%rsi
call   10c0 <strcasestr@plt>
test   %eax,%eax
jne    1219 <main+0x69>
lea    0xdc3(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1230 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
cmp    (%r12),%al
je     1230 <main+0x80>
movsbl %al,%edi
call   1040 <putchar@plt>
jmp    1230 <main+0x80>
cmp    (%r12),%al
je     1230 <main+0x80>
movsbl %al,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1230 <main+0x80>
xor    %eax,%eax
call   1060 <PrintUsage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xcda(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
lea    0xcd1(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [4 x i8] c"/%c\00"
@.str.4 = [50 x i8] c"Malformed C file. Unable to find end of comment\0A\00"
@.str.5 = [16 x i8] c"Editor Settings\00"
@.str.6 = [30 x i8] c"This program is free software\00"
@.str.7 = [7 x i8] c"/*%s*/\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
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (...) @PrintUsage()
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %30, label %23
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 2)
unreachable
30: ; preds = %16
store i8 47, i8* %8
br label %31
31: ; preds = %114, %111, %93, %77, %56, %30
%32 = load i32*, i32** %6
%33 = call i32 @feof(i32* %32)
%34 = icmp ne i32 %33, 0
%35 = xor i1 %34, true
br i1 %35, label %36, label %117
36: ; preds = %31
%37 = load i32*, i32** %6
%38 = call signext i8 @fgetc(i32* %37)
store i8 %38, i8* %10
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %57
41: ; preds = %36
%42 = load i8, i8* %10
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 34
br i1 %44, label %45, label %46
45: ; preds = %41
store i32 0, i32* %9
br label %46
46: ; preds = %45, %41
%47 = load i8, i8* %10
%48 = sext i8 %47 to i32
%49 = load i8, i8* @EOF
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %48, %50
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i8, i8* %10
%54 = sext i8 %53 to i32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %52, %46
br label %31
57: ; preds = %36
%58 = load i8, i8* %10
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 34
br i1 %60, label %61, label %62
61: ; preds = %57
store i32 1, i32* %9
br label %62
62: ; preds = %61, %57
br label %63
63: ; preds = %62
%64 = load i8, i8* %10
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 47
br i1 %66, label %67, label %78
67: ; preds = %63
%68 = load i8, i8* %10
%69 = sext i8 %68 to i32
%70 = load i8, i8* @EOF
%71 = sext i8 %70 to i32
%72 = icmp ne i32 %69, %71
br i1 %72, label %73, label %77
73: ; preds = %67
%74 = load i8, i8* %10
%75 = sext i8 %74 to i32
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %73, %67
br label %31
78: ; preds = %63
%79 = load i32*, i32** %6
%80 = call signext i8 @fgetc(i32* %79)
store i8 %80, i8* %10
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 42
br i1 %82, label %83, label %94
83: ; preds = %78
%84 = load i8, i8* %10
%85 = sext i8 %84 to i32
%86 = load i8, i8* @EOF
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %85, %87
br i1 %88, label %89, label %93
89: ; preds = %83
%90 = load i8, i8* %10
%91 = sext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %89, %83
br label %31
94: ; preds = %78
%95 = load i32*, i32** %6
%96 = call i8* @GetComment(i32* %95)
store i8* %96, i8** %7
%97 = load i8*, i8** %7
%98 = icmp ne i8* %97, null
br i1 %98, label %103, label %99
99: ; preds = %94
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%102 = call i32 @exit(i32 3)
unreachable
103: ; preds = %94
%104 = load i8*, i8** %7
%105 = call i32 @strcasestr(i8* %104, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%106 = icmp ne i32 %105, 0
br i1 %106, label %114, label %107
107: ; preds = %103
%108 = load i8*, i8** %7
%109 = call i32 @strcasestr(i8* %108, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%110 = icmp ne i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %107
%112 = load i8*, i8** %7
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %112)
br label %31
114: ; preds = %107, %103
%115 = load i8*, i8** %7
%116 = call i32 @free(i8* %115)
store i8* null, i8** %7
br label %31
117: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Unable to open %s!\0A\00"
@EOF = global i8 0
@.str.3 = [4 x i8] c"/%c\00"
@.str.4 = [50 x i8] c"Malformed C file. Unable to find end of comment\0A\00"
@.str.5 = [16 x i8] c"Editor Settings\00"
@.str.6 = [30 x i8] c"This program is free software\00"
@.str.7 = [7 x i8] c"/*%s*/\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 (...) @PrintUsage()
%6 = tail call i32 @exit(i32 1)
unreachable
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 %15, label %12
12: ; preds = %7
%13 = tail call i32 @feof(i32* %10)
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %71
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %8
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 2)
unreachable
20: ; preds = %12, %66
%21 = phi i32 [ %68, %66 ], [ 0, %12 ]
%22 = tail call signext i8 @fgetc(i32* %10)
%23 = icmp eq i32 %21, 0
br i1 %23, label %31, label %24
24: ; preds = %20
%25 = icmp ne i8 %22, 34
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %22, %26
br i1 %27, label %66, label %28
28: ; preds = %24
%29 = sext i8 %22 to i32
%30 = tail call i32 @putchar(i32 %29)
br label %66
31: ; preds = %20
%32 = sext i8 %22 to i32
%33 = icmp eq i8 %22, 34
%34 = icmp eq i8 %22, 47
br i1 %34, label %40, label %35
35: ; preds = %31
%36 = load i8, i8* @EOF
%37 = icmp eq i8 %22, %36
br i1 %37, label %66, label %38
38: ; preds = %35
%39 = tail call i32 @putchar(i32 %32)
br label %66
40: ; preds = %31
%41 = tail call signext i8 @fgetc(i32* %10)
%42 = sext i8 %41 to i32
%43 = icmp eq i8 %41, 42
br i1 %43, label %49, label %44
44: ; preds = %40
%45 = load i8, i8* @EOF
%46 = icmp eq i8 %41, %45
br i1 %46, label %66, label %47
47: ; preds = %44
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %66
49: ; preds = %40
%50 = tail call i8* @GetComment(i32* %10)
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%55 = tail call i32 @exit(i32 3)
unreachable
56: ; preds = %49
%57 = tail call i32 @strcasestr(i8* %50, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = tail call i32 @strcasestr(i8* %50, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %50)
br label %66
64: ; preds = %59, %56
%65 = tail call i32 @free(i8* %50)
br label %66
66: ; preds = %44, %47, %35, %38, %24, %28, %64, %62
%67 = phi i1 [ %33, %64 ], [ %33, %62 ], [ %25, %28 ], [ %25, %24 ], [ %33, %38 ], [ %33, %35 ], [ %33, %47 ], [ %33, %44 ]
%68 = zext i1 %67 to i32
%69 = tail call i32 @feof(i32* %10)
%70 = icmp eq i32 %69, 0
br i1 %70, label %20, label %71
71: ; preds = %66, %12
ret i32 0
}