#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;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  in = fopen("input.dat", "r");
  if (in == NULL) {
    perror("input.dat");
    return 1;
  }
  out = fopen("output.dat", "w");
  if (out == NULL) {
    perror("output.dat");
    return 1;
  }
  char ch;
  char pch;
  int state = 0;
  pch = fgetc(in);
  if (pch == EOF) {
    fclose(in);
    fclose(out);
    return 1;
  }
  while ((ch = fgetc(in)) != EOF) {
    if (pch == '/' && ch == '*') {
      state = 1;
    } else if (state == 0) {
      fputc(pch, out);
    } else if (state == 1 && pch == '*' && ch == '/') {
      state = 0;
      ch = ' ';
    }
    pch = ch;
  }
  fclose(in);
  fclose(out);
  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)
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <main+0x50>
lea    0xe71(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e8 <main+0x198>
lea    0xe65(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11da <main+0x8a>
lea    0xe43(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e8 <main+0x198>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x22(%rbp)
movsbl -0x22(%rbp),%eax
mov    0x2df0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1221 <main+0xd1>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e8 <main+0x198>
jmp    1226 <main+0xd6>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2dac(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12cf <main+0x17f>
movsbl -0x22(%rbp),%eax
cmp    $0x2f,%eax
jne    126d <main+0x11d>
movsbl -0x21(%rbp),%eax
cmp    $0x2a,%eax
jne    126d <main+0x11d>
movl   $0x1,-0x28(%rbp)
jmp    12c4 <main+0x174>
cmpl   $0x0,-0x28(%rbp)
jne    128b <main+0x13b>
mov    -0x22(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    12bf <main+0x16f>
cmpl   $0x1,-0x28(%rbp)
jne    12ba <main+0x16a>
movsbl -0x22(%rbp),%eax
cmp    $0x2a,%eax
jne    12ba <main+0x16a>
movsbl -0x21(%rbp),%eax
cmp    $0x2f,%eax
jne    12ba <main+0x16a>
movl   $0x0,-0x28(%rbp)
movb   $0x20,-0x21(%rbp)
jmp    12bf <main+0x16f>
jmp    12c4 <main+0x174>
mov    -0x21(%rbp),%al
mov    %al,-0x22(%rbp)
jmp    1226 <main+0xd6>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
lea    0xe9e(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     125b <main+0x10b>
mov    %rax,%r15
lea    0xe8b(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1264 <main+0x114>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    0x2e40(%rip),%r12
cmp    (%r12),%al
jne    11c3 <main+0x73>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    1270 <main+0x120>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <fgetc@plt>
cmp    (%r12),%al
jne    11ea <main+0x9a>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1275 <main+0x125>
mov    %eax,%ebx
xor    %r13d,%r13d
jmp    121a <main+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r13d
mov    $0x2a,%bl
mov    %ebx,%ebp
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebx
cmp    (%r12),%al
je     11d3 <main+0x83>
cmp    $0x2f,%bpl
jne    1225 <main+0xd5>
cmp    $0x2a,%bl
je     1200 <main+0xb0>
test   %r13d,%r13d
je     124a <main+0xfa>
xor    $0x2a,%bpl
movzbl %bl,%eax
xor    $0x2f,%bl
xor    %r13d,%r13d
or     %bpl,%bl
setne  %r13b
mov    $0x20,%ecx
cmove  %ecx,%eax
mov    %eax,%ebx
jmp    1208 <main+0xb8>
movsbl %bpl,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
xor    %r13d,%r13d
jmp    1208 <main+0xb8>
lea    0xd9e(%rip),%rdi
jmp    126b <main+0x11b>
lea    0xda1(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.dat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.dat\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %80
16: ; preds = %2
%17 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %17, i32** %7
%18 = load i32*, i32** %7
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %80
22: ; preds = %16
store i32 0, i32* %10
%23 = load i32*, i32** %6
%24 = call signext i8 @fgetc(i32* %23)
store i8 %24, i8* %9
%25 = load i8, i8* %9
%26 = sext i8 %25 to i32
%27 = load i8, i8* @EOF
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %26, %28
br i1 %29, label %30, label %35
30: ; preds = %22
%31 = load i32*, i32** %6
%32 = call i32 @fclose(i32* %31)
%33 = load i32*, i32** %7
%34 = call i32 @fclose(i32* %33)
store i32 1, i32* %3
br label %80
35: ; preds = %22
br label %36
36: ; preds = %73, %35
%37 = load i32*, i32** %6
%38 = call signext i8 @fgetc(i32* %37)
store i8 %38, i8* %8
%39 = sext i8 %38 to i32
%40 = load i8, i8* @EOF
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %39, %41
br i1 %42, label %43, label %75
43: ; preds = %36
%44 = load i8, i8* %9
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 47
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 42
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 1, i32* %10
br label %73
52: ; preds = %47, %43
%53 = load i32, i32* %10
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i8, i8* %9
%57 = load i32*, i32** %7
%58 = call i32 @fputc(i8 signext %56, i32* %57)
br label %72
59: ; preds = %52
%60 = load i32, i32* %10
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %71
62: ; preds = %59
%63 = load i8, i8* %9
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 42
br i1 %65, label %66, label %71
66: ; preds = %62
%67 = load i8, i8* %8
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 47
br i1 %69, label %70, label %71
70: ; preds = %66
store i32 0, i32* %10
store i8 32, i8* %8
br label %71
71: ; preds = %70, %66, %62, %59
br label %72
72: ; preds = %71, %55
br label %73
73: ; preds = %72, %51
%74 = load i8, i8* %8
store i8 %74, i8* %9
br label %36
75: ; preds = %36
%76 = load i32*, i32** %6
%77 = call i32 @fclose(i32* %76)
%78 = load i32*, i32** %7
%79 = call i32 @fclose(i32* %78)
store i32 0, i32* %3
br label %80
80: ; preds = %75, %30, %20, %14
%81 = load i32, i32* %3
ret i32 %81
}

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