#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*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int strip_comments(FILE *fp, FILE *outfp, FILE *errfp) {
  int ch;
  int lastch;
  int backslashed = 0;
  int status = 0;
  for (lastch = -1; (ch = getc(fp)) != EOF; lastch = ch) {
    switch (status) {
    case 0:
      if (ch == '/')
        status = 3;
      else if (ch == '"')
        status = 1;
      else if (ch == '\'')
        status = 2;
      else
        putc(ch, outfp);
      break;
    case 2:
      putc(ch, outfp);
      if (lastch == '\\')
        backslashed ^= 1;
      else
        backslashed = 0;
      if (ch == '\'' && !backslashed)
        status = 0;
      break;
    case 1:
      putc(ch, outfp);
      if (lastch == '\\')
        backslashed ^= 1;
      else
        backslashed = 0;
      if (ch == '"' && !backslashed)
        status = 0;
      break;
    case 3:
      if (ch == '/')
        status = 4;
      else if (ch == '*')
        status = 5;
      else {
        putc(lastch, outfp);
        putc(ch, outfp);
        status = 0;
      }
      break;
    case 4:
      if (ch == '\n') {
        putc('\n', outfp);
        status = 0;
      }
      break;
    case 5:
      if (lastch == '*' && ch == '/')
        status = 0;
      break;
    default:
      fprintf(errfp, "wrong status!!\n");
      return -1;
    }
  }
  fflush(fp);
  return 0;
}


x86 assembly (clang, -O0):
<strip_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0xffffffff,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%eax
je     1370 <strip_comments+0x230>
mov    -0x30(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x5,%rax
ja     1344 <strip_comments+0x204>
mov    -0x38(%rbp),%rax
lea    0xe60(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x2f,-0x24(%rbp)
jne    11bf <strip_comments+0x7f>
movl   $0x3,-0x30(%rbp)
jmp    1204 <strip_comments+0xc4>
cmpl   $0x22,-0x24(%rbp)
jne    11d5 <strip_comments+0x95>
movl   $0x1,-0x30(%rbp)
jmp    11ff <strip_comments+0xbf>
cmpl   $0x27,-0x24(%rbp)
jne    11eb <strip_comments+0xab>
movl   $0x2,-0x30(%rbp)
jmp    11fa <strip_comments+0xba>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
jmp    11ff <strip_comments+0xbf>
jmp    1204 <strip_comments+0xc4>
jmp    1360 <strip_comments+0x220>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
cmpl   $0x5c,-0x28(%rbp)
jne    1230 <strip_comments+0xf0>
mov    -0x2c(%rbp),%eax
xor    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1237 <strip_comments+0xf7>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x27,-0x24(%rbp)
jne    1252 <strip_comments+0x112>
cmpl   $0x0,-0x2c(%rbp)
jne    1252 <strip_comments+0x112>
movl   $0x0,-0x30(%rbp)
jmp    1360 <strip_comments+0x220>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
cmpl   $0x5c,-0x28(%rbp)
jne    127e <strip_comments+0x13e>
mov    -0x2c(%rbp),%eax
xor    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1285 <strip_comments+0x145>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x22,-0x24(%rbp)
jne    12a0 <strip_comments+0x160>
cmpl   $0x0,-0x2c(%rbp)
jne    12a0 <strip_comments+0x160>
movl   $0x0,-0x30(%rbp)
jmp    1360 <strip_comments+0x220>
cmpl   $0x2f,-0x24(%rbp)
jne    12bb <strip_comments+0x17b>
movl   $0x4,-0x30(%rbp)
jmp    12fb <strip_comments+0x1bb>
cmpl   $0x2a,-0x24(%rbp)
jne    12d1 <strip_comments+0x191>
movl   $0x5,-0x30(%rbp)
jmp    12f6 <strip_comments+0x1b6>
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
movl   $0x0,-0x30(%rbp)
jmp    12fb <strip_comments+0x1bb>
jmp    1360 <strip_comments+0x220>
cmpl   $0xa,-0x24(%rbp)
jne    131f <strip_comments+0x1df>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1030 <putc@plt>
movl   $0x0,-0x30(%rbp)
jmp    1360 <strip_comments+0x220>
cmpl   $0x2a,-0x28(%rbp)
jne    133f <strip_comments+0x1ff>
cmpl   $0x2f,-0x24(%rbp)
jne    133f <strip_comments+0x1ff>
movl   $0x0,-0x30(%rbp)
jmp    1360 <strip_comments+0x220>
mov    -0x20(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1380 <strip_comments+0x240>
jmp    1365 <strip_comments+0x225>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1169 <strip_comments+0x29>
mov    -0x10(%rbp),%rdi
call   1050 <fflush@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_comments>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
call   1060 <getc@plt>
mov    0x2e81(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    1185 <strip_comments+0x45>
mov    %rbx,%rdi
call   1040 <fflush@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xffffffff,%r15d
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    11bd <strip_comments+0x7d>
xor    $0x2a,%r14d
mov    %r15d,%eax
xor    $0x2f,%eax
xor    %ecx,%ecx
or     %r14d,%eax
setne  %cl
lea    (%rcx,%rcx,4),%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    0x0(%rbp),%eax
je     116c <strip_comments+0x2c>
cmp    $0x5,%r12d
ja     12fe <strip_comments+0x1be>
mov    %r15d,%r14d
mov    %eax,%r15d
mov    %r12d,%eax
lea    0xe29(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmp    $0x2f,%r15d
je     12d2 <strip_comments+0x192>
cmp    $0x27,%r15d
je     12dd <strip_comments+0x19d>
cmp    $0x22,%r15d
jne    12e8 <strip_comments+0x1a8>
mov    $0x1,%r12d
jmp    11b0 <strip_comments+0x70>
movsbl %r15b,%edi
mov    0x8(%rsp),%rsi
call   1030 <putc@plt>
xor    $0x1,%r13d
cmp    $0x5c,%r14d
mov    $0x0,%ecx
cmovne %ecx,%r13d
mov    %r15d,%eax
xor    $0x22,%eax
xor    %r12d,%r12d
or     %r13d,%eax
setne  %r12b
cmove  %ecx,%r13d
jmp    11b0 <strip_comments+0x70>
movsbl %r15b,%edi
mov    0x8(%rsp),%rsi
call   1030 <putc@plt>
xor    $0x1,%r13d
cmp    $0x5c,%r14d
mov    $0x0,%ecx
cmovne %ecx,%r13d
mov    %r15d,%eax
xor    $0x27,%eax
xor    %r12d,%r12d
or     %r13d,%eax
setne  %r12b
cmove  %ecx,%r13d
add    %r12d,%r12d
jmp    11b0 <strip_comments+0x70>
cmp    $0x2f,%r15d
je     12a7 <strip_comments+0x167>
cmp    $0x2a,%r15d
jne    12b2 <strip_comments+0x172>
mov    $0x5,%r12d
jmp    11b0 <strip_comments+0x70>
mov    $0x4,%r12d
cmp    $0xa,%r15d
jne    11b0 <strip_comments+0x70>
mov    $0xa,%edi
jmp    12ec <strip_comments+0x1ac>
mov    $0x4,%r12d
jmp    11b0 <strip_comments+0x70>
movsbl %r14b,%edi
mov    %rbp,%r14
mov    0x8(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <putc@plt>
movsbl %r15b,%edi
mov    %rbp,%rsi
mov    %r14,%rbp
jmp    12f1 <strip_comments+0x1b1>
mov    $0x3,%r12d
jmp    11b0 <strip_comments+0x70>
mov    $0x2,%r12d
jmp    11b0 <strip_comments+0x70>
movsbl %r15b,%edi
mov    0x8(%rsp),%rsi
call   1030 <putc@plt>
xor    %r12d,%r12d
jmp    11b0 <strip_comments+0x70>
lea    0xd13(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1050 <fwrite@plt>
mov    $0xffffffff,%eax
jmp    1176 <strip_comments+0x36>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [16 x i8] c"wrong status!!\0A\00"
define i32 @strip_comments(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 0, i32* %10
store i32 0, i32* %11
store i32 -1, i32* %9
br label %12
12: ; preds = %115, %3
%13 = load i32*, i32** %5
%14 = call i32 @getc(i32* %13)
store i32 %14, i32* %8
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %117
17: ; preds = %12
%18 = load i32, i32* %11
switch i32 %18, label %111 [
i32 0, label %19
i32 2, label %39
i32 1, label %58
i32 3, label %77
i32 4, label %96
i32 5, label %103
]
19: ; preds = %17
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 47
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 3, i32* %11
br label %38
23: ; preds = %19
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 34
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1, i32* %11
br label %37
27: ; preds = %23
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 39
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 2, i32* %11
br label %36
31: ; preds = %27
%32 = load i32, i32* %8
%33 = trunc i32 %32 to i8
%34 = load i32*, i32** %6
%35 = call i32 @putc(i8 signext %33, i32* %34)
br label %36
36: ; preds = %31, %30
br label %37
37: ; preds = %36, %26
br label %38
38: ; preds = %37, %22
br label %114
39: ; preds = %17
%40 = load i32, i32* %8
%41 = trunc i32 %40 to i8
%42 = load i32*, i32** %6
%43 = call i32 @putc(i8 signext %41, i32* %42)
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 92
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i32, i32* %10
%48 = xor i32 %47, 1
store i32 %48, i32* %10
br label %50
49: ; preds = %39
store i32 0, i32* %10
br label %50
50: ; preds = %49, %46
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 39
br i1 %52, label %53, label %57
53: ; preds = %50
%54 = load i32, i32* %10
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %53
store i32 0, i32* %11
br label %57
57: ; preds = %56, %53, %50
br label %114
58: ; preds = %17
%59 = load i32, i32* %8
%60 = trunc i32 %59 to i8
%61 = load i32*, i32** %6
%62 = call i32 @putc(i8 signext %60, i32* %61)
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, 92
br i1 %64, label %65, label %68
65: ; preds = %58
%66 = load i32, i32* %10
%67 = xor i32 %66, 1
store i32 %67, i32* %10
br label %69
68: ; preds = %58
store i32 0, i32* %10
br label %69
69: ; preds = %68, %65
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, 34
br i1 %71, label %72, label %76
72: ; preds = %69
%73 = load i32, i32* %10
%74 = icmp ne i32 %73, 0
br i1 %74, label %76, label %75
75: ; preds = %72
store i32 0, i32* %11
br label %76
76: ; preds = %75, %72, %69
br label %114
77: ; preds = %17
%78 = load i32, i32* %8
%79 = icmp eq i32 %78, 47
br i1 %79, label %80, label %81
80: ; preds = %77
store i32 4, i32* %11
br label %95
81: ; preds = %77
%82 = load i32, i32* %8
%83 = icmp eq i32 %82, 42
br i1 %83, label %84, label %85
84: ; preds = %81
store i32 5, i32* %11
br label %94
85: ; preds = %81
%86 = load i32, i32* %9
%87 = trunc i32 %86 to i8
%88 = load i32*, i32** %6
%89 = call i32 @putc(i8 signext %87, i32* %88)
%90 = load i32, i32* %8
%91 = trunc i32 %90 to i8
%92 = load i32*, i32** %6
%93 = call i32 @putc(i8 signext %91, i32* %92)
store i32 0, i32* %11
br label %94
94: ; preds = %85, %84
br label %95
95: ; preds = %94, %80
br label %114
96: ; preds = %17
%97 = load i32, i32* %8
%98 = icmp eq i32 %97, 10
br i1 %98, label %99, label %102
99: ; preds = %96
%100 = load i32*, i32** %6
%101 = call i32 @putc(i8 signext 10, i32* %100)
store i32 0, i32* %11
br label %102
102: ; preds = %99, %96
br label %114
103: ; preds = %17
%104 = load i32, i32* %9
%105 = icmp eq i32 %104, 42
br i1 %105, label %106, label %110
106: ; preds = %103
%107 = load i32, i32* %8
%108 = icmp eq i32 %107, 47
br i1 %108, label %109, label %110
109: ; preds = %106
store i32 0, i32* %11
br label %110
110: ; preds = %109, %106, %103
br label %114
111: ; preds = %17
%112 = load i32*, i32** %7
%113 = call i32 @fprintf(i32* %112, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %120
114: ; preds = %110, %102, %95, %76, %57, %38
br label %115
115: ; preds = %114
%116 = load i32, i32* %8
store i32 %116, i32* %9
br label %12
117: ; preds = %12
%118 = load i32*, i32** %5
%119 = call i32 @fflush(i32* %118)
store i32 0, i32* %4
br label %120
120: ; preds = %117, %111
%121 = load i32, i32* %4
ret i32 %121
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [16 x i8] c"wrong status!!\0A\00"
define i32 @strip_comments(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %64, label %7
7: ; preds = %3, %58
%8 = phi i32 [ %61, %58 ], [ %4, %3 ]
%9 = phi i32 [ %60, %58 ], [ 0, %3 ]
%10 = phi i32 [ %59, %58 ], [ 0, %3 ]
%11 = phi i32 [ %8, %58 ], [ -1, %3 ]
switch i32 %9, label %56 [
i32 0, label %12
i32 2, label %18
i32 1, label %29
i32 3, label %40
i32 4, label %47
i32 5, label %51
]
12: ; preds = %7
switch i32 %8, label %15 [
i32 47, label %58
i32 34, label %13
i32 39, label %14
]
13: ; preds = %12
br label %58
14: ; preds = %12
br label %58
15: ; preds = %12
%16 = trunc i32 %8 to i8
%17 = tail call i32 @putc(i8 signext %16, i32* %1)
br label %58
18: ; preds = %7
%19 = trunc i32 %8 to i8
%20 = tail call i32 @putc(i8 signext %19, i32* %1)
%21 = icmp eq i32 %11, 92
%22 = xor i32 %10, 1
%23 = select i1 %21, i32 %22, i32 0
%24 = icmp ne i32 %8, 39
%25 = icmp ne i32 %23, 0
%26 = select i1 %24, i1 true, i1 %25
%27 = select i1 %26, i32 %23, i32 0
%28 = select i1 %26, i32 2, i32 0
br label %58
29: ; preds = %7
%30 = trunc i32 %8 to i8
%31 = tail call i32 @putc(i8 signext %30, i32* %1)
%32 = icmp eq i32 %11, 92
%33 = xor i32 %10, 1
%34 = select i1 %32, i32 %33, i32 0
%35 = icmp ne i32 %8, 34
%36 = icmp ne i32 %34, 0
%37 = select i1 %35, i1 true, i1 %36
%38 = select i1 %37, i32 %34, i32 0
%39 = zext i1 %37 to i32
br label %58
40: ; preds = %7
switch i32 %8, label %42 [
i32 47, label %58
i32 42, label %41
]
41: ; preds = %40
br label %58
42: ; preds = %40
%43 = trunc i32 %11 to i8
%44 = tail call i32 @putc(i8 signext %43, i32* %1)
%45 = trunc i32 %8 to i8
%46 = tail call i32 @putc(i8 signext %45, i32* %1)
br label %58
47: ; preds = %7
%48 = icmp eq i32 %8, 10
br i1 %48, label %49, label %58
49: ; preds = %47
%50 = tail call i32 @putc(i8 signext 10, i32* %1)
br label %58
51: ; preds = %7
%52 = icmp eq i32 %11, 42
%53 = icmp eq i32 %8, 47
%54 = and i1 %52, %53
%55 = select i1 %54, i32 0, i32 5
br label %58
56: ; preds = %7
%57 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 15, i64 1, i32* %2)
br label %66
58: ; preds = %29, %18, %51, %40, %12, %13, %15, %14, %41, %42, %49, %47
%59 = phi i32 [ %10, %49 ], [ %10, %47 ], [ %10, %41 ], [ %10, %42 ], [ %10, %13 ], [ %10, %14 ], [ %10, %15 ], [ %10, %12 ], [ %10, %40 ], [ %10, %51 ], [ %27, %18 ], [ %38, %29 ]
%60 = phi i32 [ 0, %49 ], [ 4, %47 ], [ 5, %41 ], [ 0, %42 ], [ 1, %13 ], [ 2, %14 ], [ 0, %15 ], [ 3, %12 ], [ 4, %40 ], [ %55, %51 ], [ %28, %18 ], [ %39, %29 ]
%61 = tail call i32 @getc(i32* %0)
%62 = load i32, i32* @EOF
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %7
64: ; preds = %58, %3
%65 = tail call i32 @fflush(i32* %0)
br label %66
66: ; preds = %64, %56
%67 = phi i32 [ -1, %56 ], [ 0, %64 ]
ret i32 %67
}