#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *ifp;
  FILE *ofp;
  int i;
  int n;
  int count = 0;
  unsigned char buffer[1024];
  if (argc != 5) {
    fprintf(stderr, "Usage: %s <input> <output> <kwsys-name> <array>\n",
            argv[0]);
    return 1;
  }
  ifp = fopen(argv[1], "rb");
  if (!ifp) {
    fprintf(stderr, "Cannot open input file: \"%s\"\n", argv[1]);
    return 2;
  }
  ofp = fopen(argv[2], "w");
  if (!ofp) {
    fprintf(stderr, "Cannot open output file: \"%s\"\n", argv[2]);
    return 2;
  }
  fprintf(ofp, "/*\n * DO NOT EDIT\n * This file is generated by:\n");
  fprintf(ofp, " * %s\n */\n\n", argv[0]);
  fprintf(ofp, "#include \"kwsysPrivate.h\"\n");
  fprintf(ofp, "#include KWSYS_HEADER(Configure.h)\n\n");
  fprintf(ofp, "#include <stdio.h>\n\n");
  while ((n = (int)fread(buffer, 1, 1024, ifp)) > 0) {
    fprintf(ofp, "static unsigned char kwsysEncodedArray%s_%d[%d] = {\n",
            argv[4], count++, n);
    for (i = 0; i < n - 1; ++i) {
      fprintf(ofp, "0x%02X", buffer[i]);
      if (i % 10 == 9) {
        fprintf(ofp, ",\n");
      } else {
        fprintf(ofp, ", ");
      }
    }
    fprintf(ofp, "0x%02X};\n\n", buffer[n - 1]);
  }
  fclose(ifp);
  fprintf(ofp,
          "extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\n",
          argv[3], argv[3], argv[4]);
  fprintf(ofp, "{\n");
  fprintf(ofp, "  FILE* ofp = fopen(fname, \"wb\");\n");
  fprintf(ofp, "  if(!ofp) { return 0; }\n");
  for (i = 0; i < count; ++i) {
    fprintf(ofp,
            "  if(fwrite(kwsysEncodedArray%s_%d, 1,\n"
            "            sizeof(kwsysEncodedArray%s_%d), ofp) !=\n"
            "       sizeof(kwsysEncodedArray%s_%d))\n",
            argv[4], i, argv[4], i, argv[4], i);
    fprintf(ofp, "    {\n");
    fprintf(ofp, "    fclose(ofp);\n");
    fprintf(ofp, "    _unlink(fname);\n");
    fprintf(ofp, "    return 0;\n");
    fprintf(ofp, "    }\n");
  }
  fprintf(ofp, "  fclose(ofp);\n");
  fprintf(ofp, "  return 1;\n");
  fprintf(ofp, "}\n");
  fclose(ofp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1195 <main+0x55>
mov    0x2e6f(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f6 <main+0x3b6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e4 <main+0xa4>
mov    0x2e21(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f6 <main+0x3b6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1233 <main+0xf3>
mov    0x2dd2(%rip),%rax
movslq (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14f6 <main+0x3b6>
mov    -0x20(%rbp),%rdi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jle    1390 <main+0x250>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x2c(%rbp),%ecx
mov    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%r8d
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1369 <main+0x229>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
movzbl -0x430(%rbp,%rax,1),%edx
ff
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x9,%edx
jne    1344 <main+0x204>
mov    -0x20(%rbp),%rdi
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1356 <main+0x216>
mov    -0x20(%rbp),%rdi
lea    0xdf5(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    135b <main+0x21b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ea <main+0x1aa>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
cltq
movzbl -0x430(%rbp,%rax,1),%edx
ff
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1294 <main+0x154>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%r8
lea    0xd96(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    14b0 <main+0x370>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%r8
mov    -0x24(%rbp),%r9d
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%r10
mov    -0x24(%rbp),%eax
lea    0xd95(%rip),%rsi
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdf6(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1400 <main+0x2c0>
mov    -0x20(%rbp),%rdi
lea    0xd9f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,%r14
cmp    $0x5,%edi
jne    135d <main+0x20d>
mov    0x8(%r14),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     150e <main+0x3be>
mov    0x10(%r14),%rdi
lea    0xebc(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1525 <main+0x3d5>
mov    %rax,%r12
lea    0xec5(%rip),%rdi
mov    $0x30,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1070 <fwrite@plt>
mov    (%r14),%rdx
lea    0xeda(%rip),%rsi
xor    %ebx,%ebx
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xed3(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xed5(%rip),%rdi
mov    $0x24,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xee1(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    0x8(%rsp),%rcx
call   1030 <fread@plt>
mov    %rax,%rbp
test   %ebp,%ebp
jle    1382 <main+0x232>
xor    %ebx,%ebx
mov    %r14,0x20(%rsp)
jmp    129b <main+0x14b>
xchg   %ax,%ax
mov    0x14(%rsp),%ebx
add    $0x1,%ebx
mov    0x18(%rsp),%rax
movzbl 0x30(%rsp,%rax,1),%edx
mov    %r12,%rdi
lea    0xedc(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x30(%rsp),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    0x8(%rsp),%rcx
call   1030 <fread@plt>
mov    %rax,%rbp
test   %ebp,%ebp
mov    0x20(%rsp),%r14
jle    1382 <main+0x232>
mov    0x20(%r14),%rdx
mov    %r12,%rdi
lea    0xe5c(%rip),%rsi
mov    %ebx,0x14(%rsp)
mov    %ebx,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1050 <fprintf@plt>
movslq %ebp,%rax
lea    -0x1(%rax),%rcx
mov    %rcx,0x18(%rsp)
cmp    $0x2,%eax
mov    $0xcccccccd,%ecx
lea    0xe66(%rip),%rsi
lea    0xe66(%rip),%rbx
lea    0xe62(%rip),%rbp
jb     1250 <main+0x100>
mov    0x18(%rsp),%eax
mov    %rax,0x28(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%eax
imul   %rcx,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,1),%r14d
add    $0x9,%r14d
movzbl 0x30(%rsp,%r15,1),%edx
mov    %r12,%rdi
mov    %rsi,%r13
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    %r15d,%r14d
mov    %rbp,%rdi
cmove  %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    %r13,%rsi
mov    $0xcccccccd,%ecx
add    $0x1,%r15
cmp    %r15,0x28(%rsp)
jne    1300 <main+0x1b0>
jmp    1250 <main+0x100>
mov    0x2c7c(%rip),%rax
movslq (%rax),%rdi
mov    (%r14),%rdx
lea    0xc8f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    1546 <main+0x3f6>
mov    0x8(%rsp),%rdi
call   1040 <fclose@plt>
mov    0x18(%r14),%rcx
mov    0x20(%r14),%r8
lea    0xdb7(%rip),%rsi
mov    %r12,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xea6(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xdc9(%rip),%rdi
mov    $0x22,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xdd3(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
test   %ebx,%ebx
je     14b7 <main+0x367>
lea    0xe7d(%rip),%rbp
lea    0xe85(%rip),%r13
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    0x20(%r14),%rdx
mov    %r12,%rdi
lea    0xdb0(%rip),%rsi
mov    %r15d,%ecx
mov    %rdx,%r8
mov    %r15d,%r9d
xor    %eax,%eax
push   %r15
push   %rdx
call   1050 <fprintf@plt>
add    $0x10,%rsp
mov    $0x6,%esi
mov    $0x1,%edx
lea    0xe0b(%rip),%rdi
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    $0x11,%esi
mov    $0x1,%edx
lea    0xdf9(%rip),%rdi
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    $0x14,%esi
mov    $0x1,%edx
lea    0xdf2(%rip),%rdi
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r12,%rcx
call   1070 <fwrite@plt>
add    $0x1,%r15d
cmp    %r15d,%ebx
jne    1410 <main+0x2c0>
lea    0xd9c(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xdbe(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
lea    0xda2(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1546 <main+0x3f6>
mov    0x2acb(%rip),%rax
movslq (%rax),%rdi
mov    0x8(%r14),%rdx
lea    0xb11(%rip),%rsi
jmp    153a <main+0x3ea>
mov    0x2ab4(%rip),%rax
movslq (%rax),%rdi
mov    0x10(%r14),%rdx
lea    0xb1a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"Usage: %s <input> <output> <kwsys-name> <array>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [30 x i8] c"Cannot open input file: \22%s\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [31 x i8] c"Cannot open output file: \22%s\22\0A\00"
@.str.5 = [49 x i8] c"/*\0A * DO NOT EDIT\0A * This file is generated by:\0A\00"
@.str.6 = [12 x i8] c" * %s\0A */\0A\0A\00"
@.str.7 = [27 x i8] c"#include \22kwsysPrivate.h\22\0A\00"
@.str.8 = [37 x i8] c"#include KWSYS_HEADER(Configure.h)\0A\0A\00"
@.str.9 = [21 x i8] c"#include <stdio.h>\0A\0A\00"
@.str.10 = [53 x i8] c"static unsigned char kwsysEncodedArray%s_%d[%d] = {\0A\00"
@.str.11 = [7 x i8] c"0x%02X\00"
@.str.12 = [3 x i8] c",\0A\00"
@.str.13 = [3 x i8] c", \00"
@.str.14 = [11 x i8] c"0x%02X};\0A\0A\00"
@.str.15 = [63 x i8] c"extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\0A\00"
@.str.16 = [3 x i8] c"{\0A\00"
@.str.17 = [35 x i8] c" FILE* ofp = fopen(fname, \22wb\22);\0A\00"
@.str.18 = [26 x i8] c" if(!ofp) { return 0; }\0A\00"
@.str.19 = [131 x i8] c" if(fwrite(kwsysEncodedArray%s_%d, 1,\0A sizeof(kwsysEncodedArray%s_%d), ofp) !=\0A sizeof(kwsysEncodedArray%s_%d))\0A\00"
@.str.20 = [7 x i8] c" {\0A\00"
@.str.21 = [18 x i8] c" fclose(ofp);\0A\00"
@.str.22 = [21 x i8] c" _unlink(fname);\0A\00"
@.str.23 = [15 x i8] c" return 0;\0A\00"
@.str.24 = [7 x i8] c" }\0A\00"
@.str.25 = [16 x i8] c" fclose(ofp);\0A\00"
@.str.26 = [13 x i8] c" return 1;\0A\00"
@.str.27 = [3 x i8] c"}\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 i32
%10 = alloca i32
%11 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %177
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = icmp ne i32* %27, null
br i1 %28, label %37, label %29
29: ; preds = %22
%30 = load i32, i32* @stderr
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store i32 2, i32* %3
br label %177
37: ; preds = %22
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%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** %7
%42 = load i32*, i32** %7
%43 = icmp ne i32* %42, null
br i1 %43, label %52, label %44
44: ; preds = %37
%45 = load i32, i32* @stderr
%46 = sext i32 %45 to i64
%47 = inttoptr i64 %46 to i32*
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 (i32*, i8*, ...) @fprintf(i32* %47, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %50)
store i32 2, i32* %3
br label %177
52: ; preds = %37
%53 = load i32*, i32** %7
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%55 = load i32*, i32** %7
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 0
%58 = load i8*, i8** %57
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %58)
%60 = load i32*, i32** %7
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
%62 = load i32*, i32** %7
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%64 = load i32*, i32** %7
%65 = call i32 (i32*, i8*, ...) @fprintf(i32* %64, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %66
66: ; preds = %107, %52
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%68 = load i32*, i32** %6
%69 = call i64 @fread(i8* %67, i32 1, i32 1024, i32* %68)
%70 = trunc i64 %69 to i32
store i32 %70, i32* %9
%71 = icmp sgt i32 %70, 0
br i1 %71, label %72, label %116
72: ; preds = %66
%73 = load i32*, i32** %7
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 4
%76 = load i8*, i8** %75
%77 = load i32, i32* %10
%78 = add nsw i32 %77, 1
store i32 %78, i32* %10
%79 = load i32, i32* %9
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %73, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i8* %76, i32 %77, i32 %79)
store i32 0, i32* %8
br label %81
81: ; preds = %104, %72
%82 = load i32, i32* %8
%83 = load i32, i32* %9
%84 = sub nsw i32 %83, 1
%85 = icmp slt i32 %82, %84
br i1 %85, label %86, label %107
86: ; preds = %81
%87 = load i32*, i32** %7
%88 = load i32, i32* %8
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %92)
%94 = load i32, i32* %8
%95 = srem i32 %94, 10
%96 = icmp eq i32 %95, 9
br i1 %96, label %97, label %100
97: ; preds = %86
%98 = load i32*, i32** %7
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %103
100: ; preds = %86
%101 = load i32*, i32** %7
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %103
103: ; preds = %100, %97
br label %104
104: ; preds = %103
%105 = load i32, i32* %8
%106 = add nsw i32 %105, 1
store i32 %106, i32* %8
br label %81
107: ; preds = %81
%108 = load i32*, i32** %7
%109 = load i32, i32* %9
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %111
%113 = load i8, i8* %112
%114 = zext i8 %113 to i32
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %108, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32 %114)
br label %66
116: ; preds = %66
%117 = load i32*, i32** %6
%118 = call i32 @fclose(i32* %117)
%119 = load i32*, i32** %7
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 3
%122 = load i8*, i8** %121
%123 = load i8**, i8*** %5
%124 = getelementptr inbounds i8*, i8** %123, i64 3
%125 = load i8*, i8** %124
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 4
%128 = load i8*, i8** %127
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %119, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.15, i64 0, i64 0), i8* %122, i8* %125, i8* %128)
%130 = load i32*, i32** %7
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0))
%132 = load i32*, i32** %7
%133 = call i32 (i32*, i8*, ...) @fprintf(i32* %132, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.17, i64 0, i64 0))
%134 = load i32*, i32** %7
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %134, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0))
store i32 0, i32* %8
br label %136
136: ; preds = %165, %116
%137 = load i32, i32* %8
%138 = load i32, i32* %10
%139 = icmp slt i32 %137, %138
br i1 %139, label %140, label %168
140: ; preds = %136
%141 = load i32*, i32** %7
%142 = load i8**, i8*** %5
%143 = getelementptr inbounds i8*, i8** %142, i64 4
%144 = load i8*, i8** %143
%145 = load i32, i32* %8
%146 = load i8**, i8*** %5
%147 = getelementptr inbounds i8*, i8** %146, i64 4
%148 = load i8*, i8** %147
%149 = load i32, i32* %8
%150 = load i8**, i8*** %5
%151 = getelementptr inbounds i8*, i8** %150, i64 4
%152 = load i8*, i8** %151
%153 = load i32, i32* %8
%154 = call i32 (i32*, i8*, ...) @fprintf(i32* %141, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.19, i64 0, i64 0), i8* %144, i32 %145, i8* %148, i32 %149, i8* %152, i32 %153)
%155 = load i32*, i32** %7
%156 = call i32 (i32*, i8*, ...) @fprintf(i32* %155, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0))
%157 = load i32*, i32** %7
%158 = call i32 (i32*, i8*, ...) @fprintf(i32* %157, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.21, i64 0, i64 0))
%159 = load i32*, i32** %7
%160 = call i32 (i32*, i8*, ...) @fprintf(i32* %159, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
%161 = load i32*, i32** %7
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %161, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0))
%163 = load i32*, i32** %7
%164 = call i32 (i32*, i8*, ...) @fprintf(i32* %163, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0))
br label %165
165: ; preds = %140
%166 = load i32, i32* %8
%167 = add nsw i32 %166, 1
store i32 %167, i32* %8
br label %136
168: ; preds = %136
%169 = load i32*, i32** %7
%170 = call i32 (i32*, i8*, ...) @fprintf(i32* %169, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0))
%171 = load i32*, i32** %7
%172 = call i32 (i32*, i8*, ...) @fprintf(i32* %171, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.26, i64 0, i64 0))
%173 = load i32*, i32** %7
%174 = call i32 (i32*, i8*, ...) @fprintf(i32* %173, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0))
%175 = load i32*, i32** %7
%176 = call i32 @fclose(i32* %175)
store i32 0, i32* %3
br label %177
177: ; preds = %168, %44, %29, %14
%178 = load i32, i32* %3
ret i32 %178
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"Usage: %s <input> <output> <kwsys-name> <array>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [30 x i8] c"Cannot open input file: \22%s\22\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [31 x i8] c"Cannot open output file: \22%s\22\0A\00"
@.str.5 = [49 x i8] c"/*\0A * DO NOT EDIT\0A * This file is generated by:\0A\00"
@.str.6 = [12 x i8] c" * %s\0A */\0A\0A\00"
@.str.7 = [27 x i8] c"#include \22kwsysPrivate.h\22\0A\00"
@.str.8 = [37 x i8] c"#include KWSYS_HEADER(Configure.h)\0A\0A\00"
@.str.9 = [21 x i8] c"#include <stdio.h>\0A\0A\00"
@.str.10 = [53 x i8] c"static unsigned char kwsysEncodedArray%s_%d[%d] = {\0A\00"
@.str.11 = [7 x i8] c"0x%02X\00"
@.str.12 = [3 x i8] c",\0A\00"
@.str.13 = [3 x i8] c", \00"
@.str.14 = [11 x i8] c"0x%02X};\0A\0A\00"
@.str.15 = [63 x i8] c"extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\0A\00"
@.str.16 = [3 x i8] c"{\0A\00"
@.str.17 = [35 x i8] c" FILE* ofp = fopen(fname, \22wb\22);\0A\00"
@.str.18 = [26 x i8] c" if(!ofp) { return 0; }\0A\00"
@.str.19 = [131 x i8] c" if(fwrite(kwsysEncodedArray%s_%d, 1,\0A sizeof(kwsysEncodedArray%s_%d), ofp) !=\0A sizeof(kwsysEncodedArray%s_%d))\0A\00"
@.str.20 = [7 x i8] c" {\0A\00"
@.str.21 = [18 x i8] c" fclose(ofp);\0A\00"
@.str.22 = [21 x i8] c" _unlink(fname);\0A\00"
@.str.23 = [15 x i8] c" return 0;\0A\00"
@.str.24 = [7 x i8] c" }\0A\00"
@.str.25 = [16 x i8] c" fclose(ofp);\0A\00"
@.str.26 = [13 x i8] c" return 1;\0A\00"
@.str.27 = [3 x i8] c"}\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 5
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = load i8*, i8** %1
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %106
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %23
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = load i8*, i8** %13
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %106
23: ; preds = %12
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32*
%32 = load i8*, i8** %24
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %32)
br label %106
34: ; preds = %23
%35 = tail call i64 @fwrite(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i64 48, i64 1, i32* %26)
%36 = load i8*, i8** %1
%37 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %36)
%38 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i64 26, i64 1, i32* %26)
%39 = tail call i64 @fwrite(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i64 36, i64 1, i32* %26)
%40 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i64 20, i64 1, i32* %26)
%41 = call i64 @fread(i8* %4, i32 1, i32 1024, i32* %15)
%42 = trunc i64 %41 to i32
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %78
44: ; preds = %34
%45 = getelementptr inbounds i8*, i8** %1, i64 4
br label %46
46: ; preds = %44, %69
%47 = phi i32 [ %42, %44 ], [ %76, %69 ]
%48 = phi i32 [ 0, %44 ], [ %50, %69 ]
%49 = load i8*, i8** %45
%50 = add nuw nsw i32 %48, 1
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0), i8* %49, i32 %48, i32 %47)
%52 = add nsw i32 %47, -1
%53 = icmp ugt i32 %47, 1
br i1 %53, label %54, label %69
54: ; preds = %46
%55 = zext i32 %52 to i64
br label %56
56: ; preds = %54, %56
%57 = phi i64 [ 0, %54 ], [ %67, %56 ]
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i32 %60)
%62 = trunc i64 %57 to i32
%63 = urem i32 %62, 10
%64 = icmp eq i32 %63, 9
%65 = select i1 %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0)
%66 = tail call i64 @fwrite(i8* %65, i64 2, i64 1, i32* %26)
%67 = add nuw nsw i64 %57, 1
%68 = icmp eq i64 %67, %55
br i1 %68, label %69, label %56
69: ; preds = %56, %46
%70 = sext i32 %52 to i64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0), i32 %73)
%75 = call i64 @fread(i8* %4, i32 1, i32 1024, i32* %15)
%76 = trunc i64 %75 to i32
%77 = icmp sgt i32 %76, 0
br i1 %77, label %46, label %78
78: ; preds = %69, %34
%79 = phi i32 [ 0, %34 ], [ %50, %69 ]
%80 = tail call i32 @fclose(i32* %15)
%81 = getelementptr inbounds i8*, i8** %1, i64 3
%82 = load i8*, i8** %81
%83 = getelementptr inbounds i8*, i8** %1, i64 4
%84 = load i8*, i8** %83
%85 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.15, i64 0, i64 0), i8* %82, i8* %82, i8* %84)
%86 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i64 2, i64 1, i32* %26)
%87 = tail call i64 @fwrite(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.17, i64 0, i64 0), i64 34, i64 1, i32* %26)
%88 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.18, i64 0, i64 0), i64 25, i64 1, i32* %26)
%89 = icmp eq i32 %79, 0
br i1 %89, label %101, label %90
90: ; preds = %78, %90
%91 = phi i32 [ %99, %90 ], [ 0, %78 ]
%92 = load i8*, i8** %83
%93 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([131 x i8], [131 x i8]* @.str.19, i64 0, i64 0), i8* %92, i32 %91, i8* %92, i32 %91, i8* %92, i32 %91)
%94 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0), i64 6, i64 1, i32* %26)
%95 = tail call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.21, i64 0, i64 0), i64 17, i64 1, i32* %26)
%96 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0), i64 20, i64 1, i32* %26)
%97 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i64 0, i64 0), i64 14, i64 1, i32* %26)
%98 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0), i64 6, i64 1, i32* %26)
%99 = add nuw i32 %91, 1
%100 = icmp eq i32 %99, %79
br i1 %100, label %101, label %90
101: ; preds = %90, %78
%102 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), i64 15, i64 1, i32* %26)
%103 = tail call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.26, i64 0, i64 0), i64 12, i64 1, i32* %26)
%104 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.27, i64 0, i64 0), i64 2, i64 1, i32* %26)
%105 = tail call i32 @fclose(i32* %26)
br label %106
106: ; preds = %101, %28, %17, %6
%107 = phi i32 [ 1, %6 ], [ 0, %101 ], [ 2, %28 ], [ 2, %17 ]
ret i32 %107
}