#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*/ GetFileSinExtension(char *, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *, ...);
char *puesEso(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
main(int argc, char **argv) {
  FILE *in;
  FILE *ou;
  char fileSin[100];
  char extension[100];
  char buf[1000 + 1];
  char buf2[1000 + 1];
  char fileou[100];
  if (argc <= 1) {
    printf("%s fileIn \n", argv[0]);
    exit(-1);
  }
  GetFileSinExtension(argv[1], fileSin, extension);
  if (strcmp(extension, "template") != 0) {
    printf("%s el fichero ha de tener extension .template\n", argv[1]);
    exit(-1);
  }
  in = fopen(argv[1], "r");
  if (!in) {
    printf("fichero [%s] no se pudo abrir para lectura\n", argv[1]);
    exit(-1);
  }
  sprintf(fileou, "%s.h", fileSin);
  ou = fopen(fileou, "w");
  if (!ou) {
    printf("fichero [%s] no se pudo abrir para excritura\n", fileou);
    exit(-1);
  }
  fprintf(ou, "char *%s =", fileSin);
  while (fgets(buf, 1000, in)) {
    if (strlen(buf) > 0)
      buf[strlen(buf) - 1] = 0;
    fprintf(ou, "\n\"%s\\n\"", puesEso(buf, buf2));
  }
  fprintf(ou, ";\n");
  printf("Generado [%s] a partir de [%s] \n", fileou, argv[1]);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x960,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11e2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x90(%rbp),%rsi
lea    -0x100(%rbp),%rdx
call   1030 <GetFileSinExtension@plt>
lea    -0x100(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     123a <main+0x9a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdfb(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    127d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
lea    -0x950(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xde0(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x950(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12d8 <main+0x138>
lea    -0x950(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    -0x90(%rbp),%rdx
lea    0xdbd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x4f0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1379 <main+0x1d9>
lea    -0x4f0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jle    133e <main+0x19e>
lea    -0x4f0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x4f0(%rbp,%rax,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x958(%rbp)
lea    -0x4f0(%rbp),%rdi
lea    -0x8e0(%rbp),%rsi
call   10a0 <puesEso@plt>
mov    -0x958(%rbp),%rdi
mov    %rax,%rdx
lea    0xd45(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12f1 <main+0x151>
mov    -0x20(%rbp),%rdi
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x950(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x960,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x938,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jle    132f <main+0x17f>
mov    0x8(%r14),%rdi
lea    0x70(%rsp),%rsi
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <GetFileSinExtension@plt>
lea    0xe1f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
mov    0x8(%r14),%rcx
test   %rax,%rax
jne    133b <main+0x18b>
lea    0xe3b(%rip),%rsi
mov    %rcx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1347 <main+0x197>
mov    %rax,%r15
lea    0xe4e(%rip),%rsi
mov    %rsp,%rbx
lea    0x70(%rsp),%rdx
mov    %rbx,%rdi
call   10b0 <sprintf@plt>
lea    0xe3c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1354 <main+0x1a4>
mov    %rax,%r12
lea    0xe51(%rip),%rsi
lea    0x70(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0x540(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ed <main+0x13d>
lea    0x150(%rsp),%r13
lea    0xe21(%rip),%rbp
jmp    12d0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <puesEso@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12ed <main+0x13d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    12a0 <main+0xf0>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    12a0 <main+0xf0>
lea    0xdc6(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10d0 <fwrite@plt>
mov    0x8(%r14),%rdx
lea    0xdac(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x938,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%rsi
lea    0xcc7(%rip),%rdi
jmp    135e <main+0x1ae>
lea    0xcd3(%rip),%rdi
mov    %rcx,%rsi
jmp    135e <main+0x1ae>
mov    0x8(%r14),%rsi
lea    0xcf4(%rip),%rdi
jmp    135e <main+0x1ae>
lea    0xd1e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%s fileIn \0A\00"
@.str.1 = [9 x i8] c"template\00"
@.str.2 = [47 x i8] c"%s el fichero ha de tener extension .template\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [44 x i8] c"fichero [%s] no se pudo abrir para lectura\0A\00"
@.str.5 = [5 x i8] c"%s.h\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [46 x i8] c"fichero [%s] no se pudo abrir para excritura\0A\00"
@.str.8 = [11 x i8] c"char *%s =\00"
@.str.9 = [8 x i8] c"\0A\22%s\\n\22\00"
@.str.10 = [3 x i8] c";\0A\00"
@.str.11 = [33 x i8] c"Generado [%s] a partir de [%s] \0A\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 [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca [1001 x i8]
%11 = alloca [1001 x i8]
%12 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp sle i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%27 = call i32 @GetFileSinExtension(i8* %24, i8* %25, i8* %26)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %21
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %21
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %6
%42 = load i32*, i32** %6
%43 = icmp ne i32* %42, null
br i1 %43, label %50, label %44
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = call i32 @exit(i32 -1)
unreachable
50: ; preds = %37
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%53 = call i32 @sprintf(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %55, i32** %7
%56 = load i32*, i32** %7
%57 = icmp ne i32* %56, null
br i1 %57, label %62, label %58
58: ; preds = %50
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%60 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 -1)
unreachable
62: ; preds = %50
%63 = load i32*, i32** %7
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %64)
br label %66
66: ; preds = %81, %62
%67 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 0
%68 = load i32*, i32** %6
%69 = call i64 @fgets(i8* %67, i32 1000, i32* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %87
71: ; preds = %66
%72 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 0
%73 = call i32 @strlen(i8* %72)
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %71
%76 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 0
%77 = call i32 @strlen(i8* %76)
%78 = sub nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 %79
store i8 0, i8* %80
br label %81
81: ; preds = %75, %71
%82 = load i32*, i32** %7
%83 = getelementptr inbounds [1001 x i8], [1001 x i8]* %10, i64 0, i64 0
%84 = getelementptr inbounds [1001 x i8], [1001 x i8]* %11, i64 0, i64 0
%85 = call i8* @puesEso(i8* %83, i8* %84)
%86 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %85)
br label %66
87: ; preds = %66
%88 = load i32*, i32** %7
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%90 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 1
%93 = load i8*, i8** %92
%94 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %90, i8* %93)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s fileIn \0A\00"
@.str.1 = [9 x i8] c"template\00"
@.str.2 = [47 x i8] c"%s el fichero ha de tener extension .template\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [44 x i8] c"fichero [%s] no se pudo abrir para lectura\0A\00"
@.str.5 = [5 x i8] c"%s.h\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [46 x i8] c"fichero [%s] no se pudo abrir para excritura\0A\00"
@.str.8 = [11 x i8] c"char *%s =\00"
@.str.9 = [8 x i8] c"\0A\22%s\\n\22\00"
@.str.10 = [3 x i8] c";\0A\00"
@.str.11 = [33 x i8] c"Generado [%s] a partir de [%s] \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [1001 x i8]
%6 = alloca [1001 x i8]
%7 = alloca [100 x i8]
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [1001 x i8], [1001 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [1001 x i8], [1001 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%13 = icmp slt i32 %0, 2
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @GetFileSinExtension(i8* %20, i8* %8, i8* %9)
%22 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = load i8*, i8** %19
br i1 %23, label %28, label %25
25: ; preds = %18
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%27 = call i32 @exit(i32 -1)
unreachable
28: ; preds = %18
%29 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i8*, i8** %19
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %32)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %28
%36 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%37 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %12)
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %35
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8* %8)
%44 = call i64 @fgets(i8* %10, i32 1000, i32* %29)
%45 = icmp eq i64 %44, 0
br i1 %45, label %59, label %46
46: ; preds = %42, %54
%47 = call i32 @strlen(i8* %10)
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = call i32 @strlen(i8* %10)
%51 = add nsw i32 %50, -1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1001 x i8], [1001 x i8]* %5, i64 0, i64 %52
store i8 0, i8* %53
br label %54
54: ; preds = %49, %46
%55 = call i8* @puesEso(i8* %10, i8* %11)
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8* %55)
%57 = call i64 @fgets(i8* %10, i32 1000, i32* %29)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %46
59: ; preds = %54, %42
%60 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i64 2, i64 1, i32* %37)
%61 = load i8*, i8** %19
%62 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i8* %12, i8* %61)
ret i32 0
}