#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*/ fpos_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ fsetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main() {
  char buf[1024], tmp[1024], *pch, *pchtmp;
  FILE *pfi, *pfo;
  fpos_t pos;
  enum State { FREE, BLOCK, QUOTE, TEST } state = FREE;
  printf("Please input the file name (with no .c): ");
  gets(buf);
  strcpy(tmp, buf);
  strcat(buf, ".c");
  strcat(tmp, "2.c");
  pfi = fopen(buf, "r");
  if (pfi == NULL) {
    printf("No such file in current directory.");
    getchar();
    return 0;
  }
  pfo = fopen(tmp, "w");
  if (pfo == NULL) {
    printf("Can not create the output file.");
    fclose(pfi);
    getchar();
    return 0;
  }
  while (1) {
    if (state != TEST) {
      fgetpos(pfi, &pos);
      if (!fgets(buf, 1024, pfi))
        break;
    }
    switch (state) {
    case FREE:
      pch = strchr(buf, '\"');
      if (pch != NULL) {
        (*pch) = 0;
        if (pchtmp = strchr(buf, '/'))
          if (*(pchtmp + 1) == '*' || *(pchtmp + 1) == '/') {
            (*pch) = '\"';
            state = TEST;
            break;
          }
        fputs(buf, pfo);
        fputs("\"", pfo);
        fsetpos(pfi, &pos);
        fseek(pfi, strlen(buf) + 1, SEEK_CUR);
        state = QUOTE;
      } else
        state = TEST;
      break;
    case QUOTE:
      pch = strchr(buf, '\"');
      if (pch != NULL) {
        (*pch) = 0;
        fputs(buf, pfo);
        fputs("\"", pfo);
        fsetpos(pfi, &pos);
        fseek(pfi, strlen(buf) + 1, SEEK_CUR);
        state = FREE;
      } else
        state = TEST;
      break;
    case TEST:
      pch = strchr(buf, '/');
      while (pch) {
        if (*(pch + 1) == '/') {
          (*pch) = 0;
          fputs(buf, pfo);
          fputs("\n", pfo);
          state = FREE;
          break;
        } else if (*(pch + 1) == '*') {
          (*pch) = 0;
          fputs(buf, pfo);
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) + 2, SEEK_CUR);
          state = BLOCK;
          break;
        } else
          pch = strchr(pch + 1, '/');
      }
      if (pch == NULL) {
        fputs(buf, pfo);
        state = FREE;
      }
      break;
    case BLOCK:
      pch = strchr(buf, '*');
      while (pch) {
        if (*(pch + 1) == '/') {
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) - strlen(pch + 2), SEEK_CUR);
          state = FREE;
          break;
        } else
          pch = strchr(pch + 1, '*');
      }
      if (pch == NULL)
        fputs("\n", pfo);
      break;
    }
  }
  fclose(pfi);
  fclose(pfo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x838(%rbp)
lea    0xe0d(%rip),%rdi
call   1070 <printf@plt>
lea    -0x410(%rbp),%rdi
call   10c0 <gets@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1294 <main+0xb4>
lea    0xdc4(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <getchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    17b6 <main+0x5d6>
lea    -0x810(%rbp),%rdi
lea    0xdc1(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x830(%rbp)
jne    12e7 <main+0x107>
lea    0xda2(%rip),%rdi
call   1070 <printf@plt>
mov    -0x828(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   10b0 <getchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    17b6 <main+0x5d6>
jmp    12ec <main+0x10c>
cmpl   $0x3,-0x838(%rbp)
je     1337 <main+0x157>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   1080 <fgetpos@plt>
lea    -0x410(%rbp),%rdi
mov    -0x828(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%eax
jne    1332 <main+0x152>
jmp    1797 <main+0x5b7>
jmp    1337 <main+0x157>
mov    -0x838(%rbp),%eax
mov    %rax,-0x840(%rbp)
sub    $0x3,%rax
ja     1792 <main+0x5b2>
mov    -0x840(%rbp),%rax
lea    0xca4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x410(%rbp),%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     147b <main+0x29b>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x820(%rbp)
cmp    $0x0,%rax
je     13fd <main+0x21d>
mov    -0x820(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2a,%eax
je     13df <main+0x1ff>
mov    -0x820(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    13f8 <main+0x218>
mov    -0x818(%rbp),%rax
movb   $0x22,(%rax)
movl   $0x3,-0x838(%rbp)
jmp    1792 <main+0x5b2>
jmp    13fd <main+0x21d>
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xc67(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   10f0 <fsetpos@plt>
mov    -0x828(%rbp),%rax
mov    %rax,-0x848(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x848(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    0x2b83(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x2,-0x838(%rbp)
jmp    1485 <main+0x2a5>
movl   $0x3,-0x838(%rbp)
jmp    1792 <main+0x5b2>
lea    -0x410(%rbp),%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     1538 <main+0x358>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xbaa(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   10f0 <fsetpos@plt>
mov    -0x828(%rbp),%rax
mov    %rax,-0x850(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x850(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    0x2ac6(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x0,-0x838(%rbp)
jmp    1542 <main+0x362>
movl   $0x3,-0x838(%rbp)
jmp    1792 <main+0x5b2>
lea    -0x410(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     166f <main+0x48f>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    15c0 <main+0x3e0>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xadb(%rip),%rdi
call   1090 <fputs@plt>
movl   $0x0,-0x838(%rbp)
jmp    166f <main+0x48f>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2a,%eax
jne    1649 <main+0x469>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   10f0 <fsetpos@plt>
mov    -0x828(%rbp),%rax
mov    %rax,-0x858(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x858(%rbp),%rdi
mov    %rax,%rsi
add    $0x2,%rsi
mov    0x29b5(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x1,-0x838(%rbp)
jmp    166f <main+0x48f>
mov    -0x818(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
jmp    166a <main+0x48a>
jmp    155f <main+0x37f>
cmpq   $0x0,-0x818(%rbp)
jne    169a <main+0x4ba>
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
movl   $0x0,-0x838(%rbp)
jmp    1792 <main+0x5b2>
lea    -0x410(%rbp),%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     176c <main+0x58c>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    174b <main+0x56b>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   10f0 <fsetpos@plt>
mov    -0x828(%rbp),%rax
mov    %rax,-0x860(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x868(%rbp)
mov    -0x818(%rbp),%rdi
add    $0x2,%rdi
call   1050 <strlen@plt>
mov    -0x868(%rbp),%rsi
mov    -0x860(%rbp),%rdi
sub    %rax,%rsi
mov    0x28b3(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x0,-0x838(%rbp)
jmp    176c <main+0x58c>
mov    -0x818(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
jmp    16b7 <main+0x4d7>
cmpq   $0x0,-0x818(%rbp)
jne    178d <main+0x5ad>
mov    -0x830(%rbp),%rsi
lea    0x8ff(%rip),%rdi
call   1090 <fputs@plt>
jmp    1792 <main+0x5b2>
jmp    12ec <main+0x10c>
mov    -0x828(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x830(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0xdf8(%rip),%rdi
call   1070 <printf@plt>
lea    0x410(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <gets@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcat@plt>
lea    0xde7(%rip),%rsi
mov    %r14,%rdi
call   1110 <strcat@plt>
lea    0xddc(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1528 <main+0x338>
mov    %rax,%r13
lea    0xde6(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1536 <main+0x346>
mov    %rax,%r14
xor    %ebp,%ebp
lea    0x410(%rsp),%r15
lea    0xc(%rsp),%r12
jmp    12ad <main+0xbd>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
xor    %ebp,%ebp
cmp    $0x3,%ebp
jne    12f0 <main+0x100>
mov    %r15,%rdi
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12a0 <main+0xb0>
movzbl 0x1(%rax),%ecx
cmp    $0x2a,%cl
je     142a <main+0x23a>
cmp    $0x2f,%cl
je     146a <main+0x27a>
add    $0x1,%rax
mov    %rax,%rdi
jmp    12c0 <main+0xd0>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <fgetpos@plt>
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
test   %eax,%eax
je     1516 <main+0x326>
cmp    $0x2,%ebp
je     1373 <main+0x183>
cmp    $0x1,%ebp
je     13d1 <main+0x1e1>
test   %ebp,%ebp
jne    12ad <main+0xbd>
mov    %r15,%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     12ad <main+0xbd>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     148c <main+0x29c>
mov    0x1(%rax),%al
cmp    $0x2f,%al
je     136b <main+0x17b>
cmp    $0x2a,%al
jne    148c <main+0x29c>
movb   $0x22,(%rbx)
jmp    12ad <main+0xbd>
mov    %r15,%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    $0x3,%ebp
test   %rax,%rax
je     12ad <main+0xbd>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    $0x22,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1100 <fsetpos@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rsi
mov    0x2c21(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
jmp    150a <main+0x31a>
mov    %r15,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1413 <main+0x223>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x2f,0x1(%rbx)
je     14d6 <main+0x2e6>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    13f0 <main+0x200>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
mov    $0x1,%ebp
jmp    12ad <main+0xbd>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1100 <fsetpos@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x2(%rax),%rsi
mov    0x2b92(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   10e0 <fseek@plt>
mov    $0x1,%ebp
jmp    12ad <main+0xbd>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
xor    %ebp,%ebp
jmp    12ad <main+0xbd>
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    $0x22,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1100 <fsetpos@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rsi
mov    0x2b26(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   10e0 <fseek@plt>
mov    $0x2,%ebp
jmp    12ad <main+0xbd>
mov    %r13,%rdi
mov    %r12,%rsi
call   1100 <fsetpos@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
add    $0x2,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
sub    %rax,%rbp
mov    0x2ae6(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %rbp,%rsi
call   10e0 <fseek@plt>
xor    %ebp,%ebp
jmp    12ad <main+0xbd>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    1551 <main+0x361>
lea    0xb01(%rip),%rdi
call   1070 <printf@plt>
jmp    154a <main+0x35a>
lea    0xb18(%rip),%rdi
call   1070 <printf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   10c0 <getchar@plt>
xor    %eax,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Please input the file name (with no .c): \00"
@.str.1 = [3 x i8] c".c\00"
@.str.2 = [4 x i8] c"2.c\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [35 x i8] c"No such file in current directory.\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [32 x i8] c"Can not create the output file.\00"
@.str.7 = [2 x i8] c"\22\00"
@SEEK_CUR = global i32 0
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%10 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%12 = call i32 @gets(i8* %11)
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %27
24: ; preds = %0
%25 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %209
27: ; preds = %0
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %29, i32** %7
%30 = load i32*, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%34 = load i32*, i32** %6
%35 = call i32 @fclose(i32* %34)
%36 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %209
37: ; preds = %27
br label %38
38: ; preds = %37, %203
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 3
br i1 %40, label %41, label %50
41: ; preds = %38
%42 = load i32*, i32** %6
%43 = call i32 @fgetpos(i32* %42, i32* %8)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%45 = load i32*, i32** %6
%46 = call i32 @fgets(i8* %44, i32 1024, i32* %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %49, label %48
48: ; preds = %41
br label %204
49: ; preds = %41
br label %50
50: ; preds = %49, %38
%51 = load i32, i32* %9
switch i32 %51, label %203 [
i32 0, label %52
i32 2, label %93
i32 3, label %115
i32 1, label %167
]
52: ; preds = %50
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%54 = call i8* @strchr(i8* %53, i8 signext 34)
store i8* %54, i8** %4
%55 = load i8*, i8** %4
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %91
57: ; preds = %52
%58 = load i8*, i8** %4
store i8 0, i8* %58
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%60 = call i8* @strchr(i8* %59, i8 signext 47)
store i8* %60, i8** %5
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %77
62: ; preds = %57
%63 = load i8*, i8** %5
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 42
br i1 %67, label %74, label %68
68: ; preds = %62
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 1
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 47
br i1 %73, label %74, label %76
74: ; preds = %68, %62
%75 = load i8*, i8** %4
store i8 34, i8* %75
store i32 3, i32* %9
br label %203
76: ; preds = %68
br label %77
77: ; preds = %76, %57
%78 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%79 = load i32*, i32** %7
%80 = call i32 @fputs(i8* %78, i32* %79)
%81 = load i32*, i32** %7
%82 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32* %81)
%83 = load i32*, i32** %6
%84 = call i32 @fsetpos(i32* %83, i32* %8)
%85 = load i32*, i32** %6
%86 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%87 = call i64 @strlen(i8* %86)
%88 = add nsw i64 %87, 1
%89 = load i32, i32* @SEEK_CUR
%90 = call i32 @fseek(i32* %85, i64 %88, i32 %89)
store i32 2, i32* %9
br label %92
91: ; preds = %52
store i32 3, i32* %9
br label %92
92: ; preds = %91, %77
br label %203
93: ; preds = %50
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%95 = call i8* @strchr(i8* %94, i8 signext 34)
store i8* %95, i8** %4
%96 = load i8*, i8** %4
%97 = icmp ne i8* %96, null
br i1 %97, label %98, label %113
98: ; preds = %93
%99 = load i8*, i8** %4
store i8 0, i8* %99
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%101 = load i32*, i32** %7
%102 = call i32 @fputs(i8* %100, i32* %101)
%103 = load i32*, i32** %7
%104 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32* %103)
%105 = load i32*, i32** %6
%106 = call i32 @fsetpos(i32* %105, i32* %8)
%107 = load i32*, i32** %6
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%109 = call i64 @strlen(i8* %108)
%110 = add nsw i64 %109, 1
%111 = load i32, i32* @SEEK_CUR
%112 = call i32 @fseek(i32* %107, i64 %110, i32 %111)
store i32 0, i32* %9
br label %114
113: ; preds = %93
store i32 3, i32* %9
br label %114
114: ; preds = %113, %98
br label %203
115: ; preds = %50
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%117 = call i8* @strchr(i8* %116, i8 signext 47)
store i8* %117, i8** %4
br label %118
118: ; preds = %158, %115
%119 = load i8*, i8** %4
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %159
121: ; preds = %118
%122 = load i8*, i8** %4
%123 = getelementptr inbounds i8, i8* %122, i64 1
%124 = load i8, i8* %123
%125 = sext i8 %124 to i32
%126 = icmp eq i32 %125, 47
br i1 %126, label %127, label %134
127: ; preds = %121
%128 = load i8*, i8** %4
store i8 0, i8* %128
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%130 = load i32*, i32** %7
%131 = call i32 @fputs(i8* %129, i32* %130)
%132 = load i32*, i32** %7
%133 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %132)
store i32 0, i32* %9
br label %159
134: ; preds = %121
%135 = load i8*, i8** %4
%136 = getelementptr inbounds i8, i8* %135, i64 1
%137 = load i8, i8* %136
%138 = sext i8 %137 to i32
%139 = icmp eq i32 %138, 42
br i1 %139, label %140, label %153
140: ; preds = %134
%141 = load i8*, i8** %4
store i8 0, i8* %141
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%143 = load i32*, i32** %7
%144 = call i32 @fputs(i8* %142, i32* %143)
%145 = load i32*, i32** %6
%146 = call i32 @fsetpos(i32* %145, i32* %8)
%147 = load i32*, i32** %6
%148 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%149 = call i64 @strlen(i8* %148)
%150 = add nsw i64 %149, 2
%151 = load i32, i32* @SEEK_CUR
%152 = call i32 @fseek(i32* %147, i64 %150, i32 %151)
store i32 1, i32* %9
br label %159
153: ; preds = %134
%154 = load i8*, i8** %4
%155 = getelementptr inbounds i8, i8* %154, i64 1
%156 = call i8* @strchr(i8* %155, i8 signext 47)
store i8* %156, i8** %4
br label %157
157: ; preds = %153
br label %158
158: ; preds = %157
br label %118
159: ; preds = %140, %127, %118
%160 = load i8*, i8** %4
%161 = icmp eq i8* %160, null
br i1 %161, label %162, label %166
162: ; preds = %159
%163 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%164 = load i32*, i32** %7
%165 = call i32 @fputs(i8* %163, i32* %164)
store i32 0, i32* %9
br label %166
166: ; preds = %162, %159
br label %203
167: ; preds = %50
%168 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%169 = call i8* @strchr(i8* %168, i8 signext 42)
store i8* %169, i8** %4
br label %170
170: ; preds = %195, %167
%171 = load i8*, i8** %4
%172 = icmp ne i8* %171, null
br i1 %172, label %173, label %196
173: ; preds = %170
%174 = load i8*, i8** %4
%175 = getelementptr inbounds i8, i8* %174, i64 1
%176 = load i8, i8* %175
%177 = sext i8 %176 to i32
%178 = icmp eq i32 %177, 47
br i1 %178, label %179, label %191
179: ; preds = %173
%180 = load i32*, i32** %6
%181 = call i32 @fsetpos(i32* %180, i32* %8)
%182 = load i32*, i32** %6
%183 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%184 = call i64 @strlen(i8* %183)
%185 = load i8*, i8** %4
%186 = getelementptr inbounds i8, i8* %185, i64 2
%187 = call i64 @strlen(i8* %186)
%188 = sub nsw i64 %184, %187
%189 = load i32, i32* @SEEK_CUR
%190 = call i32 @fseek(i32* %182, i64 %188, i32 %189)
store i32 0, i32* %9
br label %196
191: ; preds = %173
%192 = load i8*, i8** %4
%193 = getelementptr inbounds i8, i8* %192, i64 1
%194 = call i8* @strchr(i8* %193, i8 signext 42)
store i8* %194, i8** %4
br label %195
195: ; preds = %191
br label %170
196: ; preds = %179, %170
%197 = load i8*, i8** %4
%198 = icmp eq i8* %197, null
br i1 %198, label %199, label %202
199: ; preds = %196
%200 = load i32*, i32** %7
%201 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %200)
br label %202
202: ; preds = %199, %196
br label %203
203: ; preds = %50, %202, %166, %114, %92, %74
br label %38
204: ; preds = %48
%205 = load i32*, i32** %6
%206 = call i32 @fclose(i32* %205)
%207 = load i32*, i32** %7
%208 = call i32 @fclose(i32* %207)
store i32 0, i32* %1
br label %209
209: ; preds = %204, %32, %24
%210 = load i32, i32* %1
ret i32 %210
}

LLVM IR (-O2):
@.str = [42 x i8] c"Please input the file name (with no .c): \00"
@.str.1 = [3 x i8] c".c\00"
@.str.2 = [4 x i8] c"2.c\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [35 x i8] c"No such file in current directory.\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [32 x i8] c"Can not create the output file.\00"
@SEEK_CUR = global i32 0
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @gets(i8* %4)
%9 = call i32 @strcpy(i8* %5, i8* %4)
%10 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (...) @getchar()
br label %109
17: ; preds = %0
%18 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @fclose(i32* %12)
%23 = call i32 (...) @getchar()
br label %109
24: ; preds = %17, %71
%25 = phi i32 [ %72, %71 ], [ 0, %17 ]
%26 = icmp eq i32 %25, 3
br i1 %26, label %61, label %27
27: ; preds = %24
%28 = call i32 @fgetpos(i32* %12, i32* %3)
%29 = call i32 @fgets(i8* %4, i32 1024, i32* %12)
%30 = icmp eq i32 %29, 0
br i1 %30, label %106, label %31
31: ; preds = %27
switch i32 %25, label %71 [
i32 0, label %32
i32 2, label %50
i32 1, label %85
]
32: ; preds = %31
%33 = call i8* @strchr(i8* %4, i8 signext 34)
%34 = icmp eq i8* %33, null
br i1 %34, label %71, label %35
35: ; preds = %32
store i8 0, i8* %33
%36 = call i8* @strchr(i8* %4, i8 signext 47)
%37 = icmp eq i8* %36, null
br i1 %37, label %42, label %38
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %36, i64 1
%40 = load i8, i8* %39
switch i8 %40, label %42 [
i8 42, label %41
i8 47, label %41
]
41: ; preds = %38, %38
store i8 34, i8* %33
br label %71
42: ; preds = %38, %35
%43 = call i32 @fputs(i8* %4, i32* %18)
%44 = call i32 @fputc(i32 34, i32* %18)
%45 = call i32 @fsetpos(i32* %12, i32* %3)
%46 = call i64 @strlen(i8* %4)
%47 = add nsw i64 %46, 1
%48 = load i32, i32* @SEEK_CUR
%49 = call i32 @fseek(i32* %12, i64 %47, i32 %48)
br label %71
50: ; preds = %31
%51 = call i8* @strchr(i8* %4, i8 signext 34)
%52 = icmp eq i8* %51, null
br i1 %52, label %71, label %53
53: ; preds = %50
store i8 0, i8* %51
%54 = call i32 @fputs(i8* %4, i32* %18)
%55 = call i32 @fputc(i32 34, i32* %18)
%56 = call i32 @fsetpos(i32* %12, i32* %3)
%57 = call i64 @strlen(i8* %4)
%58 = add nsw i64 %57, 1
%59 = load i32, i32* @SEEK_CUR
%60 = call i32 @fseek(i32* %12, i64 %58, i32 %59)
br label %71
61: ; preds = %24
%62 = call i8* @strchr(i8* %4, i8 signext 47)
%63 = icmp eq i8* %62, null
br i1 %63, label %83, label %64
64: ; preds = %61, %80
%65 = phi i8* [ %81, %80 ], [ %62, %61 ]
%66 = getelementptr inbounds i8, i8* %65, i64 1
%67 = load i8, i8* %66
switch i8 %67, label %80 [
i8 47, label %68
i8 42, label %73
]
68: ; preds = %64
store i8 0, i8* %65
%69 = call i32 @fputs(i8* %4, i32* %18)
%70 = call i32 @fputc(i32 10, i32* %18)
br label %71
71: ; preds = %68, %73, %96, %50, %32, %104, %83, %53, %42, %31, %41
%72 = phi i32 [ %25, %31 ], [ 1, %104 ], [ 0, %96 ], [ 0, %83 ], [ 0, %53 ], [ 3, %41 ], [ 2, %42 ], [ 3, %32 ], [ 3, %50 ], [ 1, %73 ], [ 0, %68 ]
br label %24
73: ; preds = %64
store i8 0, i8* %65
%74 = call i32 @fputs(i8* %4, i32* %18)
%75 = call i32 @fsetpos(i32* %12, i32* %3)
%76 = call i64 @strlen(i8* %4)
%77 = add nsw i64 %76, 2
%78 = load i32, i32* @SEEK_CUR
%79 = call i32 @fseek(i32* %12, i64 %77, i32 %78)
br label %71
80: ; preds = %64
%81 = call i8* @strchr(i8* %66, i8 signext 47)
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %64
83: ; preds = %80, %61
%84 = call i32 @fputs(i8* %4, i32* %18)
br label %71
85: ; preds = %31
%86 = call i8* @strchr(i8* %4, i8 signext 42)
%87 = icmp eq i8* %86, null
br i1 %87, label %104, label %88
88: ; preds = %85, %93
%89 = phi i8* [ %94, %93 ], [ %86, %85 ]
%90 = getelementptr inbounds i8, i8* %89, i64 1
%91 = load i8, i8* %90
%92 = icmp eq i8 %91, 47
br i1 %92, label %96, label %93
93: ; preds = %88
%94 = call i8* @strchr(i8* %90, i8 signext 42)
%95 = icmp eq i8* %94, null
br i1 %95, label %104, label %88
96: ; preds = %88
%97 = call i32 @fsetpos(i32* %12, i32* %3)
%98 = call i64 @strlen(i8* %4)
%99 = getelementptr inbounds i8, i8* %89, i64 2
%100 = call i64 @strlen(i8* %99)
%101 = sub nsw i64 %98, %100
%102 = load i32, i32* @SEEK_CUR
%103 = call i32 @fseek(i32* %12, i64 %101, i32 %102)
br label %71
104: ; preds = %93, %85
%105 = call i32 @fputc(i32 10, i32* %18)
br label %71
106: ; preds = %27
%107 = call i32 @fclose(i32* %12)
%108 = call i32 @fclose(i32* %18)
br label %109
109: ; preds = %106, %20, %14
ret i32 0
}