#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*/ comment(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  int last, current, next;
  FILE *read = fopen("in.c", "r");
  FILE *write = fopen("out.txt", "w");
  while (current != EOF) {
    while ((!comment(last, (current = getc(read)))) && (current != EOF)) {
      if (current != '/') {
        putc(current, write);
        last = current;
      } else {
        if ((next = getc(read)) == '*') {
          last = current;
          ungetc(next, read);
          fflush(read);
        } else {
          ungetc(next, read);
          fflush(read);
          putc(current, write);
          last = current;
        }
      }
    }
    while (((current = getc(read)) != EOF) && (!comment(last, current))) {
      last = current;
    }
  }
  fclose(read);
  fclose(write);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    0xe63(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%eax
je     12fd <main+0x18d>
jmp    11cb <main+0x5b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <getc@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%esi
mov    %esi,-0x18(%rbp)
call   1040 <comment@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    1209 <main+0x99>
mov    -0x18(%rbp),%eax
mov    0x2de7(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1219 <main+0xa9>
jmp    12a0 <main+0x130>
cmpl   $0x2f,-0x18(%rbp)
je     123a <main+0xca>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <putc@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    129b <main+0x12b>
mov    -0x28(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x2a,%eax
jne    126f <main+0xff>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1070 <ungetc@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fflush@plt>
jmp    1296 <main+0x126>
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1070 <ungetc@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fflush@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <putc@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    129b <main+0x12b>
jmp    11cb <main+0x5b>
jmp    12a5 <main+0x135>
mov    -0x28(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
mov    0x2d2c(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x39(%rbp)
je     12dd <main+0x16d>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <comment@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    12ed <main+0x17d>
jmp    12f8 <main+0x188>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12a5 <main+0x135>
jmp    11b4 <main+0x44>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe81(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe72(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x2e3d(%rip),%r12
jmp    11c5 <main+0x55>
nopl   (%rax)
mov    $0x2a,%edi
mov    %r15,%rsi
call   1070 <ungetc@plt>
mov    %r15,%rdi
call   1060 <fflush@plt>
mov    %r15,%rdi
call   1090 <getc@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <comment@plt>
test   %eax,%eax
jne    121c <main+0xac>
cmp    (%r12),%ebp
je     121c <main+0xac>
mov    %ebp,%ebx
cmp    $0x2f,%ebp
jne    1210 <main+0xa0>
mov    %r15,%rdi
call   1090 <getc@plt>
cmp    $0x2a,%eax
je     11b0 <main+0x40>
mov    %eax,%edi
mov    %r15,%rsi
call   1070 <ungetc@plt>
mov    %r15,%rdi
call   1060 <fflush@plt>
mov    $0x2f,%edi
jmp    1212 <main+0xa2>
nop
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <putc@plt>
jmp    11c5 <main+0x55>
mov    %ebx,%ebp
xchg   %ax,%ax
mov    %ebp,%ebx
mov    %r15,%rdi
call   1090 <getc@plt>
cmp    (%r12),%eax
je     1245 <main+0xd5>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <comment@plt>
test   %eax,%eax
je     1220 <main+0xb0>
cmp    (%r12),%ebp
jne    11c5 <main+0x55>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"in.c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"out.txt\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = 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
%9 = alloca i32*
%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 ([5 x i8], [5 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** %9
%12 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 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* %12, i32** %10
br label %13
13: ; preds = %77, %2
%14 = load i32, i32* %7
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %78
17: ; preds = %13
br label %18
18: ; preds = %60, %17
%19 = load i32, i32* %6
%20 = load i32*, i32** %9
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %7
%22 = call i32 @comment(i32 %19, i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %18
%25 = load i32, i32* %7
%26 = load i32, i32* @EOF
%27 = icmp ne i32 %25, %26
br label %28
28: ; preds = %24, %18
%29 = phi i1 [ false, %18 ], [ %27, %24 ]
br i1 %29, label %30, label %61
30: ; preds = %28
%31 = load i32, i32* %7
%32 = icmp ne i32 %31, 47
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i32, i32* %7
%35 = load i32*, i32** %10
%36 = call i32 @putc(i32 %34, i32* %35)
%37 = load i32, i32* %7
store i32 %37, i32* %6
br label %60
38: ; preds = %30
%39 = load i32*, i32** %9
%40 = call i32 @getc(i32* %39)
store i32 %40, i32* %8
%41 = icmp eq i32 %40, 42
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i32, i32* %7
store i32 %43, i32* %6
%44 = load i32, i32* %8
%45 = load i32*, i32** %9
%46 = call i32 @ungetc(i32 %44, i32* %45)
%47 = load i32*, i32** %9
%48 = call i32 @fflush(i32* %47)
br label %59
49: ; preds = %38
%50 = load i32, i32* %8
%51 = load i32*, i32** %9
%52 = call i32 @ungetc(i32 %50, i32* %51)
%53 = load i32*, i32** %9
%54 = call i32 @fflush(i32* %53)
%55 = load i32, i32* %7
%56 = load i32*, i32** %10
%57 = call i32 @putc(i32 %55, i32* %56)
%58 = load i32, i32* %7
store i32 %58, i32* %6
br label %59
59: ; preds = %49, %42
br label %60
60: ; preds = %59, %33
br label %18
61: ; preds = %28
br label %62
62: ; preds = %75, %61
%63 = load i32*, i32** %9
%64 = call i32 @getc(i32* %63)
store i32 %64, i32* %7
%65 = load i32, i32* @EOF
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %73
67: ; preds = %62
%68 = load i32, i32* %6
%69 = load i32, i32* %7
%70 = call i32 @comment(i32 %68, i32 %69)
%71 = icmp ne i32 %70, 0
%72 = xor i1 %71, true
br label %73
73: ; preds = %67, %62
%74 = phi i1 [ false, %62 ], [ %72, %67 ]
br i1 %74, label %75, label %77
75: ; preds = %73
%76 = load i32, i32* %7
store i32 %76, i32* %6
br label %62
77: ; preds = %73
br label %13
78: ; preds = %13
%79 = load i32*, i32** %9
%80 = call i32 @fclose(i32* %79)
%81 = load i32*, i32** %10
%82 = call i32 @fclose(i32* %81)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"in.c\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"out.txt\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %5
5: ; preds = %2, %45
%6 = phi i32 [ %38, %45 ], [ undef, %2 ]
%7 = tail call i32 @getc(i32* %3)
%8 = tail call i32 @comment(i32 %6, i32 %7)
%9 = icmp eq i32 %8, 0
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %7, %10
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %13, label %35
13: ; preds = %5, %28
%14 = phi i32 [ %29, %28 ], [ %7, %5 ]
%15 = icmp eq i32 %14, 47
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i32 @putc(i32 %14, i32* %4)
br label %28
18: ; preds = %13
%19 = tail call i32 @getc(i32* %3)
%20 = icmp eq i32 %19, 42
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @ungetc(i32 42, i32* %3)
%23 = tail call i32 @fflush(i32* %3)
br label %28
24: ; preds = %18
%25 = tail call i32 @ungetc(i32 %19, i32* %3)
%26 = tail call i32 @fflush(i32* %3)
%27 = tail call i32 @putc(i32 47, i32* %4)
br label %28
28: ; preds = %21, %24, %16
%29 = tail call i32 @getc(i32* %3)
%30 = tail call i32 @comment(i32 %14, i32 %29)
%31 = icmp eq i32 %30, 0
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %29, %32
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %13, label %35
35: ; preds = %28, %5
%36 = phi i32 [ %6, %5 ], [ %14, %28 ]
br label %37
37: ; preds = %35, %42
%38 = phi i32 [ %39, %42 ], [ %36, %35 ]
%39 = tail call i32 @getc(i32* %3)
%40 = load i32, i32* @EOF
%41 = icmp eq i32 %39, %40
br i1 %41, label %48, label %42
42: ; preds = %37
%43 = tail call i32 @comment(i32 %38, i32 %39)
%44 = icmp eq i32 %43, 0
br i1 %44, label %37, label %45
45: ; preds = %42
%46 = load i32, i32* @EOF
%47 = icmp eq i32 %39, %46
br i1 %47, label %48, label %5
48: ; preds = %45, %37
%49 = tail call i32 @fclose(i32* %3)
%50 = tail call i32 @fclose(i32* %4)
ret i32 0
}