#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
void strip(const char *filename) {
  FILE *infile;
  int c1, c2;
  int readingComment = 0;
  int readingString = 0;
  infile = fopen(filename, "rt");
  if (infile == NULL) {
    return;
  }
  while (!feof(infile)) {
    if (readingComment) {
      c1 = fgetc(infile);
      if (c1 == '*') {
        c2 = fgetc(infile);
        if (c2 == '/') {
          readingComment = 0;
        } else {
          ungetc(c2, infile);
        }
      }
    } else if (readingString) {
      c1 = fgetc(infile);
      if (c1 != '\\') {
        c2 = fgetc(infile);
        if (c2 == '"') {
          readingString = 0;
        }
        printf("%c%c", c1, c2);
      } else {
        printf("%c", c1);
      }
    } else {
      c1 = fgetc(infile);
      if (c1 != '\\') {
        c2 = fgetc(infile);
        if (c2 == '"') {
          readingString = 1;
          printf("%c%c", c1, c2);
        } else if (c1 == '/' && c2 == '*') {
          readingComment = 1;
        } else {
          printf("%c", c1);
          ungetc(c2, infile);
        }
      } else {
        printf("%c", c1);
      }
    }
  }
  fclose(infile);
}


x86 assembly (clang, -O0):
<strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <strip+0x3e>
jmp    1341 <strip+0x1e1>
jmp    11a3 <strip+0x43>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11c1 <strip+0x61>
jmp    1338 <strip+0x1d8>
cmpl   $0x0,-0x1c(%rbp)
je     1219 <strip+0xb9>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2a,-0x14(%rbp)
jne    1214 <strip+0xb4>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2f,-0x18(%rbp)
jne    1203 <strip+0xa3>
movl   $0x0,-0x1c(%rbp)
jmp    120f <strip+0xaf>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ungetc@plt>
jmp    1214 <strip+0xb4>
jmp    1333 <strip+0x1d3>
cmpl   $0x0,-0x20(%rbp)
je     1285 <strip+0x125>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5c,-0x14(%rbp)
je     126f <strip+0x10f>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x22,-0x18(%rbp)
jne    1256 <strip+0xf6>
movl   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1280 <strip+0x120>
mov    -0x14(%rbp),%esi
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132e <strip+0x1ce>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x5c,-0x14(%rbp)
je     1318 <strip+0x1b8>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x22,-0x18(%rbp)
jne    12d1 <strip+0x171>
movl   $0x1,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1313 <strip+0x1b3>
cmpl   $0x2f,-0x14(%rbp)
jne    12f1 <strip+0x191>
cmpl   $0x2a,-0x18(%rbp)
jne    12f1 <strip+0x191>
movl   $0x1,-0x1c(%rbp)
jmp    130e <strip+0x1ae>
mov    -0x14(%rbp),%esi
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1070 <ungetc@plt>
jmp    1313 <strip+0x1b3>
jmp    1329 <strip+0x1c9>
mov    -0x14(%rbp),%esi
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    132e <strip+0x1ce>
jmp    1333 <strip+0x1d3>
jmp    11a3 <strip+0x43>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11a1 <strip+0x41>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11b0 <strip+0x50>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
lea    0xe4b(%rip),%r14
lea    0xe42(%rip),%r15
xor    %ebp,%ebp
jmp    11dc <strip+0x7c>
mov    %eax,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
nop
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    118b <strip+0x2b>
mov    %rbx,%rdi
test   %ebp,%ebp
je     1210 <strip+0xb0>
call   1050 <fgetc@plt>
mov    $0x1,%ebp
cmp    $0x2a,%eax
jne    11d0 <strip+0x70>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0x2f,%eax
jne    11c5 <strip+0x65>
xor    %ebp,%ebp
jmp    11d0 <strip+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1050 <fgetc@plt>
mov    %eax,%r13d
test   %r12d,%r12d
je     123c <strip+0xdc>
cmp    $0x5c,%r13d
jne    1258 <strip+0xf8>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    $0x5c,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r12d
jmp    11d0 <strip+0x70>
cmp    $0x5c,%r13d
jne    1280 <strip+0x120>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    $0x5c,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12e2 <strip+0x182>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
xor    %r12d,%r12d
cmp    $0x22,%eax
setne  %r12b
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %r13d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d0 <strip+0x70>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0x22,%eax
jne    12ac <strip+0x14c>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x22,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r12d
jmp    11d0 <strip+0x70>
mov    %eax,%r12d
cmp    $0x2f,%r13d
jne    12c8 <strip+0x168>
cmp    $0x2a,%r12d
jne    12c8 <strip+0x168>
xor    %r12d,%r12d
mov    $0x1,%ebp
jmp    11d0 <strip+0x70>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
call   1070 <ungetc@plt>
xor    %r12d,%r12d
jmp    11d0 <strip+0x70>

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [5 x i8] c"%c%c\00"
@.str.2 = [3 x i8] c"%c\00"
define void @strip(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %3
%10 = load i32*, i32** %3
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
br label %99
13: ; preds = %1
br label %14
14: ; preds = %95, %13
%15 = load i32*, i32** %3
%16 = call i32 @feof(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %96
19: ; preds = %14
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %39
22: ; preds = %19
%23 = load i32*, i32** %3
%24 = call i32 @fgetc(i32* %23)
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 42
br i1 %26, label %27, label %38
27: ; preds = %22
%28 = load i32*, i32** %3
%29 = call i32 @fgetc(i32* %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 47
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 0, i32* %6
br label %37
33: ; preds = %27
%34 = load i32, i32* %5
%35 = load i32*, i32** %3
%36 = call i32 @ungetc(i32 %34, i32* %35)
br label %37
37: ; preds = %33, %32
br label %38
38: ; preds = %37, %22
br label %95
39: ; preds = %19
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %61
42: ; preds = %39
%43 = load i32*, i32** %3
%44 = call i32 @fgetc(i32* %43)
store i32 %44, i32* %4
%45 = load i32, i32* %4
%46 = icmp ne i32 %45, 92
br i1 %46, label %47, label %57
47: ; preds = %42
%48 = load i32*, i32** %3
%49 = call i32 @fgetc(i32* %48)
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, 34
br i1 %51, label %52, label %53
52: ; preds = %47
store i32 0, i32* %7
br label %53
53: ; preds = %52, %47
%54 = load i32, i32* %4
%55 = load i32, i32* %5
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %54, i32 %55)
br label %60
57: ; preds = %42
%58 = load i32, i32* %4
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %57, %53
br label %94
61: ; preds = %39
%62 = load i32*, i32** %3
%63 = call i32 @fgetc(i32* %62)
store i32 %63, i32* %4
%64 = load i32, i32* %4
%65 = icmp ne i32 %64, 92
br i1 %65, label %66, label %90
66: ; preds = %61
%67 = load i32*, i32** %3
%68 = call i32 @fgetc(i32* %67)
store i32 %68, i32* %5
%69 = load i32, i32* %5
%70 = icmp eq i32 %69, 34
br i1 %70, label %71, label %75
71: ; preds = %66
store i32 1, i32* %7
%72 = load i32, i32* %4
%73 = load i32, i32* %5
%74 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %72, i32 %73)
br label %89
75: ; preds = %66
%76 = load i32, i32* %4
%77 = icmp eq i32 %76, 47
br i1 %77, label %78, label %82
78: ; preds = %75
%79 = load i32, i32* %5
%80 = icmp eq i32 %79, 42
br i1 %80, label %81, label %82
81: ; preds = %78
store i32 1, i32* %6
br label %88
82: ; preds = %78, %75
%83 = load i32, i32* %4
%84 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %5
%86 = load i32*, i32** %3
%87 = call i32 @ungetc(i32 %85, i32* %86)
br label %88
88: ; preds = %82, %81
br label %89
89: ; preds = %88, %71
br label %93
90: ; preds = %61
%91 = load i32, i32* %4
%92 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %90, %89
br label %94
94: ; preds = %93, %60
br label %95
95: ; preds = %94, %38
br label %14
96: ; preds = %14
%97 = load i32*, i32** %3
%98 = call i32 @fclose(i32* %97)
br label %99
99: ; preds = %96, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [5 x i8] c"%c%c\00"
@.str.2 = [3 x i8] c"%c\00"
define void @strip(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %53, label %4
4: ; preds = %1
%5 = tail call i32 @feof(i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %51
7: ; preds = %4, %46
%8 = phi i32 [ %48, %46 ], [ 0, %4 ]
%9 = phi i32 [ %47, %46 ], [ 0, %4 ]
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = tail call i32 @fgetc(i32* %2)
%13 = icmp eq i32 %12, 42
br i1 %13, label %14, label %46
14: ; preds = %11
%15 = tail call i32 @fgetc(i32* %2)
%16 = icmp eq i32 %15, 47
br i1 %16, label %46, label %17
17: ; preds = %14
%18 = tail call i32 @ungetc(i32 %15, i32* %2)
br label %46
19: ; preds = %7
%20 = icmp eq i32 %8, 0
%21 = tail call i32 @fgetc(i32* %2)
%22 = icmp eq i32 %21, 92
br i1 %20, label %31, label %23
23: ; preds = %19
br i1 %22, label %29, label %24
24: ; preds = %23
%25 = tail call i32 @fgetc(i32* %2)
%26 = icmp ne i32 %25, 34
%27 = zext i1 %26 to i32
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %25)
br label %46
29: ; preds = %23
%30 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 92)
br label %46
31: ; preds = %19
br i1 %22, label %44, label %32
32: ; preds = %31
%33 = tail call i32 @fgetc(i32* %2)
%34 = icmp eq i32 %33, 34
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 34)
br label %46
37: ; preds = %32
%38 = icmp eq i32 %21, 47
%39 = icmp eq i32 %33, 42
%40 = and i1 %38, %39
br i1 %40, label %46, label %41
41: ; preds = %37
%42 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%43 = tail call i32 @ungetc(i32 %33, i32* %2)
br label %46
44: ; preds = %31
%45 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 92)
br label %46
46: ; preds = %37, %14, %29, %24, %35, %41, %44, %11, %17
%47 = phi i32 [ 1, %17 ], [ 1, %11 ], [ 0, %24 ], [ 0, %29 ], [ 0, %35 ], [ 0, %41 ], [ 0, %44 ], [ 0, %14 ], [ 1, %37 ]
%48 = phi i32 [ %8, %17 ], [ %8, %11 ], [ %27, %24 ], [ 1, %29 ], [ 1, %35 ], [ 0, %41 ], [ 0, %44 ], [ %8, %14 ], [ 0, %37 ]
%49 = tail call i32 @feof(i32* %2)
%50 = icmp eq i32 %49, 0
br i1 %50, label %7, label %51
51: ; preds = %46, %4
%52 = tail call i32 @fclose(i32* %2)
br label %53
53: ; preds = %1, %51
ret void
}