#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);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
char *strcat(char *, char *);
int strlen(char *);
void comFilter(char *FileName) {
  FILE *fIn, *fOut;
  char cTest[320];
  int i;
  if ((fIn = fopen(FileName, "r")) != NULL) {
    if ((fOut = fopen(strcat(FileName, ".tmp"), "w")) != NULL) {
      while (fgets(cTest, 320, fIn) != NULL) {
        for (i = 0; i < strlen(cTest); i++)
          if ((cTest[i] == '/') && cTest[i + 1] == '/') {
            if (i == 0)
              cTest[i] = '\0';
            else {
              cTest[i] = '\n';
              cTest[i + 1] = '\0';
            }
            break;
          }
        if (strlen(cTest) > 0)
          fprintf(fOut, "%s", cTest);
      }
    } else {
      printf("ERROR: Can't create output file %s.\n", FileName);
      exit(1);
    }
  } else {
    printf("ERROR: Can't open input file %s.\n", FileName);
    exit(1);
  }
  fclose(fIn);
  fclose(fOut);
}


x86 assembly (clang, -O0):
<comFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     131a <comFilter+0x19a>
mov    -0x8(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1090 <strcat@plt>
mov    %rax,%rdi
lea    0xe40(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12fb <comFilter+0x17b>
jmp    11df <comFilter+0x5f>
lea    -0x160(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x140,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12f6 <comFilter+0x176>
movl   $0x0,-0x164(%rbp)
mov    -0x164(%rbp),%eax
mov    %eax,-0x168(%rbp)
lea    -0x160(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x168(%rbp),%eax
cmp    %ecx,%eax
jge    12c5 <comFilter+0x145>
movslq -0x164(%rbp),%rax
movsbl -0x160(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    12ac <comFilter+0x12c>
mov    -0x164(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x160(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    12ac <comFilter+0x12c>
cmpl   $0x0,-0x164(%rbp)
jne    1285 <comFilter+0x105>
movslq -0x164(%rbp),%rax
movb   $0x0,-0x160(%rbp,%rax,1)
jmp    12a7 <comFilter+0x127>
movslq -0x164(%rbp),%rax
movb   $0xa,-0x160(%rbp,%rax,1)
0a
mov    -0x164(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x160(%rbp,%rax,1)
jmp    12c5 <comFilter+0x145>
jmp    12b1 <comFilter+0x131>
mov    -0x164(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x164(%rbp)
jmp    1208 <comFilter+0x88>
lea    -0x160(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jle    12f1 <comFilter+0x171>
mov    -0x18(%rbp),%rdi
lea    -0x160(%rbp),%rdx
lea    0xd1d(%rip),%rsi
call   1070 <fprintf@plt>
jmp    11df <comFilter+0x5f>
jmp    1315 <comFilter+0x195>
mov    -0x8(%rbp),%rsi
lea    0xd06(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1334 <comFilter+0x1b4>
mov    -0x8(%rbp),%rsi
lea    0xd0c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comFilter>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    %rdi,%rbx
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1271 <comFilter+0x101>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <strlen@plt>
movl   $0x706d742e,(%rbx,%rax,1)
movb   $0x0,0x4(%rbx,%rax,1)
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     127a <comFilter+0x10a>
mov    %rax,%r14
mov    %rsp,%r12
nopl   (%rax)
mov    %r12,%rdi
mov    $0x140,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1250 <comFilter+0xe0>
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1237 <comFilter+0xc7>
mov    %r12,%r13
xor    %ebx,%ebx
jmp    1217 <comFilter+0xa7>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
add    $0x1,%r13
cmp    %rax,%rbx
jge    1237 <comFilter+0xc7>
cmpb   $0x2f,0x0(%r13)
jne    1200 <comFilter+0x90>
cmpb   $0x2f,0x1(%r13)
jne    1200 <comFilter+0x90>
test   %ebx,%ebx
je     1232 <comFilter+0xc2>
movb   $0xa,0x0(%r13)
add    $0x1,%r13
movb   $0x0,0x0(%r13)
mov    %r12,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11d0 <comFilter+0x60>
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <fputs@plt>
jmp    11d0 <comFilter+0x60>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x140,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xdb6(%rip),%rdi
jmp    1281 <comFilter+0x111>
lea    0xd88(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c".tmp\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [37 x i8] c"ERROR: Can't create output file %s.\0A\00"
@.str.5 = [34 x i8] c"ERROR: Can't open input file %s.\0A\00"
define void @comFilter(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [320 x i8]
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %77
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i8* @strcat(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %72
15: ; preds = %10
br label %16
16: ; preds = %70, %15
%17 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i32* @fgets(i8* %17, i32 320, i32* %18)
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %71
21: ; preds = %16
store i32 0, i32* %6
br label %22
22: ; preds = %59, %21
%23 = load i32, i32* %6
%24 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %62
27: ; preds = %22
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 47
br i1 %33, label %34, label %58
34: ; preds = %27
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 47
br i1 %41, label %42, label %58
42: ; preds = %34
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 %47
store i8 0, i8* %48
br label %57
49: ; preds = %42
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 %51
store i8 10, i8* %52
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 %55
store i8 0, i8* %56
br label %57
57: ; preds = %49, %45
br label %62
58: ; preds = %34, %27
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %22
62: ; preds = %57, %22
%63 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%64 = call i32 @strlen(i8* %63)
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i32*, i32** %4
%68 = getelementptr inbounds [320 x i8], [320 x i8]* %5, i64 0, i64 0
%69 = call i32 @fprintf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %66, %62
br label %16
71: ; preds = %16
br label %76
72: ; preds = %10
%73 = load i8*, i8** %2
%74 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %71
br label %81
77: ; preds = %1
%78 = load i8*, i8** %2
%79 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %78)
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %76
%82 = load i32*, i32** %3
%83 = call i32 @fclose(i32* %82)
%84 = load i32*, i32** %4
%85 = call i32 @fclose(i32* %84)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c".tmp\00"
@.str.2 = [2 x i8] c"w\00"
@.str.4 = [37 x i8] c"ERROR: Can't create output file %s.\0A\00"
@.str.5 = [34 x i8] c"ERROR: Can't open input file %s.\0A\00"
define void @comFilter(i8* %0) {
%2 = alloca [320 x i8]
%3 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %52, label %6
6: ; preds = %1
%7 = tail call i64 bitcast (i32 (i8*)* @strlen to i64 (i8*)*)(i8* %0)
%8 = getelementptr i8, i8* %0, i64 %7
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %8, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5, i1 false)
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %49, label %11
11: ; preds = %6
%12 = call i32* @fgets(i8* %3, i32 320, i32* %4)
%13 = icmp eq i32* %12, null
br i1 %13, label %55, label %14
14: ; preds = %11, %46
%15 = call i32 @strlen(i8* %3)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %14, %35
%18 = phi i64 [ %22, %35 ], [ 0, %14 ]
%19 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 47
%22 = add nuw nsw i64 %18, 1
br i1 %21, label %23, label %35
23: ; preds = %17
%24 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 %22
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 47
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = trunc i64 %18 to i32
%29 = and i64 %18, 4294967295
%30 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 %29
%31 = icmp eq i32 %28, 0
br i1 %31, label %39, label %32
32: ; preds = %27
%33 = and i64 %22, 4294967295
%34 = getelementptr inbounds [320 x i8], [320 x i8]* %2, i64 0, i64 %33
store i8 10, i8* %30
br label %39
35: ; preds = %17, %23
%36 = call i32 @strlen(i8* %3)
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %22, %37
br i1 %38, label %17, label %41
39: ; preds = %27, %32
%40 = phi i8* [ %34, %32 ], [ %30, %27 ]
store i8 0, i8* %40
br label %41
41: ; preds = %35, %39, %14
%42 = call i32 @strlen(i8* %3)
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 @fputs(i8* %3, i32* %9)
br label %46
46: ; preds = %44, %41
%47 = call i32* @fgets(i8* %3, i32 320, i32* %4)
%48 = icmp eq i32* %47, null
br i1 %48, label %55, label %14
49: ; preds = %6
%50 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%51 = tail call i32 @exit(i32 1)
unreachable
52: ; preds = %1
%53 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %0)
%54 = tail call i32 @exit(i32 1)
unreachable
55: ; preds = %46, %11
%56 = call i32 @fclose(i32* %4)
%57 = call i32 @fclose(i32* %9)
ret void
}