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

/* Variables and functions */
char *basename(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ replace_dots(char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    printf("not enough arguments\n");
    return 1;
  }
  FILE *fp_h = fopen(argv[1], "w");
  if (!fp_h) {
    printf("can't open %s\n", argv[1]);
    return 2;
  }
  FILE *fp_c = fopen(argv[2], "w");
  if (!fp_c) {
    fclose(fp_h);
    printf("can't open %s\n", argv[2]);
    return 2;
  }
  fprintf(fp_h, "// generated file, all changes will be lost\n"
                "#ifndef FPP_GENERATED_TXT_RESOURCES_H\n"
                "#define FPP_GENERATED_TXT_RESOURCES_H\n"
                "\n"
                "\n");
  for (int k = 3; k < argc; k++) {
    char *fname = strdup(argv[k]);
    char *bname = basename(fname);
    replace_dots(bname);
    fprintf(fp_h, "extern const char *resource_text_%s;\n", bname);
    free(fname);
  }
  fprintf(fp_h, "\n\n#endif\n");
  fclose(fp_h);
  fprintf(fp_c,
          "// generated file, all changes will be lost\n"
          "#include \"%s\"\n"
          "\n",
          argv[1]);
  for (int k = 3; k < argc; k++) {
    unsigned char buf[4096];
    char *fname = strdup(argv[k]);
    char *bname = basename(fname);
    replace_dots(bname);
    fprintf(fp_c, "const char *resource_text_%s = \"", bname);
    size_t fsize = 0;
    FILE *tmp = fopen(argv[k], "rb");
    if (!tmp) {
      printf("can't open %s\n", argv[k]);
      free(fname);
      goto err_1;
    }
    while (!feof(tmp)) {
      size_t read_bytes = fread(buf, 1, sizeof(buf), tmp);
      for (size_t j = 0; j < read_bytes; j++)
        fprintf(fp_c, "\\x%02x", buf[j]);
      fsize += read_bytes;
    }
    fclose(tmp);
    fprintf(fp_c, "\";\n");
    free(fname);
  }
  fclose(fp_c);
  return 0;
err_1:
  fclose(fp_c);
  return 3;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11dd <main+0x3d>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1500 <main+0x360>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1222 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1500 <main+0x360>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde5(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1270 <main+0xd0>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1500 <main+0x360>
mov    -0x18(%rbp),%rdi
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ed <main+0x14d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <strdup@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <basename@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   10b0 <replace_dots@plt>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1289 <main+0xe9>
mov    -0x18(%rbp),%rdi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14db <main+0x33b>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10c0 <strdup@plt>
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rdi
call   1080 <basename@plt>
mov    %rax,-0x1050(%rbp)
mov    -0x1050(%rbp),%rdi
call   10b0 <replace_dots@plt>
mov    -0x20(%rbp),%rdi
mov    -0x1050(%rbp),%rdx
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movq   $0x0,-0x1058(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd8c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x1060(%rbp)
cmpq   $0x0,-0x1060(%rbp)
jne    13e8 <main+0x248>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1048(%rbp),%rdi
call   1030 <free@plt>
jmp    14f0 <main+0x350>
jmp    13ed <main+0x24d>
mov    -0x1060(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    140e <main+0x26e>
jmp    14a3 <main+0x303>
lea    -0x1040(%rbp),%rdi
mov    -0x1060(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %rax,-0x1068(%rbp)
movq   $0x0,-0x1070(%rbp)
mov    -0x1070(%rbp),%rax
cmp    -0x1068(%rbp),%rax
jae    1489 <main+0x2e9>
mov    -0x20(%rbp),%rdi
mov    -0x1070(%rbp),%rax
movzbl -0x1040(%rbp,%rax,1),%edx
ff
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1070(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1070(%rbp)
jmp    143d <main+0x29d>
mov    -0x1068(%rbp),%rax
add    -0x1058(%rbp),%rax
mov    %rax,-0x1058(%rbp)
jmp    13ed <main+0x24d>
mov    -0x1060(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
lea    0xc7f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x1048(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1329 <main+0x189>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1500 <main+0x360>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
cmp    $0x2,%edi
jg     11ec <main+0x2c>
lea    0xf4a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1475 <main+0x2b5>
mov    %rsi,%r13
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe04(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     140e <main+0x24e>
mov    %rax,%r14
mov    0x10(%r13),%rdi
lea    0xde8(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1414 <main+0x254>
mov    %rax,%rbx
lea    0xde1(%rip),%rdi
mov    $0x7a,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
cmp    $0x4,%ebp
jb     1435 <main+0x275>
mov    %ebp,0x10(%rsp)
mov    %r14,0x8(%rsp)
mov    %ebp,%r14d
mov    $0x3,%r15d
nopl   (%rax)
mov    0x0(%r13,%r15,8),%rdi
call   10e0 <strdup@plt>
mov    %r13,%r12
mov    %rax,%r13
mov    %rax,%rdi
call   1090 <basename@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   10c0 <replace_dots@plt>
mov    0x8(%rsp),%rdi
lea    0xdfd(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13,%rdi
mov    %r12,%r13
call   1030 <free@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1260 <main+0xa0>
mov    %r14,0x18(%rsp)
lea    0xdf9(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    0x8(%rsp),%rbp
mov    %rbp,%rcx
call   10d0 <fwrite@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    0x8(%r13),%rdx
lea    0xdd9(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
cmpl   $0x4,0x10(%rsp)
jb     146b <main+0x2ab>
mov    $0x3,%r15d
lea    0xe17(%rip),%rbp
jmp    1352 <main+0x192>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    $0x3,%esi
mov    $0x1,%edx
lea    0xdfa(%rip),%rdi
mov    %rbx,%rcx
call   10d0 <fwrite@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%r15
add    $0x1,%r15
cmp    0x18(%rsp),%r15
mov    %r12,%r13
je     146b <main+0x2ab>
mov    0x0(%r13,%r15,8),%rdi
call   10e0 <strdup@plt>
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
call   1090 <basename@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   10c0 <replace_dots@plt>
mov    %rbx,%rdi
lea    0xd7a(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r15,0x8(%rsp)
mov    0x0(%r13,%r15,8),%rdi
lea    0xd80(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1487 <main+0x2c7>
mov    %rax,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    1310 <main+0x150>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     13b0 <main+0x1f0>
mov    %rax,%r14
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x20(%rsp,%r13,1),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    13f0 <main+0x230>
jmp    13b0 <main+0x1f0>
mov    0x8(%r13),%rsi
jmp    1420 <main+0x260>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x10(%r13),%rsi
lea    0xbdb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%eax
jmp    1475 <main+0x2b5>
lea    0xc76(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x8(%r13),%rdx
lea    0xc5b(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%eax
mov    0x0(%r13,%rax,8),%rsi
lea    0xb6b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x3,%eax
jmp    1475 <main+0x2b5>

LLVM IR (-O0):
@.str = [22 x i8] c"not enough arguments\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [15 x i8] c"can't open %s\0A\00"
@.str.3 = [123 x i8] c"// generated file, all changes will be lost\0A#ifndef FPP_GENERATED_TXT_RESOURCES_H\0A#define FPP_GENERATED_TXT_RESOURCES_H\0A\0A\0A\00"
@.str.4 = [38 x i8] c"extern const char *resource_text_%s;\0A\00"
@.str.5 = [10 x i8] c"\0A\0A#endif\0A\00"
@.str.6 = [60 x i8] c"// generated file, all changes will be lost\0A#include \22%s\22\0A\0A\00"
@.str.7 = [33 x i8] c"const char *resource_text_%s = \22\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [7 x i8] c"\\x%02x\00"
@.str.10 = [4 x i8] c"\22;\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 i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca [4096 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32*
%17 = alloca i64
%18 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 3
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %164
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %6
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %35, label %30
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %33)
store i32 2, i32* %3
br label %164
35: ; preds = %23
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %7
%40 = load i32*, i32** %7
%41 = icmp ne i32* %40, null
br i1 %41, label %49, label %42
42: ; preds = %35
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %47)
store i32 2, i32* %3
br label %164
49: ; preds = %35
%50 = load i32*, i32** %6
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %50, i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %8
br label %52
52: ; preds = %72, %49
%53 = load i32, i32* %8
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %75
56: ; preds = %52
%57 = load i8**, i8*** %5
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = call i8* @strdup(i8* %61)
store i8* %62, i8** %9
%63 = load i8*, i8** %9
%64 = call i8* @basename(i8* %63)
store i8* %64, i8** %10
%65 = load i8*, i8** %10
%66 = call i32 @replace_dots(i8* %65)
%67 = load i32*, i32** %6
%68 = load i8*, i8** %10
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %68)
%70 = load i8*, i8** %9
%71 = call i32 @free(i8* %70)
br label %72
72: ; preds = %56
%73 = load i32, i32* %8
%74 = add nsw i32 %73, 1
store i32 %74, i32* %8
br label %52
75: ; preds = %52
%76 = load i32*, i32** %6
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
%80 = load i32*, i32** %7
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0), i8* %83)
store i32 3, i32* %11
br label %85
85: ; preds = %155, %75
%86 = load i32, i32* %11
%87 = load i32, i32* %4
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %158
89: ; preds = %85
%90 = load i8**, i8*** %5
%91 = load i32, i32* %11
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %90, i64 %92
%94 = load i8*, i8** %93
%95 = call i8* @strdup(i8* %94)
store i8* %95, i8** %13
%96 = load i8*, i8** %13
%97 = call i8* @basename(i8* %96)
store i8* %97, i8** %14
%98 = load i8*, i8** %14
%99 = call i32 @replace_dots(i8* %98)
%100 = load i32*, i32** %7
%101 = load i8*, i8** %14
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %100, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %101)
store i64 0, i64* %15
%103 = load i8**, i8*** %5
%104 = load i32, i32* %11
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %103, i64 %105
%107 = load i8*, i8** %106
%108 = call i32* @fopen(i8* %107, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %108, i32** %16
%109 = load i32*, i32** %16
%110 = icmp ne i32* %109, null
br i1 %110, label %120, label %111
111: ; preds = %89
%112 = load i8**, i8*** %5
%113 = load i32, i32* %11
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8*, i8** %112, i64 %114
%116 = load i8*, i8** %115
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %116)
%118 = load i8*, i8** %13
%119 = call i32 @free(i8* %118)
br label %161
120: ; preds = %89
br label %121
121: ; preds = %144, %120
%122 = load i32*, i32** %16
%123 = call i32 @feof(i32* %122)
%124 = icmp ne i32 %123, 0
%125 = xor i1 %124, true
br i1 %125, label %126, label %148
126: ; preds = %121
%127 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%128 = load i32*, i32** %16
%129 = call i64 @fread(i8* %127, i32 1, i32 4096, i32* %128)
store i64 %129, i64* %17
store i64 0, i64* %18
br label %130
130: ; preds = %141, %126
%131 = load i64, i64* %18
%132 = load i64, i64* %17
%133 = icmp ult i64 %131, %132
br i1 %133, label %134, label %144
134: ; preds = %130
%135 = load i32*, i32** %7
%136 = load i64, i64* %18
%137 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 %136
%138 = load i8, i8* %137
%139 = zext i8 %138 to i32
%140 = call i32 (i32*, i8*, ...) @fprintf(i32* %135, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %139)
br label %141
141: ; preds = %134
%142 = load i64, i64* %18
%143 = add i64 %142, 1
store i64 %143, i64* %18
br label %130
144: ; preds = %130
%145 = load i64, i64* %17
%146 = load i64, i64* %15
%147 = add i64 %146, %145
store i64 %147, i64* %15
br label %121
148: ; preds = %121
%149 = load i32*, i32** %16
%150 = call i32 @fclose(i32* %149)
%151 = load i32*, i32** %7
%152 = call i32 (i32*, i8*, ...) @fprintf(i32* %151, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%153 = load i8*, i8** %13
%154 = call i32 @free(i8* %153)
br label %155
155: ; preds = %148
%156 = load i32, i32* %11
%157 = add nsw i32 %156, 1
store i32 %157, i32* %11
br label %85
158: ; preds = %85
%159 = load i32*, i32** %7
%160 = call i32 @fclose(i32* %159)
store i32 0, i32* %3
br label %164
161: ; preds = %111
%162 = load i32*, i32** %7
%163 = call i32 @fclose(i32* %162)
store i32 3, i32* %3
br label %164
164: ; preds = %161, %158, %42, %30, %21
%165 = load i32, i32* %3
ret i32 %165
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [15 x i8] c"can't open %s\0A\00"
@.str.3 = [123 x i8] c"// generated file, all changes will be lost\0A#ifndef FPP_GENERATED_TXT_RESOURCES_H\0A#define FPP_GENERATED_TXT_RESOURCES_H\0A\0A\0A\00"
@.str.4 = [38 x i8] c"extern const char *resource_text_%s;\0A\00"
@.str.5 = [10 x i8] c"\0A\0A#endif\0A\00"
@.str.6 = [60 x i8] c"// generated file, all changes will be lost\0A#include \22%s\22\0A\0A\00"
@.str.7 = [33 x i8] c"const char *resource_text_%s = \22\00"
@.str.8 = [3 x i8] c"rb\00"
@.str.9 = [7 x i8] c"\\x%02x\00"
@.str.10 = [4 x i8] c"\22;\0A\00"
@str = [21 x i8] c"not enough arguments\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = icmp slt i32 %0, 3
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %96
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %13)
br label %96
15: ; preds = %7
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = tail call i32 @fclose(i32* %10)
%22 = load i8*, i8** %16
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %96
24: ; preds = %15
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.3, i64 0, i64 0), i64 122, i64 1, i32* %10)
%26 = icmp ugt i32 %0, 3
br i1 %26, label %27, label %82
27: ; preds = %24
%28 = zext i32 %0 to i64
br label %37
29: ; preds = %37
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64 9, i64 1, i32* %10)
%31 = tail call i32 @fclose(i32* %10)
%32 = load i8*, i8** %8
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0), i8* %32)
br i1 %26, label %34, label %87
34: ; preds = %29
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%36 = zext i32 %0 to i64
br label %48
37: ; preds = %27, %37
%38 = phi i64 [ 3, %27 ], [ %46, %37 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = tail call i8* @strdup(i8* %40)
%42 = tail call i8* @basename(i8* %41)
%43 = tail call i32 @replace_dots(i8* %42)
%44 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8* %42)
%45 = tail call i32 @free(i8* %41)
%46 = add nuw nsw i64 %38, 1
%47 = icmp eq i64 %46, %28
br i1 %47, label %29, label %37
48: ; preds = %34, %76
%49 = phi i64 [ 3, %34 ], [ %80, %76 ]
%50 = getelementptr inbounds i8*, i8** %1, i64 %49
%51 = load i8*, i8** %50
%52 = tail call i8* @strdup(i8* %51)
%53 = tail call i8* @basename(i8* %52)
%54 = tail call i32 @replace_dots(i8* %53)
%55 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %53)
%56 = load i8*, i8** %50
%57 = tail call i32* @fopen(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%58 = icmp eq i32* %57, null
br i1 %58, label %89, label %59
59: ; preds = %48
%60 = tail call i32 @feof(i32* %57)
%61 = icmp eq i32 %60, 0
br i1 %61, label %65, label %76
62: ; preds = %68, %65
%63 = tail call i32 @feof(i32* %57)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %76
65: ; preds = %59, %62
%66 = call i64 @fread(i8* %35, i32 1, i32 4096, i32* %57)
%67 = icmp eq i64 %66, 0
br i1 %67, label %62, label %68
68: ; preds = %65, %68
%69 = phi i64 [ %74, %68 ], [ 0, %65 ]
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32 %72)
%74 = add nuw i64 %69, 1
%75 = icmp eq i64 %74, %66
br i1 %75, label %62, label %68
76: ; preds = %62, %59
%77 = tail call i32 @fclose(i32* %57)
%78 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i64 3, i64 1, i32* %18)
%79 = tail call i32 @free(i8* %52)
%80 = add nuw nsw i64 %49, 1
%81 = icmp eq i64 %80, %36
br i1 %81, label %87, label %48
82: ; preds = %24
%83 = tail call i64 @fwrite(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i64 9, i64 1, i32* %10)
%84 = tail call i32 @fclose(i32* %10)
%85 = load i8*, i8** %8
%86 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %76, %82, %29
%88 = tail call i32 @fclose(i32* %18)
br label %96
89: ; preds = %48
%90 = and i64 %49, 4294967295
%91 = getelementptr inbounds i8*, i8** %1, i64 %90
%92 = load i8*, i8** %91
%93 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %92)
%94 = tail call i32 @free(i8* %52)
%95 = tail call i32 @fclose(i32* %18)
br label %96
96: ; preds = %12, %89, %87, %20, %5
%97 = phi i32 [ 1, %5 ], [ 2, %12 ], [ 3, %89 ], [ 0, %87 ], [ 2, %20 ]
ret i32 %97
}