#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 */
char *escape(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  char *func_name = argv[1];
  FILE *in = fopen(argv[2], "r");
  char *line = NULL;
  size_t len = 0;
  printf("void %s(FILE *out)\n", func_name);
  printf("{\n");
  printf("  fputs(\n");
  while (getline(&line, &len, in) != -1) {
    if (strncmp(line, "//", 2) == 0)
      continue;
    char *l = escape(line);
    printf("    \"%s\\n\"\n", l);
    free(l);
  }
  free(line);
  fclose(in);
  printf("    , out);\n");
  printf("}\n");
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1253 <main+0xe3>
mov    -0x28(%rbp),%rdi
lea    0xe16(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1226 <main+0xb6>
jmp    11e8 <main+0x78>
mov    -0x28(%rbp),%rdi
call   1090 <escape@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    11e8 <main+0x78>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
lea    0xe63(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe44(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe56(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4c(%rip),%rdi
call   1050 <puts@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     126e <main+0xee>
lea    0xe18(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe0a(%rip),%r13
jmp    1233 <main+0xb3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     126e <main+0xee>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1220 <main+0xa0>
mov    0x8(%rsp),%rdi
call   10a0 <escape@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
jmp    1220 <main+0xa0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xda9(%rip),%rdi
call   1050 <puts@plt>
lea    0xda9(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"void %s(FILE *out)\0A\00"
@.str.2 = [3 x i8] c"{\0A\00"
@.str.3 = [10 x i8] c" fputs(\0A\00"
@.str.4 = [3 x i8] c"//\00"
@.str.5 = [12 x i8] c" \22%s\\n\22\0A\00"
@.str.6 = [13 x i8] c" , out);\0A\00"
@.str.7 = [3 x i8] c"}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %7
store i8* null, i8** %8
store i64 0, i64* %9
%18 = load i8*, i8** %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %31, %30, %2
%23 = load i32*, i32** %7
%24 = call i32 @getline(i8** %8, i64* %9, i32* %23)
%25 = icmp ne i32 %24, -1
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = call i64 @strncmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26
br label %22
31: ; preds = %26
%32 = load i8*, i8** %8
%33 = call i8* @escape(i8* %32)
store i8* %33, i8** %10
%34 = load i8*, i8** %10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %10
%37 = call i32 @free(i8* %36)
br label %22
38: ; preds = %22
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
%41 = load i32*, i32** %7
%42 = call i32 @fclose(i32* %41)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [20 x i8] c"void %s(FILE *out)\0A\00"
@.str.4 = [3 x i8] c"//\00"
@.str.5 = [12 x i8] c" \22%s\\n\22\0A\00"
@str = [2 x i8] c"{\00"
@str.8 = [9 x i8] c" fputs(\00"
@str.9 = [12 x i8] c" , out);\00"
@str.10 = [2 x i8] c"}\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%11 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.8, i64 0, i64 0))
%15 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%16 = icmp eq i32 %15, -1
br i1 %16, label %29, label %17
17: ; preds = %2, %26
%18 = load i8*, i8** %3
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 2)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = load i8*, i8** %3
%23 = call i8* @escape(i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8* %23)
%25 = call i32 @free(i8* %23)
br label %26
26: ; preds = %21, %17
%27 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %17
29: ; preds = %26, %2
%30 = load i8*, i8** %3
%31 = call i32 @free(i8* %30)
%32 = call i32 @fclose(i32* %9)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.9, i64 0, i64 0))
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
ret i32 0
}