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

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
char *escapeChars(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
char *removeExt(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ *stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Missing arguments. Usage: ./[programName] [files]\n");
    fprintf(stderr,
            "Example:\n./printfer 1.csd 2.csd 3.csd\n./printfer *.csd\n\n");
    return 1;
  }
  for (int i = 1; i < argc; ++i) {
    FILE *fp = fopen(argv[i], "r");
    if (fp == NULL) {
      fprintf(stderr, "Error opening %s\n", argv[i]);
      fclose(fp);
      continue;
    }
    fseek(fp, 0L, SEEK_END);
    int size = ftell(fp);
    rewind(fp);
    printf("Processing %s ===> ", argv[i]);
    char *outFileName = malloc(sizeof(argv[i]) + 10);
    sprintf(outFileName, "%s_printfed.c", removeExt(argv[i]));
    FILE *outFile = fopen(outFileName, "w");
    if (outFile == NULL) {
      printf("Error writing to file %s\n", outFileName);
      fclose(outFile);
      continue;
    }
    char *contents = malloc(size * sizeof(char));
    char line[512];
    while (fgets(line, sizeof(line), fp)) {
      if (strcmp(line, "\n") != 0) {
        strtok(line, "\n");
        char *escapedLine = escapeChars(line);
        fprintf(outFile, "printf(\"%s\\n\");\n", escapedLine);
        free(escapedLine);
      } else {
        fprintf(outFile, "printf(\"\\n\");\n\n");
      }
    }
    fclose(fp);
    fclose(outFile);
    free(outFileName);
    free(contents);
    printf("%s\n", outFileName);
  }
  printf("Complete.\n");
  printf("\a");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    124f <main+0x5f>
mov    0x2dbe(%rip),%rax
mov    (%rax),%rdi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%rdi
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1495 <main+0x2a5>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1479 <main+0x289>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdf7(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12bb <main+0xcb>
mov    0x2d48(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
jmp    146b <main+0x27b>
mov    -0x20(%rbp),%rdi
mov    0x2d22(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10d0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x12,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x250(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <removeExt@plt>
mov    -0x250(%rbp),%rdi
mov    %rax,%rdx
lea    0xd59(%rip),%rsi
call   1110 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd57(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    137f <main+0x18f>
mov    -0x30(%rbp),%rsi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
jmp    146b <main+0x27b>
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x40(%rbp)
lea    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x200,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1435 <main+0x245>
lea    -0x240(%rbp),%rdi
lea    0xd1e(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     141e <main+0x22e>
lea    -0x240(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   1100 <strtok@plt>
lea    -0x240(%rbp),%rdi
call   10e0 <escapeChars@plt>
mov    %rax,-0x248(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x248(%rbp),%rdx
lea    0xcb8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x248(%rbp),%rdi
call   1030 <free@plt>
jmp    1430 <main+0x240>
mov    -0x38(%rbp),%rdi
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1392 <main+0x1a2>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rsi
lea    0xc56(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1256 <main+0x66>
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
cmp    $0x2,%edi
jge    1279 <main+0x59>
mov    0x2d9b(%rip),%rbx
mov    (%rbx),%rcx
lea    0xdb9(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
call   1140 <fwrite@plt>
mov    (%rbx),%rcx
lea    0xdd3(%rip),%rdi
mov    $0x38,%esi
mov    $0x1,%edx
call   1140 <fwrite@plt>
mov    $0x1,%eax
jmp    146f <main+0x24f>
mov    %rsi,%r13
mov    %edi,%eax
mov    %rax,0x18(%rsp)
mov    $0x1,%ebp
lea    0x20(%rsp),%r15
lea    0xe49(%rip),%rbx
mov    %rsi,0x8(%rsp)
jmp    12d3 <main+0xb3>
nopl   0x0(%rax,%rax,1)
mov    0x2d31(%rip),%rax
mov    (%rax),%rdi
mov    0x0(%r13,%rbp,8),%rdx
lea    0xdb8(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1060 <fclose@plt>
add    $0x1,%rbp
cmp    0x18(%rsp),%rbp
je     1457 <main+0x237>
mov    0x0(%r13,%rbp,8),%rdi
lea    0xd8d(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     12a0 <main+0x80>
mov    %rax,%r14
mov    0x2cf5(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %r14,%rdi
call   10d0 <ftell@plt>
mov    %eax,(%rsp)
mov    %r14,%rdi
call   1080 <rewind@plt>
mov    0x0(%r13,%rbp,8),%rsi
lea    0xd62(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x12,%edi
call   10e0 <malloc@plt>
mov    %rax,%r12
mov    %rbp,0x10(%rsp)
mov    0x0(%r13,%rbp,8),%rdi
call   1090 <removeExt@plt>
mov    %r12,%rdi
lea    0xd49(%rip),%rsi
mov    %rax,%rdx
call   1130 <sprintf@plt>
mov    %r12,%rdi
lea    0xd45(%rip),%rsi
call   1110 <fopen@plt>
test   %rax,%rax
je     1430 <main+0x210>
mov    %rax,%r13
mov    (%rsp),%edi
call   10e0 <malloc@plt>
mov    %rax,(%rsp)
jmp    13b2 <main+0x192>
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1120 <strtok@plt>
mov    %r15,%rdi
call   1100 <escapeChars@plt>
mov    %rax,%rbp
mov    %r13,%rdi
lea    0xd1e(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1400 <main+0x1e0>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1380 <main+0x160>
mov    $0xf,%esi
mov    $0x1,%edx
lea    0xce7(%rip),%rdi
mov    %r13,%rcx
call   1140 <fwrite@plt>
jmp    13b2 <main+0x192>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
jmp    1448 <main+0x228>
nopl   0x0(%rax,%rax,1)
lea    0xc6d(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   1060 <fclose@plt>
mov    0x8(%rsp),%r13
mov    0x10(%rsp),%rbp
jmp    12c4 <main+0xa4>
lea    0xc81(%rip),%rdi
call   1050 <puts@plt>
mov    $0x7,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32* null
@.str = [51 x i8] c"Missing arguments. Usage: ./[programName] [files]\0A\00"
@.str.1 = [57 x i8] c"Example:\0A./printfer 1.csd 2.csd 3.csd\0A./printfer *.csd\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"Error opening %s\0A\00"
@SEEK_END = global i32 0
@.str.4 = [20 x i8] c"Processing %s ===> \00"
@.str.5 = [14 x i8] c"%s_printfed.c\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [26 x i8] c"Error writing to file %s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"printf(\22%s\\n\22);\0A\00"
@.str.10 = [16 x i8] c"printf(\22\\n\22);\0A\0A\00"
@.str.11 = [4 x i8] c"%s\0A\00"
@.str.12 = [11 x i8] c"Complete.\0A\00"
@.str.13 = [2 x i8] c"\07\00"
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 i8*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca [512 x i8]
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32*, i32** @stderr
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%19 = load i32*, i32** @stderr
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %123
21: ; preds = %2
store i32 1, i32* %6
br label %22
22: ; preds = %117, %21
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %120
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %45
35: ; preds = %26
%36 = load i32*, i32** @stderr
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = load i32*, i32** %7
%44 = call i32 @fclose(i32* %43)
br label %117
45: ; preds = %26
%46 = load i32*, i32** %7
%47 = load i32, i32* @SEEK_END
%48 = call i32 @fseek(i32* %46, i64 0, i32 %47)
%49 = load i32*, i32** %7
%50 = call i32 @ftell(i32* %49)
store i32 %50, i32* %8
%51 = load i32*, i32** %7
%52 = call i32 @rewind(i32* %51)
%53 = load i8**, i8*** %5
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %57)
%59 = call i8* @malloc(i32 18)
store i8* %59, i8** %9
%60 = load i8*, i8** %9
%61 = load i8**, i8*** %5
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = call i8* @removeExt(i8* %65)
%67 = call i32 @sprintf(i8* %60, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %66)
%68 = load i8*, i8** %9
%69 = call i32* @fopen(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %69, i32** %10
%70 = load i32*, i32** %10
%71 = icmp eq i32* %70, null
br i1 %71, label %72, label %77
72: ; preds = %45
%73 = load i8*, i8** %9
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %73)
%75 = load i32*, i32** %10
%76 = call i32 @fclose(i32* %75)
br label %117
77: ; preds = %45
%78 = load i32, i32* %8
%79 = sext i32 %78 to i64
%80 = mul i64 %79, 1
%81 = trunc i64 %80 to i32
%82 = call i8* @malloc(i32 %81)
store i8* %82, i8** %11
br label %83
83: ; preds = %105, %77
%84 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%85 = load i32*, i32** %7
%86 = call i64 @fgets(i8* %84, i32 512, i32* %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %106
88: ; preds = %83
%89 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %102
92: ; preds = %88
%93 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%94 = call i32 @strtok(i8* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%96 = call i8* @escapeChars(i8* %95)
store i8* %96, i8** %13
%97 = load i32*, i32** %10
%98 = load i8*, i8** %13
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %97, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %98)
%100 = load i8*, i8** %13
%101 = call i32 @free(i8* %100)
br label %105
102: ; preds = %88
%103 = load i32*, i32** %10
%104 = call i32 (i32*, i8*, ...) @fprintf(i32* %103, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %105
105: ; preds = %102, %92
br label %83
106: ; preds = %83
%107 = load i32*, i32** %7
%108 = call i32 @fclose(i32* %107)
%109 = load i32*, i32** %10
%110 = call i32 @fclose(i32* %109)
%111 = load i8*, i8** %9
%112 = call i32 @free(i8* %111)
%113 = load i8*, i8** %11
%114 = call i32 @free(i8* %113)
%115 = load i8*, i8** %9
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %115)
br label %117
117: ; preds = %106, %72, %35
%118 = load i32, i32* %6
%119 = add nsw i32 %118, 1
store i32 %119, i32* %6
br label %22
120: ; preds = %22
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %123
123: ; preds = %120, %16
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [51 x i8] c"Missing arguments. Usage: ./[programName] [files]\0A\00"
@.str.1 = [57 x i8] c"Example:\0A./printfer 1.csd 2.csd 3.csd\0A./printfer *.csd\0A\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"Error opening %s\0A\00"
@SEEK_END = global i32 0
@.str.4 = [20 x i8] c"Processing %s ===> \00"
@.str.5 = [14 x i8] c"%s_printfed.c\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [26 x i8] c"Error writing to file %s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"printf(\22%s\\n\22);\0A\00"
@.str.10 = [16 x i8] c"printf(\22\\n\22);\0A\0A\00"
@str = [10 x i8] c"Complete.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = zext i32 %0 to i64
br label %16
8: ; preds = %2
%9 = load i32*, i32** @stderr
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 50, i64 1, i32* %9)
%11 = load i32*, i32** @stderr
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i64 56, i64 1, i32* %11)
br label %69
13: ; preds = %66
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%15 = call i32 @putchar(i32 7)
br label %69
16: ; preds = %5, %66
%17 = phi i64 [ 1, %5 ], [ %67, %66 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32*, i32** @stderr
%24 = load i8*, i8** %18
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = call i32 @fclose(i32* null)
br label %66
27: ; preds = %16
%28 = load i32, i32* @SEEK_END
%29 = call i32 @fseek(i32* %20, i64 0, i32 %28)
%30 = call i32 @ftell(i32* %20)
%31 = call i32 @rewind(i32* %20)
%32 = load i8*, i8** %18
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = call dereferenceable_or_null(18) i8* @malloc(i32 18)
%35 = load i8*, i8** %18
%36 = call i8* @removeExt(i8* %35)
%37 = call i32 @sprintf(i8* dereferenceable(1) %34, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %36)
%38 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %43
40: ; preds = %27
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* %34)
%42 = call i32 @fclose(i32* null)
br label %66
43: ; preds = %27
%44 = call i8* @malloc(i32 %30)
%45 = call i64 @fgets(i8* %6, i32 512, i32* %20)
%46 = icmp eq i64 %45, 0
br i1 %46, label %60, label %47
47: ; preds = %43, %57
%48 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %55, label %50
50: ; preds = %47
%51 = call i32 @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%52 = call i8* @escapeChars(i8* %6)
%53 = call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i8* %52)
%54 = call i32 @free(i8* %52)
br label %57
55: ; preds = %47
%56 = call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i64 15, i64 1, i32* %38)
br label %57
57: ; preds = %55, %50
%58 = call i64 @fgets(i8* %6, i32 512, i32* %20)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %47
60: ; preds = %57, %43
%61 = call i32 @fclose(i32* %20)
%62 = call i32 @fclose(i32* %38)
%63 = call i32 @free(i8* %34)
%64 = call i32 @free(i8* %44)
%65 = call i32 @puts(i8* dereferenceable(1) %34)
br label %66
66: ; preds = %40, %60, %22
%67 = add nuw nsw i64 %17, 1
%68 = icmp eq i64 %67, %7
br i1 %68, label %13, label %16
69: ; preds = %13, %8
%70 = phi i32 [ 1, %8 ], [ 0, %13 ]
ret i32 %70
}