#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
unsigned char getc(int /*<<< orphan*/ *);
scalar_t__ getenv(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *infile, *outfile;
  char infname[1024];
  char outfname[1024];
  char *rt28xxdir;
  char *chipset;
  int i = 0;
  unsigned char c;
  memset(infname, 0, 1024);
  memset(outfname, 0, 1024);
  rt28xxdir = (char *)getenv("RT28xx_DIR");
  chipset = (char *)getenv("CHIPSET");
  if (!rt28xxdir) {
    printf("Environment value \"RT28xx_DIR\" not export \n");
    return -1;
  }
  if (!chipset) {
    printf("Environment value \"CHIPSET\" not export \n");
    return -1;
  }
  strcat(infname, rt28xxdir);
  if (strncmp(chipset, "2860", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "2870", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else
    strcat(infname, "/common/rt2860.bin");
  strcat(outfname, rt28xxdir);
  strcat(outfname, "/include/firmware.h");
  infile = fopen(infname, "r");
  if (infile == (FILE *)NULL) {
    printf("Can't read file %s \n", infname);
    return -1;
  }
  outfile = fopen(outfname, "w");
  if (outfile == (FILE *)NULL) {
    printf("Can't open write file %s \n", outfname);
    return -1;
  }
  fputs("/*\n", outfile);
  fputs(" Copyright (c) 2007, Ralink Technology Corporation \n", outfile);
  fputs(" All rights reserved. \n\n", outfile);
  fputs(" Redistribution.  Redistribution and use in binary form, without \n",
        outfile);
  fputs(" modification, are permitted provided that the following conditions "
        "are \n",
        outfile);
  fputs(" met: \n\n", outfile);
  fputs(" \t* Redistributions must reproduce the above copyright notice and "
        "the \n",
        outfile);
  fputs(
      " \tfollowing disclaimer in the documentation and/or other materials \n",
      outfile);
  fputs(" \tprovided with the distribution. \n", outfile);
  fputs(" \t* Neither the name of Ralink Technology Corporation nor the names "
        "of its \n",
        outfile);
  fputs(" \tsuppliers may be used to endorse or promote products derived from "
        "this \n",
        outfile);
  fputs(" \tsoftware without specific prior written permission. \n", outfile);
  fputs(" \t* No reverse engineering, decompilation, or disassembly of this "
        "software \n",
        outfile);
  fputs(" \tis permitted. \n\n", outfile);
  fputs(" Limited patent license. Ralink Technology Corporation grants a "
        "world-wide, \n",
        outfile);
  fputs(" royalty-free, non-exclusive license under patents it now or "
        "hereafter \n",
        outfile);
  fputs(
      " owns or controls to make, have made, use, import, offer to sell and \n",
      outfile);
  fputs(
      " sell (\"Utilize\") this software, but solely to the extent that any \n",
      outfile);
  fputs(" such patent is necessary to Utilize the software alone, or in \n",
        outfile);
  fputs(" combination with an operating system licensed under an approved Open "
        "\n",
        outfile);
  fputs(" Source license as listed by the Open Source Initiative at \n",
        outfile);
  fputs(" http://opensource.org/licenses.  The patent license shall not apply "
        "to \n",
        outfile);
  fputs(" any other combinations which include this software.  No hardware per "
        "\n",
        outfile);
  fputs(" se is licensed hereunder. \n\n", outfile);
  fputs(
      " DISCLAIMER.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \n",
      outfile);
  fputs(" CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, "
        "INCLUDING, \n",
        outfile);
  fputs(" BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \n",
        outfile);
  fputs(" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL "
        "THE \n",
        outfile);
  fputs(
      " COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \n",
      outfile);
  fputs(" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, "
        "\n",
        outfile);
  fputs(" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; "
        "LOSS \n",
        outfile);
  fputs(" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED "
        "AND \n",
        outfile);
  fputs(" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, "
        "OR \n",
        outfile);
  fputs(" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF "
        "THE \n",
        outfile);
  fputs(" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \n",
        outfile);
  fputs(" DAMAGE. \n", outfile);
  fputs("*/ \n", outfile);
  fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n", outfile);
  fputs("/* AUTO GEN PLEASE DO NOT MODIFY IT */ \n", outfile);
  fputs("\n", outfile);
  fputs("\n", outfile);
  fputs("UCHAR FirmwareImage [] = { \n", outfile);
  while (1) {
    char cc[3];
    c = getc(infile);
    if (feof(infile))
      break;
    memset(cc, 0, 2);
    if (i >= 16) {
      fputs("\n", outfile);
      i = 0;
    }
    fputs("0x", outfile);
    sprintf(cc, "%02x", c);
    fputs(cc, outfile);
    fputs(", ", outfile);
    i++;
  }
  fputs("} ;\n", outfile);
  fclose(infile);
  fclose(outfile);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x834(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1080 <memset@plt>
lea    0xdf0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x828(%rbp)
lea    0xde8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x830(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    1257 <main+0x97>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1752 <main+0x592>
cmpq   $0x0,-0x830(%rbp)
jne    127f <main+0xbf>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1752 <main+0x592>
lea    -0x420(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x830(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12cc <main+0x10c>
lea    -0x420(%rbp),%rdi
lea    0xdab(%rip),%rsi
call   10b0 <strcat@plt>
jmp    131e <main+0x15e>
mov    -0x830(%rbp),%rdi
lea    0xda6(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1306 <main+0x146>
lea    -0x420(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   10b0 <strcat@plt>
jmp    1319 <main+0x159>
lea    -0x420(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   10b0 <strcat@plt>
jmp    131e <main+0x15e>
lea    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   10b0 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xd5a(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1387 <main+0x1c7>
lea    -0x420(%rbp),%rsi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1752 <main+0x592>
lea    -0x820(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    13ca <main+0x20a>
lea    -0x820(%rbp),%rsi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1752 <main+0x592>
mov    -0x20(%rbp),%rsi
lea    0xd0b(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xcff(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd24(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd2d(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd60(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd9a(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd93(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xdcb(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xe14(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xeb4(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xef1(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xef4(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xf32(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xf6b(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xfa2(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xfd7(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1008(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1040(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x106d(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x10a7(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x10df(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x10ed(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1124(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x115e(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1193(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x11cd(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1204(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x123c(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1275(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x12af(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x12e8(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1322(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1356(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1375(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1341(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x1331(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd62(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xd52(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x132a(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   10e0 <getc@plt>
mov    %al,-0x835(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     1691 <main+0x4d1>
jmp    1729 <main+0x569>
lea    -0x838(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <memset@plt>
cmpl   $0x10,-0x834(%rbp)
jl     16cb <main+0x50b>
mov    -0x20(%rbp),%rsi
lea    0xceb(%rip),%rdi
call   1070 <fputs@plt>
movl   $0x0,-0x834(%rbp)
mov    -0x20(%rbp),%rsi
lea    0x12d6(%rip),%rdi
call   1070 <fputs@plt>
lea    -0x838(%rbp),%rdi
lea    0x12c6(%rip),%rsi
movzbl -0x835(%rbp),%edx
call   10c0 <sprintf@plt>
lea    -0x838(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x12a4(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x834(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x834(%rbp)
jmp    166a <main+0x4aa>
mov    -0x20(%rbp),%rsi
lea    0x1283(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0x410(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1090 <memset@plt>
lea    0xdd3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xdcf(%rip),%rdi
call   1030 <getenv@plt>
test   %rbx,%rbx
je     12a2 <main+0xb2>
mov    %rax,%rbp
test   %rax,%rax
je     12ab <main+0xbb>
lea    0x410(%rsp),%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
lea    0xdae(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     12bc <main+0xcc>
lea    0xdad(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
lea    0xd9b(%rip),%rax
lea    0xd7c(%rip),%rsi
cmove  %rax,%rsi
jmp    12c3 <main+0xd3>
lea    0x16be(%rip),%rdi
jmp    12b2 <main+0xc2>
lea    0x16e0(%rip),%rdi
call   1050 <puts@plt>
jmp    1343 <main+0x153>
lea    0xd55(%rip),%rsi
lea    0x410(%rsp),%r14
mov    %r14,%rdi
call   10d0 <strcat@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <strcat@plt>
lea    0xd59(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcat@plt>
lea    0xd5e(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     132d <main+0x13d>
mov    %rax,%rbx
lea    0xd5e(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
jne    135a <main+0x16a>
lea    0xd4a(%rip),%rdi
lea    0x10(%rsp),%rsi
jmp    133c <main+0x14c>
lea    0xd25(%rip),%rdi
lea    0x410(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%r14
lea    0xd27(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1100 <fwrite@plt>
lea    0xd12(%rip),%rdi
mov    $0x34,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xd2e(%rip),%rdi
mov    $0x18,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xd2e(%rip),%rdi
mov    $0x42,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xd58(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xd89(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xd79(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xda8(%rip),%rdi
mov    $0x44,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xdd4(%rip),%rdi
mov    $0x23,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xddf(%rip),%rdi
mov    $0x4c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xe13(%rip),%rdi
mov    $0x4a,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xe45(%rip),%rdi
mov    $0x37,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xe64(%rip),%rdi
mov    $0x4c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xe98(%rip),%rdi
mov    $0x12,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xe92(%rip),%rdi
mov    $0x4d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xec7(%rip),%rdi
mov    $0x48,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xef7(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xf25(%rip),%rdi
mov    $0x44,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xf51(%rip),%rdi
mov    $0x40,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xf79(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xfa8(%rip),%rdi
mov    $0x3c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xfcc(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0xffd(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x102c(%rip),%rdi
mov    $0x1d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x1031(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x105f(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x1090(%rip),%rdi
mov    $0x44,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x10bc(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x10ed(%rip),%rdi
mov    $0x46,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x111b(%rip),%rdi
mov    $0x47,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x114a(%rip),%rdi
mov    $0x48,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x117a(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x11ab(%rip),%rdi
mov    $0x48,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x11db(%rip),%rdi
mov    $0x49,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x120c(%rip),%rdi
mov    $0x43,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x1237(%rip),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x124d(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
lea    0x1210(%rip),%rbp
mov    $0x28,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   1100 <fwrite@plt>
mov    $0x28,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   1100 <fwrite@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
lea    0x11ee(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
mov    %rbx,%rdi
call   1110 <getc@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %rax,%rax
jne    181d <main+0x62d>
xor    %r13d,%r13d
lea    0xd(%rsp),%r15
lea    0x11d6(%rip),%rbp
jmp    17f3 <main+0x603>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0x11bb(%rip),%rdi
mov    %r14,%rcx
call   1100 <fwrite@plt>
movzbl %r12b,%edx
mov    %r15,%rdi
lea    0x11a8(%rip),%rsi
call   10e0 <sprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <fputs@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   1100 <fwrite@plt>
add    $0x1,%r13d
mov    %rbx,%rdi
call   1110 <getc@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   10b0 <feof@plt>
test   %rax,%rax
jne    181d <main+0x62d>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1090 <memset@plt>
cmp    $0x10,%r13d
jl     178b <main+0x59b>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
xor    %r13d,%r13d
jmp    178b <main+0x59b>
lea    0x113e(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1100 <fwrite@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [8 x i8] c"CHIPSET\00"
@.str.2 = [44 x i8] c"Environment value \22RT28xx_DIR\22 not export \0A\00"
@.str.3 = [41 x i8] c"Environment value \22CHIPSET\22 not export \0A\00"
@.str.4 = [5 x i8] c"2860\00"
@.str.5 = [19 x i8] c"/common/rt2860.bin\00"
@.str.6 = [5 x i8] c"2870\00"
@.str.7 = [19 x i8] c"/common/rt2870.bin\00"
@.str.8 = [20 x i8] c"/include/firmware.h\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [21 x i8] c"Can't read file %s \0A\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.13 = [4 x i8] c"/*\0A\00"
@.str.14 = [53 x i8] c" Copyright (c) 2007, Ralink Technology Corporation \0A\00"
@.str.15 = [25 x i8] c" All rights reserved. \0A\0A\00"
@.str.16 = [67 x i8] c" Redistribution. Redistribution and use in binary form, without \0A\00"
@.str.17 = [74 x i8] c" modification, are permitted provided that the following conditions are \0A\00"
@.str.18 = [9 x i8] c" met: \0A\0A\00"
@.str.19 = [72 x i8] c" \09* Redistributions must reproduce the above copyright notice and the \0A\00"
@.str.20 = [69 x i8] c" \09following disclaimer in the documentation and/or other materials \0A\00"
@.str.21 = [36 x i8] c" \09provided with the distribution. \0A\00"
@.str.22 = [77 x i8] c" \09* Neither the name of Ralink Technology Corporation nor the names of its \0A\00"
@.str.23 = [75 x i8] c" \09suppliers may be used to endorse or promote products derived from this \0A\00"
@.str.24 = [56 x i8] c" \09software without specific prior written permission. \0A\00"
@.str.25 = [77 x i8] c" \09* No reverse engineering, decompilation, or disassembly of this software \0A\00"
@.str.26 = [19 x i8] c" \09is permitted. \0A\0A\00"
@.str.27 = [78 x i8] c" Limited patent license. Ralink Technology Corporation grants a world-wide, \0A\00"
@.str.28 = [73 x i8] c" royalty-free, non-exclusive license under patents it now or hereafter \0A\00"
@.str.29 = [71 x i8] c" owns or controls to make, have made, use, import, offer to sell and \0A\00"
@.str.30 = [69 x i8] c" sell (\22Utilize\22) this software, but solely to the extent that any \0A\00"
@.str.31 = [65 x i8] c" such patent is necessary to Utilize the software alone, or in \0A\00"
@.str.32 = [72 x i8] c" combination with an operating system licensed under an approved Open \0A\00"
@.str.33 = [61 x i8] c" Source license as listed by the Open Source Initiative at \0A\00"
@.str.34 = [74 x i8] c" http://opensource.org/licenses. The patent license shall not apply to \0A\00"
@.str.35 = [72 x i8] c" any other combinations which include this software. No hardware per \0A\00"
@.str.36 = [30 x i8] c" se is licensed hereunder. \0A\0A\00"
@.str.37 = [71 x i8] c" DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \0A\00"
@.str.38 = [74 x i8] c" CONTRIBUTORS \22AS IS\22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, \0A\00"
@.str.39 = [69 x i8] c" BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \0A\00"
@.str.40 = [74 x i8] c" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \0A\00"
@.str.41 = [71 x i8] c" COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \0A\00"
@.str.42 = [72 x i8] c" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \0A\00"
@.str.43 = [73 x i8] c" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS \0A\00"
@.str.44 = [74 x i8] c" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND \0A\00"
@.str.45 = [73 x i8] c" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR \0A\00"
@.str.46 = [74 x i8] c" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE \0A\00"
@.str.47 = [68 x i8] c" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \0A\00"
@.str.48 = [11 x i8] c" DAMAGE. \0A\00"
@.str.49 = [5 x i8] c"*/ \0A\00"
@.str.50 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.51 = [2 x i8] c"\0A\00"
@.str.52 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.53 = [3 x i8] c"0x\00"
@.str.54 = [5 x i8] c"%02x\00"
@.str.55 = [3 x i8] c", \00"
@.str.56 = [5 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 [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8
%14 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 1024)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 1024)
%19 = call i64 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %10
%21 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %11
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %27, label %25
25: ; preds = %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %195
27: ; preds = %2
%28 = load i8*, i8** %11
%29 = icmp ne i8* %28, null
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %195
32: ; preds = %27
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = load i8*, i8** %10
%35 = call i32 @strcat(i8* %33, i8* %34)
%36 = load i8*, i8** %11
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%41 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %53
42: ; preds = %32
%43 = load i8*, i8** %11
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%48 = call i32 @strcat(i8* %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %52
49: ; preds = %42
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %49, %46
br label %53
53: ; preds = %52, %39
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%55 = load i8*, i8** %10
%56 = call i32 @strcat(i8* %54, i8* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%58 = call i32 @strcat(i8* %57, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %60, i32** %6
%61 = load i32*, i32** %6
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %66
63: ; preds = %53
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %64)
store i32 -1, i32* %3
br label %195
66: ; preds = %53
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %68, i32** %7
%69 = load i32*, i32** %7
%70 = icmp eq i32* %69, null
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* %72)
store i32 -1, i32* %3
br label %195
74: ; preds = %66
%75 = load i32*, i32** %7
%76 = call i32 @fputs(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32* %75)
%77 = load i32*, i32** %7
%78 = call i32 @fputs(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i32* %77)
%79 = load i32*, i32** %7
%80 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), i32* %79)
%81 = load i32*, i32** %7
%82 = call i32 @fputs(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.16, i64 0, i64 0), i32* %81)
%83 = load i32*, i32** %7
%84 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.17, i64 0, i64 0), i32* %83)
%85 = load i32*, i32** %7
%86 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i32* %85)
%87 = load i32*, i32** %7
%88 = call i32 @fputs(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.19, i64 0, i64 0), i32* %87)
%89 = load i32*, i32** %7
%90 = call i32 @fputs(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.20, i64 0, i64 0), i32* %89)
%91 = load i32*, i32** %7
%92 = call i32 @fputs(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.21, i64 0, i64 0), i32* %91)
%93 = load i32*, i32** %7
%94 = call i32 @fputs(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.22, i64 0, i64 0), i32* %93)
%95 = load i32*, i32** %7
%96 = call i32 @fputs(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.23, i64 0, i64 0), i32* %95)
%97 = load i32*, i32** %7
%98 = call i32 @fputs(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.24, i64 0, i64 0), i32* %97)
%99 = load i32*, i32** %7
%100 = call i32 @fputs(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.25, i64 0, i64 0), i32* %99)
%101 = load i32*, i32** %7
%102 = call i32 @fputs(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.26, i64 0, i64 0), i32* %101)
%103 = load i32*, i32** %7
%104 = call i32 @fputs(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.27, i64 0, i64 0), i32* %103)
%105 = load i32*, i32** %7
%106 = call i32 @fputs(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.28, i64 0, i64 0), i32* %105)
%107 = load i32*, i32** %7
%108 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.29, i64 0, i64 0), i32* %107)
%109 = load i32*, i32** %7
%110 = call i32 @fputs(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.30, i64 0, i64 0), i32* %109)
%111 = load i32*, i32** %7
%112 = call i32 @fputs(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.31, i64 0, i64 0), i32* %111)
%113 = load i32*, i32** %7
%114 = call i32 @fputs(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.32, i64 0, i64 0), i32* %113)
%115 = load i32*, i32** %7
%116 = call i32 @fputs(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.33, i64 0, i64 0), i32* %115)
%117 = load i32*, i32** %7
%118 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.34, i64 0, i64 0), i32* %117)
%119 = load i32*, i32** %7
%120 = call i32 @fputs(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.35, i64 0, i64 0), i32* %119)
%121 = load i32*, i32** %7
%122 = call i32 @fputs(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.36, i64 0, i64 0), i32* %121)
%123 = load i32*, i32** %7
%124 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.37, i64 0, i64 0), i32* %123)
%125 = load i32*, i32** %7
%126 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.38, i64 0, i64 0), i32* %125)
%127 = load i32*, i32** %7
%128 = call i32 @fputs(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.39, i64 0, i64 0), i32* %127)
%129 = load i32*, i32** %7
%130 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.40, i64 0, i64 0), i32* %129)
%131 = load i32*, i32** %7
%132 = call i32 @fputs(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.41, i64 0, i64 0), i32* %131)
%133 = load i32*, i32** %7
%134 = call i32 @fputs(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.42, i64 0, i64 0), i32* %133)
%135 = load i32*, i32** %7
%136 = call i32 @fputs(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.43, i64 0, i64 0), i32* %135)
%137 = load i32*, i32** %7
%138 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.44, i64 0, i64 0), i32* %137)
%139 = load i32*, i32** %7
%140 = call i32 @fputs(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.45, i64 0, i64 0), i32* %139)
%141 = load i32*, i32** %7
%142 = call i32 @fputs(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.46, i64 0, i64 0), i32* %141)
%143 = load i32*, i32** %7
%144 = call i32 @fputs(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.47, i64 0, i64 0), i32* %143)
%145 = load i32*, i32** %7
%146 = call i32 @fputs(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.48, i64 0, i64 0), i32* %145)
%147 = load i32*, i32** %7
%148 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.49, i64 0, i64 0), i32* %147)
%149 = load i32*, i32** %7
%150 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.50, i64 0, i64 0), i32* %149)
%151 = load i32*, i32** %7
%152 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.50, i64 0, i64 0), i32* %151)
%153 = load i32*, i32** %7
%154 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.51, i64 0, i64 0), i32* %153)
%155 = load i32*, i32** %7
%156 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.51, i64 0, i64 0), i32* %155)
%157 = load i32*, i32** %7
%158 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.52, i64 0, i64 0), i32* %157)
br label %159
159: ; preds = %74, %174
%160 = load i32*, i32** %6
%161 = call zeroext i8 @getc(i32* %160)
store i8 %161, i8* %13
%162 = load i32*, i32** %6
%163 = call i64 @feof(i32* %162)
%164 = icmp ne i64 %163, 0
br i1 %164, label %165, label %166
165: ; preds = %159
br label %187
166: ; preds = %159
%167 = getelementptr inbounds [3 x i8], [3 x i8]* %14, i64 0, i64 0
%168 = call i32 @memset(i8* %167, i32 0, i32 2)
%169 = load i32, i32* %12
%170 = icmp sge i32 %169, 16
br i1 %170, label %171, label %174
171: ; preds = %166
%172 = load i32*, i32** %7
%173 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.51, i64 0, i64 0), i32* %172)
store i32 0, i32* %12
br label %174
174: ; preds = %171, %166
%175 = load i32*, i32** %7
%176 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.53, i64 0, i64 0), i32* %175)
%177 = getelementptr inbounds [3 x i8], [3 x i8]* %14, i64 0, i64 0
%178 = load i8, i8* %13
%179 = call i32 @sprintf(i8* %177, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.54, i64 0, i64 0), i8 zeroext %178)
%180 = getelementptr inbounds [3 x i8], [3 x i8]* %14, i64 0, i64 0
%181 = load i32*, i32** %7
%182 = call i32 @fputs(i8* %180, i32* %181)
%183 = load i32*, i32** %7
%184 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.55, i64 0, i64 0), i32* %183)
%185 = load i32, i32* %12
%186 = add nsw i32 %185, 1
store i32 %186, i32* %12
br label %159
187: ; preds = %165
%188 = load i32*, i32** %7
%189 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.56, i64 0, i64 0), i32* %188)
%190 = load i32*, i32** %6
%191 = call i32 @fclose(i32* %190)
%192 = load i32*, i32** %7
%193 = call i32 @fclose(i32* %192)
%194 = call i32 @exit(i32 0)
unreachable
195: ; preds = %71, %63, %30, %25
%196 = load i32, i32* %3
ret i32 %196
}

LLVM IR (-O2):
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [8 x i8] c"CHIPSET\00"
@.str.4 = [5 x i8] c"2860\00"
@.str.5 = [19 x i8] c"/common/rt2860.bin\00"
@.str.6 = [5 x i8] c"2870\00"
@.str.7 = [19 x i8] c"/common/rt2870.bin\00"
@.str.8 = [20 x i8] c"/include/firmware.h\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [21 x i8] c"Can't read file %s \0A\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.13 = [4 x i8] c"/*\0A\00"
@.str.14 = [53 x i8] c" Copyright (c) 2007, Ralink Technology Corporation \0A\00"
@.str.15 = [25 x i8] c" All rights reserved. \0A\0A\00"
@.str.16 = [67 x i8] c" Redistribution. Redistribution and use in binary form, without \0A\00"
@.str.17 = [74 x i8] c" modification, are permitted provided that the following conditions are \0A\00"
@.str.18 = [9 x i8] c" met: \0A\0A\00"
@.str.19 = [72 x i8] c" \09* Redistributions must reproduce the above copyright notice and the \0A\00"
@.str.20 = [69 x i8] c" \09following disclaimer in the documentation and/or other materials \0A\00"
@.str.21 = [36 x i8] c" \09provided with the distribution. \0A\00"
@.str.22 = [77 x i8] c" \09* Neither the name of Ralink Technology Corporation nor the names of its \0A\00"
@.str.23 = [75 x i8] c" \09suppliers may be used to endorse or promote products derived from this \0A\00"
@.str.24 = [56 x i8] c" \09software without specific prior written permission. \0A\00"
@.str.25 = [77 x i8] c" \09* No reverse engineering, decompilation, or disassembly of this software \0A\00"
@.str.26 = [19 x i8] c" \09is permitted. \0A\0A\00"
@.str.27 = [78 x i8] c" Limited patent license. Ralink Technology Corporation grants a world-wide, \0A\00"
@.str.28 = [73 x i8] c" royalty-free, non-exclusive license under patents it now or hereafter \0A\00"
@.str.29 = [71 x i8] c" owns or controls to make, have made, use, import, offer to sell and \0A\00"
@.str.30 = [69 x i8] c" sell (\22Utilize\22) this software, but solely to the extent that any \0A\00"
@.str.31 = [65 x i8] c" such patent is necessary to Utilize the software alone, or in \0A\00"
@.str.32 = [72 x i8] c" combination with an operating system licensed under an approved Open \0A\00"
@.str.33 = [61 x i8] c" Source license as listed by the Open Source Initiative at \0A\00"
@.str.34 = [74 x i8] c" http://opensource.org/licenses. The patent license shall not apply to \0A\00"
@.str.35 = [72 x i8] c" any other combinations which include this software. No hardware per \0A\00"
@.str.36 = [30 x i8] c" se is licensed hereunder. \0A\0A\00"
@.str.37 = [71 x i8] c" DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \0A\00"
@.str.38 = [74 x i8] c" CONTRIBUTORS \22AS IS\22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, \0A\00"
@.str.39 = [69 x i8] c" BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \0A\00"
@.str.40 = [74 x i8] c" FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \0A\00"
@.str.41 = [71 x i8] c" COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \0A\00"
@.str.42 = [72 x i8] c" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \0A\00"
@.str.43 = [73 x i8] c" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS \0A\00"
@.str.44 = [74 x i8] c" OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND \0A\00"
@.str.45 = [73 x i8] c" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR \0A\00"
@.str.46 = [74 x i8] c" TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE \0A\00"
@.str.47 = [68 x i8] c" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH \0A\00"
@.str.48 = [11 x i8] c" DAMAGE. \0A\00"
@.str.49 = [5 x i8] c"*/ \0A\00"
@.str.50 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.52 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.53 = [3 x i8] c"0x\00"
@.str.54 = [5 x i8] c"%02x\00"
@.str.55 = [3 x i8] c", \00"
@.str.56 = [5 x i8] c"} ;\0A\00"
@str = [43 x i8] c"Environment value \22RT28xx_DIR\22 not export \00"
@str.57 = [40 x i8] c"Environment value \22CHIPSET\22 not export \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [3 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %6, i32 0, i32 1024)
%9 = call i32 @memset(i8* %7, i32 0, i32 1024)
%10 = call i64 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = inttoptr i64 %10 to i8*
%12 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = inttoptr i64 %12 to i8*
%14 = icmp eq i64 %10, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %112
17: ; preds = %2
%18 = icmp eq i64 %12, 0
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.57, i64 0, i64 0))
br label %112
21: ; preds = %17
%22 = call i32 @strcat(i8* %6, i8* %11)
%23 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 4)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0)
br label %29
29: ; preds = %25, %21
%30 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %21 ], [ %28, %25 ]
%31 = call i32 @strcat(i8* %6, i8* %30)
%32 = call i32 @strcat(i8* %7, i8* %11)
%33 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* %6)
br label %112
38: ; preds = %29
%39 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* %7)
br label %112
43: ; preds = %38
%44 = call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i64 3, i64 1, i32* %39)
%45 = call i64 @fwrite(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.14, i64 0, i64 0), i64 52, i64 1, i32* %39)
%46 = call i64 @fwrite(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), i64 24, i64 1, i32* %39)
%47 = call i64 @fwrite(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.16, i64 0, i64 0), i64 66, i64 1, i32* %39)
%48 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.17, i64 0, i64 0), i64 73, i64 1, i32* %39)
%49 = call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.18, i64 0, i64 0), i64 8, i64 1, i32* %39)
%50 = call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.19, i64 0, i64 0), i64 71, i64 1, i32* %39)
%51 = call i64 @fwrite(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.20, i64 0, i64 0), i64 68, i64 1, i32* %39)
%52 = call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.21, i64 0, i64 0), i64 35, i64 1, i32* %39)
%53 = call i64 @fwrite(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.22, i64 0, i64 0), i64 76, i64 1, i32* %39)
%54 = call i64 @fwrite(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.23, i64 0, i64 0), i64 74, i64 1, i32* %39)
%55 = call i64 @fwrite(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.24, i64 0, i64 0), i64 55, i64 1, i32* %39)
%56 = call i64 @fwrite(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.25, i64 0, i64 0), i64 76, i64 1, i32* %39)
%57 = call i64 @fwrite(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.26, i64 0, i64 0), i64 18, i64 1, i32* %39)
%58 = call i64 @fwrite(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.27, i64 0, i64 0), i64 77, i64 1, i32* %39)
%59 = call i64 @fwrite(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.28, i64 0, i64 0), i64 72, i64 1, i32* %39)
%60 = call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.29, i64 0, i64 0), i64 70, i64 1, i32* %39)
%61 = call i64 @fwrite(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.30, i64 0, i64 0), i64 68, i64 1, i32* %39)
%62 = call i64 @fwrite(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.31, i64 0, i64 0), i64 64, i64 1, i32* %39)
%63 = call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.32, i64 0, i64 0), i64 71, i64 1, i32* %39)
%64 = call i64 @fwrite(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.33, i64 0, i64 0), i64 60, i64 1, i32* %39)
%65 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.34, i64 0, i64 0), i64 73, i64 1, i32* %39)
%66 = call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.35, i64 0, i64 0), i64 71, i64 1, i32* %39)
%67 = call i64 @fwrite(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.36, i64 0, i64 0), i64 29, i64 1, i32* %39)
%68 = call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.37, i64 0, i64 0), i64 70, i64 1, i32* %39)
%69 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.38, i64 0, i64 0), i64 73, i64 1, i32* %39)
%70 = call i64 @fwrite(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.39, i64 0, i64 0), i64 68, i64 1, i32* %39)
%71 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.40, i64 0, i64 0), i64 73, i64 1, i32* %39)
%72 = call i64 @fwrite(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.41, i64 0, i64 0), i64 70, i64 1, i32* %39)
%73 = call i64 @fwrite(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.42, i64 0, i64 0), i64 71, i64 1, i32* %39)
%74 = call i64 @fwrite(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.43, i64 0, i64 0), i64 72, i64 1, i32* %39)
%75 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.44, i64 0, i64 0), i64 73, i64 1, i32* %39)
%76 = call i64 @fwrite(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.45, i64 0, i64 0), i64 72, i64 1, i32* %39)
%77 = call i64 @fwrite(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.46, i64 0, i64 0), i64 73, i64 1, i32* %39)
%78 = call i64 @fwrite(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.47, i64 0, i64 0), i64 67, i64 1, i32* %39)
%79 = call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.48, i64 0, i64 0), i64 10, i64 1, i32* %39)
%80 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.49, i64 0, i64 0), i64 4, i64 1, i32* %39)
%81 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.50, i64 0, i64 0), i64 40, i64 1, i32* %39)
%82 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.50, i64 0, i64 0), i64 40, i64 1, i32* %39)
%83 = call i32 @fputc(i32 10, i32* %39)
%84 = call i32 @fputc(i32 10, i32* %39)
%85 = call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.52, i64 0, i64 0), i64 28, i64 1, i32* %39)
%86 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%87 = call zeroext i8 @getc(i32* %34)
%88 = call i64 @feof(i32* %34)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %107
90: ; preds = %43, %97
%91 = phi i8 [ %104, %97 ], [ %87, %43 ]
%92 = phi i32 [ %103, %97 ], [ 0, %43 ]
%93 = call i32 @memset(i8* %86, i32 0, i32 2)
%94 = icmp sgt i32 %92, 15
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 @fputc(i32 10, i32* %39)
br label %97
97: ; preds = %90, %95
%98 = phi i32 [ 0, %95 ], [ %92, %90 ]
%99 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.53, i64 0, i64 0), i64 2, i64 1, i32* %39)
%100 = call i32 @sprintf(i8* %86, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.54, i64 0, i64 0), i8 zeroext %91)
%101 = call i32 @fputs(i8* %86, i32* %39)
%102 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.55, i64 0, i64 0), i64 2, i64 1, i32* %39)
%103 = add nsw i32 %98, 1
%104 = call zeroext i8 @getc(i32* %34)
%105 = call i64 @feof(i32* %34)
%106 = icmp eq i64 %105, 0
br i1 %106, label %90, label %107
107: ; preds = %97, %43
%108 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.56, i64 0, i64 0), i64 4, i64 1, i32* %39)
%109 = call i32 @fclose(i32* %34)
%110 = call i32 @fclose(i32* %39)
%111 = call i32 @exit(i32 0)
unreachable
112: ; preds = %41, %36, %19, %15
ret i32 -1
}