#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() {
  int fBlock = 0, fQuotation = 0;
  char buf[1024], tmp[1024], *pch, *pchtmp;
  FILE *pfi, *pfo;
  fpos_t pos;
  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) {
    fgetpos(pfi, &pos);
    if (!fgets(buf, 1024, pfi))
      break;
    if (!fBlock) {
      if (!fQuotation) {
        pch = strchr(buf, '\"');
        if (pch != NULL) {
          (*pch) = 0;
          if (pchtmp = strchr(buf, '/'))
            if (*(pchtmp + 1) == '*' || *(pchtmp + 1) == '/') {
              (*pch) = '\"';
              goto tag;
            }
          fputs(buf, pfo);
          fputs("\"", pfo);
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) + 1, SEEK_CUR);
          fQuotation = 1;
          continue;
        }
      } else {
        pch = strchr(buf, '\"');
        if (pch != NULL) {
          (*pch) = 0;
          fputs(buf, pfo);
          fputs("\"", pfo);
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) + 1, SEEK_CUR);
          fQuotation = 0;
          continue;
        }
      }
    tag:
      pch = strchr(buf, '/');
      while (pch) {
        if (*(pch + 1) == '/') {
          (*pch) = 0;
          fputs(buf, pfo);
          fputs("\n", pfo);
          break;
        } else if (*(pch + 1) == '*') {
          (*pch) = 0;
          fputs(buf, pfo);
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) + 2, SEEK_CUR);
          fBlock = 1;
          break;
        } else
          pch = strchr(pch + 1, '/');
      }
      if (pch == NULL)
        fputs(buf, pfo);
    } else {
      pch = strchr(buf, '*');
      while (pch) {
        if (*(pch + 1) == '/') {
          fsetpos(pfi, &pos);
          fseek(pfi, strlen(buf) - strlen(pch + 2), SEEK_CUR);
          fBlock = 0;
          break;
        } else
          pch = strchr(pch + 1, '*');
      }
      if (pch == NULL)
        fputs("\n", pfo);
    }
  }
  fclose(pfi);
  fclose(pfo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xdf9(%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    0xdf2(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xdcf(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x828(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1298 <main+0xb8>
lea    0xdb0(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <getchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    1755 <main+0x575>
lea    -0x810(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x830(%rbp)
jne    12eb <main+0x10b>
lea    0xd8e(%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    1755 <main+0x575>
jmp    12f0 <main+0x110>
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    1329 <main+0x149>
jmp    1736 <main+0x556>
cmpl   $0x0,-0x8(%rbp)
jne    1641 <main+0x461>
cmpl   $0x0,-0xc(%rbp)
jne    144b <main+0x26b>
lea    -0x410(%rbp),%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     1446 <main+0x266>
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     13cb <main+0x1eb>
mov    -0x820(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2a,%eax
je     13b7 <main+0x1d7>
mov    -0x820(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    13c6 <main+0x1e6>
mov    -0x818(%rbp),%rax
movb   $0x22,(%rax)
jmp    1500 <main+0x320>
jmp    13cb <main+0x1eb>
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xc89(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x828(%rbp),%rdi
lea    -0x834(%rbp),%rsi
call   10f0 <fsetpos@plt>
mov    -0x828(%rbp),%rax
mov    %rax,-0x840(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x840(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    0x2bb5(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x1,-0xc(%rbp)
jmp    12f0 <main+0x110>
jmp    14fb <main+0x31b>
lea    -0x410(%rbp),%rdi
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     14f6 <main+0x316>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xbd9(%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    0x2b05(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x0,-0xc(%rbp)
jmp    12f0 <main+0x110>
jmp    14fb <main+0x31b>
jmp    1500 <main+0x320>
lea    -0x410(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     161b <main+0x43b>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    156f <main+0x38f>
mov    -0x818(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x830(%rbp),%rsi
lea    0xb12(%rip),%rdi
call   1090 <fputs@plt>
jmp    161b <main+0x43b>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2a,%eax
jne    15f5 <main+0x415>
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,-0x850(%rbp)
lea    -0x410(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x850(%rbp),%rdi
mov    %rax,%rsi
add    $0x2,%rsi
mov    0x2a06(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x1,-0x8(%rbp)
jmp    161b <main+0x43b>
mov    -0x818(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
jmp    1616 <main+0x436>
jmp    1518 <main+0x338>
cmpq   $0x0,-0x818(%rbp)
jne    163c <main+0x45c>
lea    -0x410(%rbp),%rdi
mov    -0x830(%rbp),%rsi
call   1090 <fputs@plt>
jmp    1731 <main+0x551>
lea    -0x410(%rbp),%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     170b <main+0x52b>
mov    -0x818(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    16ea <main+0x50a>
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    %rax,-0x860(%rbp)
mov    -0x818(%rbp),%rdi
add    $0x2,%rdi
call   1050 <strlen@plt>
mov    -0x860(%rbp),%rsi
mov    -0x858(%rbp),%rdi
sub    %rax,%rsi
mov    0x2911(%rip),%rax
mov    (%rax),%edx
call   10d0 <fseek@plt>
movl   $0x0,-0x8(%rbp)
jmp    170b <main+0x52b>
mov    -0x818(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x818(%rbp)
jmp    1659 <main+0x479>
cmpq   $0x0,-0x818(%rbp)
jne    172c <main+0x54c>
mov    -0x830(%rbp),%rsi
lea    0x950(%rip),%rdi
call   1090 <fputs@plt>
jmp    1731 <main+0x551>
jmp    12f0 <main+0x110>
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    $0x860,%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    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <gets@plt>
lea    0x410(%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     1501 <main+0x311>
mov    %rax,%r13
lea    0xde6(%rip),%rsi
lea    0x410(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     150f <main+0x31f>
mov    %rax,%r14
lea    0xc(%rsp),%rsi
mov    %r13,%rdi
call   1080 <fgetpos@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
test   %eax,%eax
je     14ef <main+0x2ff>
movl   $0x0,0x8(%rsp)
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
xor    %ebx,%ebx
jmp    1300 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
xor    %ebx,%ebx
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     14ef <main+0x2ff>
mov    %r15,%rdi
test   %ebx,%ebx
je     1360 <main+0x170>
mov    $0x2a,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     133f <main+0x14f>
mov    %rax,%rbx
nopl   0x0(%rax)
cmpb   $0x2f,0x1(%rbx)
je     1383 <main+0x193>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2a,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1320 <main+0x130>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
mov    $0x1,%ebx
jmp    12dd <main+0xed>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x22,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
cmpl   $0x0,0x8(%rsp)
je     13c1 <main+0x1d1>
test   %rbx,%rbx
je     13f6 <main+0x206>
movb   $0x0,(%rbx)
xor    %ebp,%ebp
jmp    1485 <main+0x295>
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    0x2c39(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %rbp,%rsi
call   10e0 <fseek@plt>
jmp    12db <main+0xeb>
test   %rbx,%rbx
je     13f6 <main+0x206>
movb   $0x0,(%rbx)
mov    %r15,%rdi
mov    $0x2f,%esi
call   1060 <strchr@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1485 <main+0x295>
mov    0x1(%rax),%al
cmp    $0x2f,%al
je     13f3 <main+0x203>
cmp    $0x2a,%al
jne    1485 <main+0x295>
movb   $0x22,(%rbx)
mov    %r15,%rdi
nopl   0x0(%rax)
mov    $0x2f,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     12d0 <main+0xe0>
movzbl 0x1(%rax),%ecx
cmp    $0x2a,%cl
je     142a <main+0x23a>
cmp    $0x2f,%cl
je     1465 <main+0x275>
add    $0x1,%rax
mov    %rax,%rdi
jmp    1400 <main+0x210>
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>
jmp    134c <main+0x15c>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <fputs@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
jmp    12db <main+0xeb>
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    0x2b2d(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   10e0 <fseek@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <fgetpos@plt>
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
mov    %ebp,0x8(%rsp)
test   %eax,%eax
je     14ef <main+0x2ff>
xor    %ebx,%ebx
jmp    1300 <main+0x110>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    152a <main+0x33a>
lea    0xb28(%rip),%rdi
call   1070 <printf@plt>
jmp    1523 <main+0x333>
lea    0xb3f(%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 i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%11 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%13 = call i32 @gets(i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%20 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %22, i32** %8
%23 = load i32*, i32** %8
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %0
%26 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %209
28: ; preds = %0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %30, i32** %9
%31 = load i32*, i32** %9
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%35 = load i32*, i32** %8
%36 = call i32 @fclose(i32* %35)
%37 = call i32 (...) @getchar()
store i32 0, i32* %1
br label %209
38: ; preds = %28
br label %39
39: ; preds = %38, %78, %98, %203
%40 = load i32*, i32** %8
%41 = call i32 @fgetpos(i32* %40, i32* %10)
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%43 = load i32*, i32** %8
%44 = call i32 @fgets(i8* %42, i32 1024, i32* %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %47, label %46
46: ; preds = %39
br label %204
47: ; preds = %39
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 0
br i1 %49, label %167, label %50
50: ; preds = %47
%51 = load i32, i32* %3
%52 = icmp ne i32 %51, 0
br i1 %52, label %93, label %53
53: ; preds = %50
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%55 = call i8* @strchr(i8* %54, i8 signext 34)
store i8* %55, i8** %6
%56 = load i8*, i8** %6
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %92
58: ; preds = %53
%59 = load i8*, i8** %6
store i8 0, i8* %59
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%61 = call i8* @strchr(i8* %60, i8 signext 47)
store i8* %61, i8** %7
%62 = icmp ne i8* %61, null
br i1 %62, label %63, label %78
63: ; preds = %58
%64 = load i8*, i8** %7
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 42
br i1 %68, label %75, label %69
69: ; preds = %63
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i64 1
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 47
br i1 %74, label %75, label %77
75: ; preds = %69, %63
%76 = load i8*, i8** %6
store i8 34, i8* %76
br label %115
77: ; preds = %69
br label %78
78: ; preds = %77, %58
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%80 = load i32*, i32** %9
%81 = call i32 @fputs(i8* %79, i32* %80)
%82 = load i32*, i32** %9
%83 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32* %82)
%84 = load i32*, i32** %8
%85 = call i32 @fsetpos(i32* %84, i32* %10)
%86 = load i32*, i32** %8
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%88 = call i64 @strlen(i8* %87)
%89 = add nsw i64 %88, 1
%90 = load i32, i32* @SEEK_CUR
%91 = call i32 @fseek(i32* %86, i64 %89, i32 %90)
store i32 1, i32* %3
br label %39
92: ; preds = %53
br label %114
93: ; preds = %50
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%95 = call i8* @strchr(i8* %94, i8 signext 34)
store i8* %95, i8** %6
%96 = load i8*, i8** %6
%97 = icmp ne i8* %96, null
br i1 %97, label %98, label %113
98: ; preds = %93
%99 = load i8*, i8** %6
store i8 0, i8* %99
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%101 = load i32*, i32** %9
%102 = call i32 @fputs(i8* %100, i32* %101)
%103 = load i32*, i32** %9
%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** %8
%106 = call i32 @fsetpos(i32* %105, i32* %10)
%107 = load i32*, i32** %8
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, 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* %3
br label %39
113: ; preds = %93
br label %114
114: ; preds = %113, %92
br label %115
115: ; preds = %114, %75
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%117 = call i8* @strchr(i8* %116, i8 signext 47)
store i8* %117, i8** %6
br label %118
118: ; preds = %158, %115
%119 = load i8*, i8** %6
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %159
121: ; preds = %118
%122 = load i8*, i8** %6
%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** %6
store i8 0, i8* %128
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%130 = load i32*, i32** %9
%131 = call i32 @fputs(i8* %129, i32* %130)
%132 = load i32*, i32** %9
%133 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %132)
br label %159
134: ; preds = %121
%135 = load i8*, i8** %6
%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** %6
store i8 0, i8* %141
%142 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%143 = load i32*, i32** %9
%144 = call i32 @fputs(i8* %142, i32* %143)
%145 = load i32*, i32** %8
%146 = call i32 @fsetpos(i32* %145, i32* %10)
%147 = load i32*, i32** %8
%148 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, 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* %2
br label %159
153: ; preds = %134
%154 = load i8*, i8** %6
%155 = getelementptr inbounds i8, i8* %154, i64 1
%156 = call i8* @strchr(i8* %155, i8 signext 47)
store i8* %156, i8** %6
br label %157
157: ; preds = %153
br label %158
158: ; preds = %157
br label %118
159: ; preds = %140, %127, %118
%160 = load i8*, i8** %6
%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]* %4, i64 0, i64 0
%164 = load i32*, i32** %9
%165 = call i32 @fputs(i8* %163, i32* %164)
br label %166
166: ; preds = %162, %159
br label %203
167: ; preds = %47
%168 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%169 = call i8* @strchr(i8* %168, i8 signext 42)
store i8* %169, i8** %6
br label %170
170: ; preds = %195, %167
%171 = load i8*, i8** %6
%172 = icmp ne i8* %171, null
br i1 %172, label %173, label %196
173: ; preds = %170
%174 = load i8*, i8** %6
%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** %8
%181 = call i32 @fsetpos(i32* %180, i32* %10)
%182 = load i32*, i32** %8
%183 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%184 = call i64 @strlen(i8* %183)
%185 = load i8*, i8** %6
%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* %2
br label %196
191: ; preds = %173
%192 = load i8*, i8** %6
%193 = getelementptr inbounds i8, i8* %192, i64 1
%194 = call i8* @strchr(i8* %193, i8 signext 42)
store i8* %194, i8** %6
br label %195
195: ; preds = %191
br label %170
196: ; preds = %179, %170
%197 = load i8*, i8** %6
%198 = icmp eq i8* %197, null
br i1 %198, label %199, label %202
199: ; preds = %196
%200 = load i32*, i32** %9
%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 = %202, %166
br label %39
204: ; preds = %46
%205 = load i32*, i32** %8
%206 = call i32 @fclose(i32* %205)
%207 = load i32*, i32** %9
%208 = call i32 @fclose(i32* %207)
store i32 0, i32* %1
br label %209
209: ; preds = %204, %33, %25
%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 %110
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 %24, label %20
20: ; preds = %17
%21 = call i32 @fgetpos(i32* %12, i32* %3)
%22 = call i32 @fgets(i8* %4, i32 1024, i32* %12)
%23 = icmp eq i32 %22, 0
br i1 %23, label %107, label %56
24: ; preds = %17
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @fclose(i32* %12)
%27 = call i32 (...) @getchar()
br label %110
28: ; preds = %56, %102
%29 = phi i32 [ 0, %56 ], [ %103, %102 ]
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %81
31: ; preds = %28
%32 = call i8* @strchr(i8* %4, i8 signext 34)
%33 = icmp eq i8* %32, null
br i1 %58, label %34, label %42
34: ; preds = %31
br i1 %33, label %59, label %35
35: ; preds = %34
store i8 0, i8* %32
%36 = call i8* @strchr(i8* %4, i8 signext 47)
%37 = icmp eq i8* %36, null
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = getelementptr inbounds i8, i8* %36, i64 1
%40 = load i8, i8* %39
switch i8 %40, label %44 [
i8 42, label %41
i8 47, label %41
]
41: ; preds = %38, %38
store i8 34, i8* %32
br label %59
42: ; preds = %31
br i1 %33, label %59, label %43
43: ; preds = %42
store i8 0, i8* %32
br label %44
44: ; preds = %35, %38, %43
%45 = phi i32 [ 0, %43 ], [ 1, %38 ], [ 1, %35 ]
%46 = call i32 @fputs(i8* %4, i32* %18)
%47 = call i32 @fputc(i32 34, i32* %18)
%48 = call i32 @fsetpos(i32* %12, i32* %3)
%49 = call i64 @strlen(i8* %4)
%50 = add nsw i64 %49, 1
%51 = load i32, i32* @SEEK_CUR
%52 = call i32 @fseek(i32* %12, i64 %50, i32 %51)
%53 = call i32 @fgetpos(i32* %12, i32* %3)
%54 = call i32 @fgets(i8* %4, i32 1024, i32* %12)
%55 = icmp eq i32 %54, 0
br i1 %55, label %107, label %56
56: ; preds = %20, %44
%57 = phi i32 [ %45, %44 ], [ 0, %20 ]
%58 = icmp eq i32 %57, 0
br label %28
59: ; preds = %34, %42, %41
%60 = call i8* @strchr(i8* %4, i8 signext 47)
%61 = icmp eq i8* %60, null
br i1 %61, label %79, label %62
62: ; preds = %59, %76
%63 = phi i8* [ %77, %76 ], [ %60, %59 ]
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
switch i8 %65, label %76 [
i8 47, label %66
i8 42, label %69
]
66: ; preds = %62
store i8 0, i8* %63
%67 = call i32 @fputs(i8* %4, i32* %18)
%68 = call i32 @fputc(i32 10, i32* %18)
br label %102
69: ; preds = %62
store i8 0, i8* %63
%70 = call i32 @fputs(i8* %4, i32* %18)
%71 = call i32 @fsetpos(i32* %12, i32* %3)
%72 = call i64 @strlen(i8* %4)
%73 = add nsw i64 %72, 2
%74 = load i32, i32* @SEEK_CUR
%75 = call i32 @fseek(i32* %12, i64 %73, i32 %74)
br label %102
76: ; preds = %62
%77 = call i8* @strchr(i8* %64, i8 signext 47)
%78 = icmp eq i8* %77, null
br i1 %78, label %79, label %62
79: ; preds = %76, %59
%80 = call i32 @fputs(i8* %4, i32* %18)
br label %102
81: ; preds = %28
%82 = call i8* @strchr(i8* %4, i8 signext 42)
%83 = icmp eq i8* %82, null
br i1 %83, label %100, label %84
84: ; preds = %81, %89
%85 = phi i8* [ %90, %89 ], [ %82, %81 ]
%86 = getelementptr inbounds i8, i8* %85, i64 1
%87 = load i8, i8* %86
%88 = icmp eq i8 %87, 47
br i1 %88, label %92, label %89
89: ; preds = %84
%90 = call i8* @strchr(i8* %86, i8 signext 42)
%91 = icmp eq i8* %90, null
br i1 %91, label %100, label %84
92: ; preds = %84
%93 = call i32 @fsetpos(i32* %12, i32* %3)
%94 = call i64 @strlen(i8* %4)
%95 = getelementptr inbounds i8, i8* %85, i64 2
%96 = call i64 @strlen(i8* %95)
%97 = sub nsw i64 %94, %96
%98 = load i32, i32* @SEEK_CUR
%99 = call i32 @fseek(i32* %12, i64 %97, i32 %98)
br label %102
100: ; preds = %89, %81
%101 = call i32 @fputc(i32 10, i32* %18)
br label %102
102: ; preds = %66, %69, %92, %100, %79
%103 = phi i32 [ 1, %100 ], [ 0, %92 ], [ 0, %79 ], [ 1, %69 ], [ 0, %66 ]
%104 = call i32 @fgetpos(i32* %12, i32* %3)
%105 = call i32 @fgets(i8* %4, i32 1024, i32* %12)
%106 = icmp eq i32 %105, 0
br i1 %106, label %107, label %28
107: ; preds = %44, %102, %20
%108 = call i32 @fclose(i32* %12)
%109 = call i32 @fclose(i32* %18)
br label %110
110: ; preds = %107, %24, %14
ret i32 0
}