#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*/ infname;
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*/ fprintf(int /*<<< orphan*/, 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*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *strstr(char *, char *);
int main(int argc, char *argv[]) {
  FILE *infile, *outfile;
  char infname[1024];
  char outfname[1024];
  char *rt28xxdir;
  char *chipset;
  char *sw_ch_offload;
  char *wow, *rt28xx_mode;
  int i = 0;
  unsigned char c;
  memset(infname, 0, 1024);
  memset(outfname, 0, 1024);
  rt28xxdir = (char *)getenv("RT28xx_DIR");
  chipset = (char *)getenv("CHIPSET");
  wow = (char *)getenv("HAS_WOW_SUPPORT");
  rt28xx_mode = (char *)getenv("RT28xx_MODE");
  sw_ch_offload = (char *)getenv("HAS_SWITCH_CHANNEL_OFFLOAD");
  if (!rt28xxdir) {
    printf("Environment value \"RT28xx_DIR\" not export \n");
    return -1;
  }
  if (!chipset) {
    printf("Environment value \"CHIPSET\" not export \n");
    return -1;
  }
  if (strlen(rt28xxdir) > (sizeof(infname) - 100)) {
    printf("Environment value \"RT28xx_DIR\" is too long!\n");
    return -1;
  }
  if (!sw_ch_offload) {
    printf("Do not export HAS_SWITCH_CHANNEL_OFFLOAD environment\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 if (strncmp(chipset, "3090", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "2070", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3070", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3572", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3573", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "3370", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "5370", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "5572", 4) == 0) {
    if (strncmp(sw_ch_offload, "y", 1) == 0) {
      printf("xxxxx\n");
      strcat(infname, "/common/rt2870_sw_ch_offload.bin");
    } else
      strcat(infname, "/common/rt2870.bin");
  } else if (strncmp(chipset, "5592", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "USB", 3) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "PCI", 3) == 0)
    strcat(infname, "/common/rt2860.bin");
  else
    strcat(infname, "/common/rt2860.bin");
  if ((wow != NULL) && (strncmp(wow, "y", 1) == 0) &&
      (strncmp(rt28xx_mode, "STA", 3) == 0)) {
    if ((wow = strstr(infname, "rt2870")) != NULL) {
      strcpy(wow, "rt2870_wow.bin");
      fprintf(stderr, "infname %s\n", infname);
    }
  }
  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("/* 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    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84c(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10a0 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10a0 <memset@plt>
lea    0xdb0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x828(%rbp)
lea    0xda8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x830(%rbp)
lea    0xd9d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x840(%rbp)
lea    0xd9a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x848(%rbp)
lea    0xd93(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x838(%rbp)
cmpq   $0x0,-0x828(%rbp)
jne    12d0 <main+0xd0>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
cmpq   $0x0,-0x830(%rbp)
jne    12f8 <main+0xf8>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
mov    -0x828(%rbp),%rdi
call   1070 <strlen@plt>
cltq
cmp    $0x39c,%rax
jbe    132c <main+0x12c>
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
cmpq   $0x0,-0x838(%rbp)
jne    1354 <main+0x154>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
lea    -0x420(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x830(%rbp),%rdi
lea    0xd8d(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13a1 <main+0x1a1>
lea    -0x420(%rbp),%rdi
lea    0xd70(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16f0 <main+0x4f0>
mov    -0x830(%rbp),%rdi
lea    0xde3(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13db <main+0x1db>
lea    -0x420(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16eb <main+0x4eb>
mov    -0x830(%rbp),%rdi
lea    0xd44(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1415 <main+0x215>
lea    -0x420(%rbp),%rdi
lea    0xcfc(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16e6 <main+0x4e6>
mov    -0x830(%rbp),%rdi
lea    0xd0f(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    144f <main+0x24f>
lea    -0x420(%rbp),%rdi
lea    0xcd5(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16e1 <main+0x4e1>
mov    -0x830(%rbp),%rdi
lea    0xcda(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1489 <main+0x289>
lea    -0x420(%rbp),%rdi
lea    0xc9b(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16dc <main+0x4dc>
mov    -0x830(%rbp),%rdi
lea    0xca5(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    14c3 <main+0x2c3>
lea    -0x420(%rbp),%rdi
lea    0xc61(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16d7 <main+0x4d7>
mov    -0x830(%rbp),%rdi
lea    0xc70(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    14fd <main+0x2fd>
lea    -0x420(%rbp),%rdi
lea    0xc27(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16d2 <main+0x4d2>
mov    -0x830(%rbp),%rdi
lea    0xc3b(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1537 <main+0x337>
lea    -0x420(%rbp),%rdi
lea    0xbed(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16cd <main+0x4cd>
mov    -0x830(%rbp),%rdi
lea    0xc06(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1571 <main+0x371>
lea    -0x420(%rbp),%rdi
lea    0xbb3(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16c8 <main+0x4c8>
mov    -0x830(%rbp),%rdi
lea    0xbd1(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    15f3 <main+0x3f3>
mov    -0x838(%rbp),%rdi
lea    0xbb4(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    15db <main+0x3db>
lea    0xb9b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x420(%rbp),%rdi
lea    0xb8d(%rip),%rsi
call   10e0 <strcat@plt>
jmp    15ee <main+0x3ee>
lea    -0x420(%rbp),%rdi
lea    0xb31(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16c3 <main+0x4c3>
mov    -0x830(%rbp),%rdi
lea    0xb7e(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    162d <main+0x42d>
lea    -0x420(%rbp),%rdi
lea    0xae4(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16be <main+0x4be>
mov    -0x830(%rbp),%rdi
lea    0xb49(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1667 <main+0x467>
lea    -0x420(%rbp),%rdi
lea    0xabd(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16b9 <main+0x4b9>
mov    -0x830(%rbp),%rdi
lea    0xb13(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    16a1 <main+0x4a1>
lea    -0x420(%rbp),%rdi
lea    0xa70(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16b4 <main+0x4b4>
lea    -0x420(%rbp),%rdi
lea    0xa58(%rip),%rsi
call   10e0 <strcat@plt>
jmp    16b9 <main+0x4b9>
jmp    16be <main+0x4be>
jmp    16c3 <main+0x4c3>
jmp    16c8 <main+0x4c8>
jmp    16cd <main+0x4cd>
jmp    16d2 <main+0x4d2>
jmp    16d7 <main+0x4d7>
jmp    16dc <main+0x4dc>
jmp    16e1 <main+0x4e1>
jmp    16e6 <main+0x4e6>
jmp    16eb <main+0x4eb>
jmp    16f0 <main+0x4f0>
cmpq   $0x0,-0x840(%rbp)
je     179a <main+0x59a>
mov    -0x840(%rbp),%rdi
lea    0xa49(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    179a <main+0x59a>
mov    -0x848(%rbp),%rdi
lea    0xa5e(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    179a <main+0x59a>
lea    -0x420(%rbp),%rdi
lea    0xa40(%rip),%rsi
call   1120 <strstr@plt>
mov    %rax,-0x840(%rbp)
cmp    $0x0,%rax
je     1795 <main+0x595>
mov    -0x840(%rbp),%rdi
lea    0xa23(%rip),%rsi
call   1050 <strcpy@plt>
mov    0x2860(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    0xa16(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    179a <main+0x59a>
lea    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   10e0 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    0x9f7(%rip),%rsi
call   10e0 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0x9f8(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1803 <main+0x603>
lea    -0x420(%rbp),%rsi
lea    0x9d8(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
lea    -0x820(%rbp),%rdi
lea    0x9cc(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1846 <main+0x646>
lea    -0x820(%rbp),%rsi
lea    0x9ac(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    197e <main+0x77e>
mov    -0x20(%rbp),%rsi
lea    0x9a9(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x999(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x9b0(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x9a0(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x992(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1110 <getc@plt>
mov    %al,-0x84d(%rbp)
mov    -0x18(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%rax
je     18bd <main+0x6bd>
jmp    1955 <main+0x755>
lea    -0x850(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10a0 <memset@plt>
cmpl   $0x10,-0x84c(%rbp)
jl     18f7 <main+0x6f7>
mov    -0x20(%rbp),%rsi
lea    0x939(%rip),%rdi
call   1090 <fputs@plt>
movl   $0x0,-0x84c(%rbp)
mov    -0x20(%rbp),%rsi
lea    0x93e(%rip),%rdi
call   1090 <fputs@plt>
lea    -0x850(%rbp),%rdi
lea    0x92e(%rip),%rsi
movzbl -0x84d(%rbp),%edx
call   10f0 <sprintf@plt>
lea    -0x850(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0x90c(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x84c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84c(%rbp)
jmp    1896 <main+0x696>
mov    -0x20(%rbp),%rsi
lea    0x8eb(%rip),%rdi
call   1090 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   1100 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x850,%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    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
lea    0x410(%rsp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
lea    0xd93(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r12
lea    0xd8f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xd88(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
lea    0xd89(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
lea    0xd86(%rip),%rdi
call   1030 <getenv@plt>
test   %r12,%r12
je     12d6 <main+0xa6>
test   %rbx,%rbx
je     12e2 <main+0xb2>
mov    %rax,%rbp
mov    %r12,%rdi
call   1080 <strlen@plt>
cmp    $0x39d,%eax
jb     12ee <main+0xbe>
lea    0xf4e(%rip),%rdi
jmp    156c <main+0x33c>
lea    0xeb4(%rip),%rdi
jmp    156c <main+0x33c>
lea    0xed3(%rip),%rdi
jmp    156c <main+0x33c>
test   %rbp,%rbp
je     1565 <main+0x335>
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1100 <strcat@plt>
lea    0xd3f(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
lea    0xd30(%rip),%r13
test   %rax,%rax
je     147d <main+0x24d>
lea    0xda4(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
lea    0xd1f(%rip),%r13
test   %rax,%rax
je     147d <main+0x24d>
lea    0xd22(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1476 <main+0x246>
lea    0xd0a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xcf2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xcda(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xcc2(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xcaa(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xc92(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xc7e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     159d <main+0x36d>
lea    0xc89(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1476 <main+0x246>
lea    0xc75(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     147d <main+0x24d>
lea    0xc60(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
lea    0xbd2(%rip),%r13
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
call   1100 <strcat@plt>
test   %r15,%r15
je     1500 <main+0x2d0>
lea    0xc07(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1500 <main+0x2d0>
lea    0xc1e(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1500 <main+0x2d0>
lea    0xc09(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1150 <strstr@plt>
test   %rax,%rax
je     1500 <main+0x2d0>
lea    0xbfa(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
lea    0xbf1(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10d0 <fprintf@plt>
lea    0x410(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1100 <strcat@plt>
lea    0xbd9(%rip),%rsi
mov    %rbx,%rdi
call   1100 <strcat@plt>
lea    0xbde(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1588 <main+0x358>
mov    %rax,%rbx
lea    0xbdc(%rip),%rsi
lea    0x410(%rsp),%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
jne    15d2 <main+0x3a2>
lea    0xbc5(%rip),%rdi
lea    0x410(%rsp),%rsi
jmp    1594 <main+0x364>
lea    0xc78(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%eax
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb7a(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1571 <main+0x341>
lea    0xaf9(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    147d <main+0x24d>
lea    0xc58(%rip),%rdi
call   1060 <puts@plt>
lea    0xad2(%rip),%r13
jmp    147d <main+0x24d>
mov    %rax,%rbp
lea    0xb5f(%rip),%r14
mov    $0x28,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rax,%rcx
call   1130 <fwrite@plt>
mov    $0x28,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbp,%rcx
call   1130 <fwrite@plt>
mov    $0xa,%edi
mov    %rbp,%rsi
call   10c0 <fputc@plt>
mov    $0xa,%edi
mov    %rbp,%rsi
call   10c0 <fputc@plt>
lea    0xb3d(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1130 <fwrite@plt>
mov    %rbx,%rdi
call   1140 <getc@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   10e0 <feof@plt>
test   %rax,%rax
jne    16f8 <main+0x4c8>
xor    %r12d,%r12d
lea    0xd(%rsp),%r14
lea    0xb25(%rip),%r13
jmp    16ce <main+0x49e>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xb0a(%rip),%rdi
mov    %rbp,%rcx
call   1130 <fwrite@plt>
movzbl %r15b,%edx
mov    %r14,%rdi
lea    0xaf7(%rip),%rsi
call   1110 <sprintf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <fputs@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %rbp,%rcx
call   1130 <fwrite@plt>
add    $0x1,%r12d
mov    %rbx,%rdi
call   1140 <getc@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   10e0 <feof@plt>
test   %rax,%rax
jne    16f8 <main+0x4c8>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10b0 <memset@plt>
cmp    $0x10,%r12d
jl     1666 <main+0x436>
mov    $0xa,%edi
mov    %rbp,%rsi
call   10c0 <fputc@plt>
xor    %r12d,%r12d
jmp    1666 <main+0x436>
lea    0xa8d(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1130 <fwrite@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    %rbp,%rdi
call   1070 <fclose@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [8 x i8] c"CHIPSET\00"
@.str.2 = [16 x i8] c"HAS_WOW_SUPPORT\00"
@.str.3 = [12 x i8] c"RT28xx_MODE\00"
@.str.4 = [27 x i8] c"HAS_SWITCH_CHANNEL_OFFLOAD\00"
@.str.5 = [44 x i8] c"Environment value \22RT28xx_DIR\22 not export \0A\00"
@.str.6 = [41 x i8] c"Environment value \22CHIPSET\22 not export \0A\00"
@.str.7 = [45 x i8] c"Environment value \22RT28xx_DIR\22 is too long!\0A\00"
@.str.8 = [54 x i8] c"Do not export HAS_SWITCH_CHANNEL_OFFLOAD environment\0A\00"
@.str.9 = [5 x i8] c"2860\00"
@.str.10 = [19 x i8] c"/common/rt2860.bin\00"
@.str.11 = [5 x i8] c"2870\00"
@.str.12 = [19 x i8] c"/common/rt2870.bin\00"
@.str.13 = [5 x i8] c"3090\00"
@.str.14 = [5 x i8] c"2070\00"
@.str.15 = [5 x i8] c"3070\00"
@.str.16 = [5 x i8] c"3572\00"
@.str.17 = [5 x i8] c"3573\00"
@.str.18 = [5 x i8] c"3370\00"
@.str.19 = [5 x i8] c"5370\00"
@.str.20 = [5 x i8] c"5572\00"
@.str.21 = [2 x i8] c"y\00"
@.str.22 = [7 x i8] c"xxxxx\0A\00"
@.str.23 = [33 x i8] c"/common/rt2870_sw_ch_offload.bin\00"
@.str.24 = [5 x i8] c"5592\00"
@.str.25 = [4 x i8] c"USB\00"
@.str.26 = [4 x i8] c"PCI\00"
@.str.27 = [4 x i8] c"STA\00"
@.str.28 = [7 x i8] c"rt2870\00"
@.str.29 = [15 x i8] c"rt2870_wow.bin\00"
@stderr = global i32 0
@.str.30 = [12 x i8] c"infname %s\0A\00"
@.str.31 = [20 x i8] c"/include/firmware.h\00"
@.str.32 = [2 x i8] c"r\00"
@.str.33 = [21 x i8] c"Can't read file %s \0A\00"
@.str.34 = [2 x i8] c"w\00"
@.str.35 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.36 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.37 = [2 x i8] c"\0A\00"
@.str.38 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.39 = [3 x i8] c"0x\00"
@.str.40 = [5 x i8] c"%02x\00"
@.str.41 = [3 x i8] c", \00"
@.str.42 = [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 i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i8
%17 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %15
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 1024)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%21 = call i32 @memset(i8* %20, i32 0, i32 1024)
%22 = call i64 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %10
%24 = call i64 @getenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %11
%26 = call i64 @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %13
%28 = call i64 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%29 = inttoptr i64 %28 to i8*
store i8* %29, i8** %14
%30 = call i64 @getenv(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%31 = inttoptr i64 %30 to i8*
store i8* %31, i8** %12
%32 = load i8*, i8** %10
%33 = icmp ne i8* %32, null
br i1 %33, label %36, label %34
34: ; preds = %2
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %261
36: ; preds = %2
%37 = load i8*, i8** %11
%38 = icmp ne i8* %37, null
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %261
41: ; preds = %36
%42 = load i8*, i8** %10
%43 = call i32 @strlen(i8* %42)
%44 = sext i32 %43 to i64
%45 = icmp ugt i64 %44, 924
br i1 %45, label %46, label %48
46: ; preds = %41
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %261
48: ; preds = %41
%49 = load i8*, i8** %12
%50 = icmp ne i8* %49, null
br i1 %50, label %53, label %51
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %261
53: ; preds = %48
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%55 = load i8*, i8** %10
%56 = call i32 @strcat(i8* %54, i8* %55)
%57 = load i8*, i8** %11
%58 = call i64 @strncmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %171
63: ; preds = %53
%64 = load i8*, i8** %11
%65 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 4)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%69 = call i32 @strcat(i8* %68, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %170
70: ; preds = %63
%71 = load i8*, i8** %11
%72 = call i64 @strncmp(i8* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%76 = call i32 @strcat(i8* %75, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %169
77: ; preds = %70
%78 = load i8*, i8** %11
%79 = call i64 @strncmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%83 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %168
84: ; preds = %77
%85 = load i8*, i8** %11
%86 = call i64 @strncmp(i8* %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 4)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%90 = call i32 @strcat(i8* %89, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %167
91: ; preds = %84
%92 = load i8*, i8** %11
%93 = call i64 @strncmp(i8* %92, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i32 4)
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %91
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%97 = call i32 @strcat(i8* %96, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %166
98: ; preds = %91
%99 = load i8*, i8** %11
%100 = call i64 @strncmp(i8* %99, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i32 4)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%104 = call i32 @strcat(i8* %103, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %165
105: ; preds = %98
%106 = load i8*, i8** %11
%107 = call i64 @strncmp(i8* %106, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 4)
%108 = icmp eq i64 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %105
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%111 = call i32 @strcat(i8* %110, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %164
112: ; preds = %105
%113 = load i8*, i8** %11
%114 = call i64 @strncmp(i8* %113, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 4)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %112
%117 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%118 = call i32 @strcat(i8* %117, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %163
119: ; preds = %112
%120 = load i8*, i8** %11
%121 = call i64 @strncmp(i8* %120, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %135
123: ; preds = %119
%124 = load i8*, i8** %12
%125 = call i64 @strncmp(i8* %124, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32 1)
%126 = icmp eq i64 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %123
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i64 0, i64 0))
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%130 = call i32 @strcat(i8* %129, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.23, i64 0, i64 0))
br label %134
131: ; preds = %123
%132 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%133 = call i32 @strcat(i8* %132, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %134
134: ; preds = %131, %127
br label %162
135: ; preds = %119
%136 = load i8*, i8** %11
%137 = call i64 @strncmp(i8* %136, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i64 0, i64 0), i32 4)
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %142
139: ; preds = %135
%140 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%141 = call i32 @strcat(i8* %140, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %161
142: ; preds = %135
%143 = load i8*, i8** %11
%144 = call i64 @strncmp(i8* %143, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0), i32 3)
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %142
%147 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%148 = call i32 @strcat(i8* %147, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
br label %160
149: ; preds = %142
%150 = load i8*, i8** %11
%151 = call i64 @strncmp(i8* %150, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i64 0, i64 0), i32 3)
%152 = icmp eq i64 %151, 0
br i1 %152, label %153, label %156
153: ; preds = %149
%154 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%155 = call i32 @strcat(i8* %154, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %159
156: ; preds = %149
%157 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%158 = call i32 @strcat(i8* %157, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
br label %159
159: ; preds = %156, %153
br label %160
160: ; preds = %159, %146
br label %161
161: ; preds = %160, %139
br label %162
162: ; preds = %161, %134
br label %163
163: ; preds = %162, %116
br label %164
164: ; preds = %163, %109
br label %165
165: ; preds = %164, %102
br label %166
166: ; preds = %165, %95
br label %167
167: ; preds = %166, %88
br label %168
168: ; preds = %167, %81
br label %169
169: ; preds = %168, %74
br label %170
170: ; preds = %169, %67
br label %171
171: ; preds = %170, %60
%172 = load i8*, i8** %13
%173 = icmp ne i8* %172, null
br i1 %173, label %174, label %193
174: ; preds = %171
%175 = load i8*, i8** %13
%176 = call i64 @strncmp(i8* %175, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32 1)
%177 = icmp eq i64 %176, 0
br i1 %177, label %178, label %193
178: ; preds = %174
%179 = load i8*, i8** %14
%180 = call i64 @strncmp(i8* %179, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0), i32 3)
%181 = icmp eq i64 %180, 0
br i1 %181, label %182, label %193
182: ; preds = %178
%183 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%184 = call i8* @strstr(i8* %183, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i64 0, i64 0))
store i8* %184, i8** %13
%185 = icmp ne i8* %184, null
br i1 %185, label %186, label %192
186: ; preds = %182
%187 = load i8*, i8** %13
%188 = call i32 @strcpy(i8* %187, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.29, i64 0, i64 0))
%189 = load i32, i32* @stderr
%190 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%191 = call i32 @fprintf(i32 %189, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.30, i64 0, i64 0), i8* %190)
br label %192
192: ; preds = %186, %182
br label %193
193: ; preds = %192, %178, %174, %171
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%195 = load i8*, i8** %10
%196 = call i32 @strcat(i8* %194, i8* %195)
%197 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%198 = call i32 @strcat(i8* %197, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.31, i64 0, i64 0))
%199 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%200 = call i32* @fopen(i8* %199, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.32, i64 0, i64 0))
store i32* %200, i32** %6
%201 = load i32*, i32** %6
%202 = icmp eq i32* %201, null
br i1 %202, label %203, label %206
203: ; preds = %193
%204 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.33, i64 0, i64 0), i8* %204)
store i32 -1, i32* %3
br label %261
206: ; preds = %193
%207 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%208 = call i32* @fopen(i8* %207, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.34, i64 0, i64 0))
store i32* %208, i32** %7
%209 = load i32*, i32** %7
%210 = icmp eq i32* %209, null
br i1 %210, label %211, label %214
211: ; preds = %206
%212 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0), i8* %212)
store i32 -1, i32* %3
br label %261
214: ; preds = %206
%215 = load i32*, i32** %7
%216 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0), i32* %215)
%217 = load i32*, i32** %7
%218 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0), i32* %217)
%219 = load i32*, i32** %7
%220 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.37, i64 0, i64 0), i32* %219)
%221 = load i32*, i32** %7
%222 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.37, i64 0, i64 0), i32* %221)
%223 = load i32*, i32** %7
%224 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.38, i64 0, i64 0), i32* %223)
br label %225
225: ; preds = %214, %240
%226 = load i32*, i32** %6
%227 = call zeroext i8 @getc(i32* %226)
store i8 %227, i8* %16
%228 = load i32*, i32** %6
%229 = call i64 @feof(i32* %228)
%230 = icmp ne i64 %229, 0
br i1 %230, label %231, label %232
231: ; preds = %225
br label %253
232: ; preds = %225
%233 = getelementptr inbounds [3 x i8], [3 x i8]* %17, i64 0, i64 0
%234 = call i32 @memset(i8* %233, i32 0, i32 2)
%235 = load i32, i32* %15
%236 = icmp sge i32 %235, 16
br i1 %236, label %237, label %240
237: ; preds = %232
%238 = load i32*, i32** %7
%239 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.37, i64 0, i64 0), i32* %238)
store i32 0, i32* %15
br label %240
240: ; preds = %237, %232
%241 = load i32*, i32** %7
%242 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.39, i64 0, i64 0), i32* %241)
%243 = getelementptr inbounds [3 x i8], [3 x i8]* %17, i64 0, i64 0
%244 = load i8, i8* %16
%245 = call i32 @sprintf(i8* %243, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.40, i64 0, i64 0), i8 zeroext %244)
%246 = getelementptr inbounds [3 x i8], [3 x i8]* %17, i64 0, i64 0
%247 = load i32*, i32** %7
%248 = call i32 @fputs(i8* %246, i32* %247)
%249 = load i32*, i32** %7
%250 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.41, i64 0, i64 0), i32* %249)
%251 = load i32, i32* %15
%252 = add nsw i32 %251, 1
store i32 %252, i32* %15
br label %225
253: ; preds = %231
%254 = load i32*, i32** %7
%255 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.42, i64 0, i64 0), i32* %254)
%256 = load i32*, i32** %6
%257 = call i32 @fclose(i32* %256)
%258 = load i32*, i32** %7
%259 = call i32 @fclose(i32* %258)
%260 = call i32 @exit(i32 0)
unreachable
261: ; preds = %211, %203, %51, %46, %39, %34
%262 = load i32, i32* %3
ret i32 %262
}

LLVM IR (-O2):
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [8 x i8] c"CHIPSET\00"
@.str.2 = [16 x i8] c"HAS_WOW_SUPPORT\00"
@.str.3 = [12 x i8] c"RT28xx_MODE\00"
@.str.4 = [27 x i8] c"HAS_SWITCH_CHANNEL_OFFLOAD\00"
@.str.9 = [5 x i8] c"2860\00"
@.str.10 = [19 x i8] c"/common/rt2860.bin\00"
@.str.11 = [5 x i8] c"2870\00"
@.str.12 = [19 x i8] c"/common/rt2870.bin\00"
@.str.13 = [5 x i8] c"3090\00"
@.str.14 = [5 x i8] c"2070\00"
@.str.15 = [5 x i8] c"3070\00"
@.str.16 = [5 x i8] c"3572\00"
@.str.17 = [5 x i8] c"3573\00"
@.str.18 = [5 x i8] c"3370\00"
@.str.19 = [5 x i8] c"5370\00"
@.str.20 = [5 x i8] c"5572\00"
@.str.21 = [2 x i8] c"y\00"
@.str.23 = [33 x i8] c"/common/rt2870_sw_ch_offload.bin\00"
@.str.24 = [5 x i8] c"5592\00"
@.str.25 = [4 x i8] c"USB\00"
@.str.26 = [4 x i8] c"PCI\00"
@.str.27 = [4 x i8] c"STA\00"
@.str.28 = [7 x i8] c"rt2870\00"
@.str.29 = [15 x i8] c"rt2870_wow.bin\00"
@stderr = global i32 0
@.str.30 = [12 x i8] c"infname %s\0A\00"
@.str.31 = [20 x i8] c"/include/firmware.h\00"
@.str.32 = [2 x i8] c"r\00"
@.str.33 = [21 x i8] c"Can't read file %s \0A\00"
@.str.34 = [2 x i8] c"w\00"
@.str.35 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.36 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.38 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.39 = [3 x i8] c"0x\00"
@.str.40 = [5 x i8] c"%02x\00"
@.str.41 = [3 x i8] c", \00"
@.str.42 = [5 x i8] c"} ;\0A\00"
@str = [43 x i8] c"Environment value \22RT28xx_DIR\22 not export \00"
@str.43 = [40 x i8] c"Environment value \22CHIPSET\22 not export \00"
@str.44 = [53 x i8] c"Do not export HAS_SWITCH_CHANNEL_OFFLOAD environment\00"
@str.45 = [6 x i8] c"xxxxx\00"
@str.46 = [44 x i8] c"Environment value \22RT28xx_DIR\22 is too long!\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 = call i64 @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%15 = inttoptr i64 %14 to i8*
%16 = call i64 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%17 = inttoptr i64 %16 to i8*
%18 = call i64 @getenv(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%19 = inttoptr i64 %18 to i8*
%20 = icmp eq i64 %10, 0
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %141
23: ; preds = %2
%24 = icmp eq i64 %12, 0
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.43, i64 0, i64 0))
br label %141
27: ; preds = %23
%28 = call i32 @strlen(i8* %11)
%29 = icmp ugt i32 %28, 924
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.46, i64 0, i64 0))
br label %141
32: ; preds = %27
%33 = icmp eq i64 %18, 0
br i1 %33, label %34, label %36
34: ; preds = %32
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.44, i64 0, i64 0))
br label %141
36: ; preds = %32
%37 = call i32 @strcat(i8* %6, i8* %11)
%38 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%39 = icmp eq i64 %38, 0
br i1 %39, label %80, label %40
40: ; preds = %36
%41 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 4)
%42 = icmp eq i64 %41, 0
br i1 %42, label %80, label %43
43: ; preds = %40
%44 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 4)
%45 = icmp eq i64 %44, 0
br i1 %45, label %80, label %46
46: ; preds = %43
%47 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%48 = icmp eq i64 %47, 0
br i1 %48, label %80, label %49
49: ; preds = %46
%50 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i64 0, i64 0), i32 4)
%51 = icmp eq i64 %50, 0
br i1 %51, label %80, label %52
52: ; preds = %49
%53 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i32 4)
%54 = icmp eq i64 %53, 0
br i1 %54, label %80, label %55
55: ; preds = %52
%56 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i32 4)
%57 = icmp eq i64 %56, 0
br i1 %57, label %80, label %58
58: ; preds = %55
%59 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 4)
%60 = icmp eq i64 %59, 0
br i1 %60, label %80, label %61
61: ; preds = %58
%62 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 4)
%63 = icmp eq i64 %62, 0
br i1 %63, label %80, label %64
64: ; preds = %61
%65 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %64
%68 = call i64 @strncmp(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32 1)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %80
70: ; preds = %67
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.45, i64 0, i64 0))
br label %80
72: ; preds = %64
%73 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i64 0, i64 0), i32 4)
%74 = icmp eq i64 %73, 0
br i1 %74, label %80, label %75
75: ; preds = %72
%76 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0), i32 3)
%77 = icmp eq i64 %76, 0
br i1 %77, label %80, label %78
78: ; preds = %75
%79 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.26, i64 0, i64 0), i32 3)
br label %80
80: ; preds = %75, %72, %67, %61, %58, %55, %52, %49, %46, %43, %40, %36, %78, %70
%81 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), %78 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.23, i64 0, i64 0), %70 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), %36 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %40 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), %43 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %46 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %49 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %52 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %55 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %58 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %61 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %67 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), %72 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %75 ]
%82 = call i32 @strcat(i8* %6, i8* %81)
%83 = icmp eq i64 %14, 0
br i1 %83, label %97, label %84
84: ; preds = %80
%85 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32 1)
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %97
87: ; preds = %84
%88 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.27, i64 0, i64 0), i32 3)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %97
90: ; preds = %87
%91 = call i8* @strstr(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.28, i64 0, i64 0))
%92 = icmp eq i8* %91, null
br i1 %92, label %97, label %93
93: ; preds = %90
%94 = call i32 @strcpy(i8* %91, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.29, i64 0, i64 0))
%95 = load i32, i32* @stderr
%96 = call i32 @fprintf(i32 %95, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.30, i64 0, i64 0), i8* %6)
br label %97
97: ; preds = %90, %93, %87, %84, %80
%98 = call i32 @strcat(i8* %7, i8* %11)
%99 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.31, i64 0, i64 0))
%100 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.32, i64 0, i64 0))
%101 = icmp eq i32* %100, null
br i1 %101, label %102, label %104
102: ; preds = %97
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.33, i64 0, i64 0), i8* %6)
br label %141
104: ; preds = %97
%105 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.34, i64 0, i64 0))
%106 = icmp eq i32* %105, null
br i1 %106, label %107, label %109
107: ; preds = %104
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.35, i64 0, i64 0), i8* %7)
br label %141
109: ; preds = %104
%110 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0), i64 40, i64 1, i32* %105)
%111 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.36, i64 0, i64 0), i64 40, i64 1, i32* %105)
%112 = call i32 @fputc(i32 10, i32* %105)
%113 = call i32 @fputc(i32 10, i32* %105)
%114 = call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.38, i64 0, i64 0), i64 28, i64 1, i32* %105)
%115 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%116 = call zeroext i8 @getc(i32* %100)
%117 = call i64 @feof(i32* %100)
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %136
119: ; preds = %109, %126
%120 = phi i8 [ %133, %126 ], [ %116, %109 ]
%121 = phi i32 [ %132, %126 ], [ 0, %109 ]
%122 = call i32 @memset(i8* %115, i32 0, i32 2)
%123 = icmp sgt i32 %121, 15
br i1 %123, label %124, label %126
124: ; preds = %119
%125 = call i32 @fputc(i32 10, i32* %105)
br label %126
126: ; preds = %119, %124
%127 = phi i32 [ 0, %124 ], [ %121, %119 ]
%128 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.39, i64 0, i64 0), i64 2, i64 1, i32* %105)
%129 = call i32 @sprintf(i8* %115, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.40, i64 0, i64 0), i8 zeroext %120)
%130 = call i32 @fputs(i8* %115, i32* %105)
%131 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.41, i64 0, i64 0), i64 2, i64 1, i32* %105)
%132 = add nsw i32 %127, 1
%133 = call zeroext i8 @getc(i32* %100)
%134 = call i64 @feof(i32* %100)
%135 = icmp eq i64 %134, 0
br i1 %135, label %119, label %136
136: ; preds = %126, %109
%137 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.42, i64 0, i64 0), i64 4, i64 1, i32* %105)
%138 = call i32 @fclose(i32* %100)
%139 = call i32 @fclose(i32* %105)
%140 = call i32 @exit(i32 0)
unreachable
141: ; preds = %107, %102, %34, %30, %25, %21
ret i32 -1
}