#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
unsigned int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(unsigned int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
main(int argc, char *argv[]) {
  FILE *FIn;
  unsigned int c;
  int mode = 0;
  if (argc != 2) {
    fprintf(stderr, "Error: no input filename given.\n");
    exit(0);
  }
  if (!(FIn = fopen(argv[1], "rb"))) {
    fprintf(stderr, "Error opening %s\n", argv[1]);
    exit(0);
  }
  c = fgetc(FIn);
  while (!feof(FIn)) {
    switch (mode) {
    case 0:
      if (c == '/')
        mode = 1;
      else
        fputc(c, stdout);
      break;
    case 1:
      if (c == '*')
        mode = 2;
      else {
        mode = 0;
        fputc('/', stdout);
        fputc(c, stdout);
      }
      break;
    case 2:
      if (c == '*')
        mode = 3;
      break;
    case 3:
      if (c == '/')
        mode = 0;
      else
        mode = 2;
      break;
    }
    c = fgetc(FIn);
  }
  fclose(FIn);
}


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,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b5 <main+0x45>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11fd <main+0x8d>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1227 <main+0xb7>
jmp    1307 <main+0x197>
mov    -0x20(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     12f6 <main+0x186>
mov    -0x28(%rbp),%rax
lea    0xdbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x2f,-0x1c(%rbp)
jne    1262 <main+0xf2>
movl   $0x1,-0x20(%rbp)
jmp    1273 <main+0x103>
mov    -0x1c(%rbp),%edi
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
call   1050 <fputc@plt>
jmp    12f6 <main+0x186>
cmpl   $0x2a,-0x1c(%rbp)
jne    128e <main+0x11e>
movl   $0x2,-0x20(%rbp)
jmp    12b9 <main+0x149>
movl   $0x0,-0x20(%rbp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
mov    $0x2f,%edi
call   1050 <fputc@plt>
mov    -0x1c(%rbp),%edi
mov    0x2d26(%rip),%rax
mov    (%rax),%esi
call   1050 <fputc@plt>
jmp    12f6 <main+0x186>
cmpl   $0x2a,-0x1c(%rbp)
jne    12cf <main+0x15f>
movl   $0x3,-0x20(%rbp)
jmp    12f6 <main+0x186>
cmpl   $0x2f,-0x1c(%rbp)
jne    12ea <main+0x17a>
movl   $0x0,-0x20(%rbp)
jmp    12f1 <main+0x181>
movl   $0x2,-0x20(%rbp)
jmp    12f6 <main+0x186>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
jmp    1209 <main+0x99>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    125d <main+0xed>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xea2(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     127b <main+0x10b>
mov    %rax,%r12
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11c9 <main+0x59>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
lea    0xe2e(%rip),%r14
mov    0x2dff(%rip),%r15
jmp    1200 <main+0x90>
nopl   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cmp    $0x2f,%ebp
setne  %bl
add    %ebx,%ebx
mov    %r12,%rdi
call   1040 <fgetc@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11b6 <main+0x46>
cmp    $0x3,%ebx
ja     11ea <main+0x7a>
mov    %ebx,%eax
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
mov    $0x1,%ebx
cmp    $0x2f,%ebp
je     11ea <main+0x7a>
jmp    1237 <main+0xc7>
nopl   0x0(%rax)
mov    $0x2,%ebx
cmp    $0x2a,%ebp
je     11ea <main+0x7a>
mov    (%r15),%esi
mov    $0x2f,%edi
call   1050 <fputc@plt>
mov    (%r15),%esi
mov    %ebp,%edi
call   1050 <fputc@plt>
xor    %ebx,%ebx
jmp    11ea <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
cmp    $0x2a,%ebp
sete   %bl
or     $0x2,%ebx
jmp    11ea <main+0x7a>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xda5(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Error: no input filename given.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"Error opening %s\0A\00"
@stdout = global i32 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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp ne i32* %19, null
br i1 %20, label %28, label %21
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %15
%29 = load i32*, i32** %6
%30 = call i32 @fgetc(i32* %29)
store i32 %30, i32* %7
br label %31
31: ; preds = %69, %28
%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 %72
36: ; preds = %31
%37 = load i32, i32* %8
switch i32 %37, label %69 [
i32 0, label %38
i32 1, label %47
i32 2, label %58
i32 3, label %63
]
38: ; preds = %36
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 47
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 1, i32* %8
br label %46
42: ; preds = %38
%43 = load i32, i32* %7
%44 = load i32, i32* @stdout
%45 = call i32 @fputc(i32 %43, i32 %44)
br label %46
46: ; preds = %42, %41
br label %69
47: ; preds = %36
%48 = load i32, i32* %7
%49 = icmp eq i32 %48, 42
br i1 %49, label %50, label %51
50: ; preds = %47
store i32 2, i32* %8
br label %57
51: ; preds = %47
store i32 0, i32* %8
%52 = load i32, i32* @stdout
%53 = call i32 @fputc(i32 47, i32 %52)
%54 = load i32, i32* %7
%55 = load i32, i32* @stdout
%56 = call i32 @fputc(i32 %54, i32 %55)
br label %57
57: ; preds = %51, %50
br label %69
58: ; preds = %36
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 42
br i1 %60, label %61, label %62
61: ; preds = %58
store i32 3, i32* %8
br label %62
62: ; preds = %61, %58
br label %69
63: ; preds = %36
%64 = load i32, i32* %7
%65 = icmp eq i32 %64, 47
br i1 %65, label %66, label %67
66: ; preds = %63
store i32 0, i32* %8
br label %68
67: ; preds = %63
store i32 2, i32* %8
br label %68
68: ; preds = %67, %66
br label %69
69: ; preds = %36, %68, %62, %57, %46
%70 = load i32*, i32** %6
%71 = call i32 @fgetc(i32* %70)
store i32 %71, i32* %7
br label %31
72: ; preds = %31
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Error: no input filename given.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"Error opening %s\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %8
%19 = tail call i32 @fgetc(i32* %11)
%20 = tail call i32 @feof(i32* %11)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %48
22: ; preds = %18, %43
%23 = phi i32 [ %44, %43 ], [ 0, %18 ]
%24 = phi i32 [ %45, %43 ], [ %19, %18 ]
switch i32 %23, label %43 [
i32 0, label %25
i32 1, label %30
i32 2, label %37
i32 3, label %40
]
25: ; preds = %22
%26 = icmp eq i32 %24, 47
br i1 %26, label %43, label %27
27: ; preds = %25
%28 = load i32, i32* @stdout
%29 = tail call i32 @fputc(i32 %24, i32 %28)
br label %43
30: ; preds = %22
%31 = icmp eq i32 %24, 42
br i1 %31, label %43, label %32
32: ; preds = %30
%33 = load i32, i32* @stdout
%34 = tail call i32 @fputc(i32 47, i32 %33)
%35 = load i32, i32* @stdout
%36 = tail call i32 @fputc(i32 %24, i32 %35)
br label %43
37: ; preds = %22
%38 = icmp eq i32 %24, 42
%39 = select i1 %38, i32 3, i32 2
br label %43
40: ; preds = %22
%41 = icmp eq i32 %24, 47
%42 = select i1 %41, i32 0, i32 2
br label %43
43: ; preds = %37, %40, %30, %25, %32, %27, %22
%44 = phi i32 [ %23, %22 ], [ 0, %32 ], [ 0, %27 ], [ 1, %25 ], [ 2, %30 ], [ %39, %37 ], [ %42, %40 ]
%45 = tail call i32 @fgetc(i32* %11)
%46 = tail call i32 @feof(i32* %11)
%47 = icmp eq i32 %46, 0
br i1 %47, label %22, label %48
48: ; preds = %43, %18
%49 = tail call i32 @fclose(i32* %11)
ret i32 0
}