#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 if (strncmp(chipset, "3090", 4) == 0)
    strcat(infname, "/common/rt2860.bin");
  else if (strncmp(chipset, "3390", 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, "3370", 4) == 0)
    strcat(infname, "/common/rt2870.bin");
  else if (strncmp(chipset, "USB_COMBO", 9) == 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("/* 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[2];
    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    16bb <main+0x4fb>
cmpq   $0x0,-0x830(%rbp)
jne    127f <main+0xbf>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16bb <main+0x4fb>
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    14d7 <main+0x317>
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    14d2 <main+0x312>
mov    -0x830(%rbp),%rdi
lea    0xd84(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1340 <main+0x180>
lea    -0x420(%rbp),%rdi
lea    0xd37(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14cd <main+0x30d>
mov    -0x830(%rbp),%rdi
lea    0xd4f(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    137a <main+0x1ba>
lea    -0x420(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14c8 <main+0x308>
mov    -0x830(%rbp),%rdi
lea    0xd1a(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13b4 <main+0x1f4>
lea    -0x420(%rbp),%rdi
lea    0xcdb(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14c3 <main+0x303>
mov    -0x830(%rbp),%rdi
lea    0xce5(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    13ee <main+0x22e>
lea    -0x420(%rbp),%rdi
lea    0xca1(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14be <main+0x2fe>
mov    -0x830(%rbp),%rdi
lea    0xcb0(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1428 <main+0x268>
lea    -0x420(%rbp),%rdi
lea    0xc67(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14b9 <main+0x2f9>
mov    -0x830(%rbp),%rdi
lea    0xc7b(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1462 <main+0x2a2>
lea    -0x420(%rbp),%rdi
lea    0xc2d(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14b4 <main+0x2f4>
mov    -0x830(%rbp),%rdi
lea    0xc46(%rip),%rsi
mov    $0x9,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    149c <main+0x2dc>
lea    -0x420(%rbp),%rdi
lea    0xbf3(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14af <main+0x2ef>
lea    -0x420(%rbp),%rdi
lea    0xbc3(%rip),%rsi
call   10b0 <strcat@plt>
jmp    14b4 <main+0x2f4>
jmp    14b9 <main+0x2f9>
jmp    14be <main+0x2fe>
jmp    14c3 <main+0x303>
jmp    14c8 <main+0x308>
jmp    14cd <main+0x30d>
jmp    14d2 <main+0x312>
jmp    14d7 <main+0x317>
lea    -0x820(%rbp),%rdi
mov    -0x828(%rbp),%rsi
call   10b0 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    0xbc8(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x420(%rbp),%rdi
lea    0xbc9(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1540 <main+0x380>
lea    -0x420(%rbp),%rsi
lea    0xba9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16bb <main+0x4fb>
lea    -0x820(%rbp),%rdi
lea    0xb9d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1583 <main+0x3c3>
lea    -0x820(%rbp),%rsi
lea    0xb7d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16bb <main+0x4fb>
mov    -0x20(%rbp),%rsi
lea    0xb7a(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xb6a(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xb81(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xb71(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xb63(%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     15fa <main+0x43a>
jmp    1692 <main+0x4d2>
lea    -0x837(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <memset@plt>
cmpl   $0x10,-0x834(%rbp)
jl     1634 <main+0x474>
mov    -0x20(%rbp),%rsi
lea    0xb0a(%rip),%rdi
call   1070 <fputs@plt>
movl   $0x0,-0x834(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xb0f(%rip),%rdi
call   1070 <fputs@plt>
lea    -0x837(%rbp),%rdi
lea    0xaff(%rip),%rsi
movzbl -0x835(%rbp),%edx
call   10c0 <sprintf@plt>
lea    -0x837(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <fputs@plt>
mov    -0x20(%rbp),%rsi
lea    0xadd(%rip),%rdi
call   1070 <fputs@plt>
mov    -0x834(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x834(%rbp)
jmp    15d3 <main+0x413>
mov    -0x20(%rbp),%rsi
lea    0xabc(%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,%r14
lea    0xdcf(%rip),%rdi
call   1030 <getenv@plt>
test   %r14,%r14
je     137e <main+0x18e>
mov    %rax,%rbx
test   %rax,%rax
je     1387 <main+0x197>
lea    0x410(%rsp),%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
lea    0xda6(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
lea    0xd97(%rip),%rbp
test   %rax,%rax
je     139b <main+0x1ab>
lea    0xd9a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
lea    0xd8b(%rip),%r15
test   %rax,%rax
je     1398 <main+0x1a8>
lea    0xd8e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     139b <main+0x1ab>
lea    0xd76(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     139b <main+0x1ab>
lea    0xd5e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1398 <main+0x1a8>
lea    0xd46(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1398 <main+0x1a8>
lea    0xd32(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1398 <main+0x1a8>
lea    0xd1e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
mov    %r15,%rbp
test   %rax,%rax
je     139b <main+0x1ab>
lea    0xd07(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
lea    0xcbf(%rip),%rax
lea    0xca0(%rip),%rbp
cmove  %rax,%rbp
jmp    139b <main+0x1ab>
lea    0xd84(%rip),%rdi
jmp    138e <main+0x19e>
lea    0xda6(%rip),%rdi
call   1050 <puts@plt>
jmp    141e <main+0x22e>
mov    %r15,%rbp
lea    0x410(%rsp),%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
lea    0xca6(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <strcat@plt>
lea    0xcab(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1408 <main+0x218>
mov    %rax,%rbx
lea    0xcab(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
jne    1435 <main+0x245>
lea    0xc97(%rip),%rdi
lea    0x10(%rsp),%rsi
jmp    1417 <main+0x227>
lea    0xc72(%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    0xc74(%rip),%rbp
mov    $0x28,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rax,%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    0xc52(%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    155b <main+0x36b>
xor    %r13d,%r13d
lea    0xe(%rsp),%r15
lea    0xc3a(%rip),%rbp
jmp    1531 <main+0x341>
mov    $0x2,%esi
mov    $0x1,%edx
lea    0xc1f(%rip),%rdi
mov    %r14,%rcx
call   1100 <fwrite@plt>
movzbl %r12b,%edx
mov    %r15,%rdi
lea    0xc0c(%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    155b <main+0x36b>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1090 <memset@plt>
cmp    $0x10,%r13d
jl     14c9 <main+0x2d9>
mov    $0xa,%edi
mov    %r14,%rsi
call   10a0 <fputc@plt>
xor    %r13d,%r13d
jmp    14c9 <main+0x2d9>
lea    0xba2(%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 = [5 x i8] c"3090\00"
@.str.9 = [5 x i8] c"3390\00"
@.str.10 = [5 x i8] c"2070\00"
@.str.11 = [5 x i8] c"3070\00"
@.str.12 = [5 x i8] c"3572\00"
@.str.13 = [5 x i8] c"3370\00"
@.str.14 = [10 x i8] c"USB_COMBO\00"
@.str.15 = [20 x i8] c"/include/firmware.h\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [21 x i8] c"Can't read file %s \0A\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.20 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.21 = [2 x i8] c"\0A\00"
@.str.22 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.23 = [3 x i8] c"0x\00"
@.str.24 = [5 x i8] c"%02x\00"
@.str.25 = [3 x i8] c", \00"
@.str.26 = [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 [2 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 %177
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 %177
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 %109
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 %108
49: ; preds = %42
%50 = load i8*, i8** %11
%51 = call i64 @strncmp(i8* %50, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %107
56: ; preds = %49
%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 = %56
%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.5, i64 0, i64 0))
br label %106
63: ; preds = %56
%64 = load i8*, i8** %11
%65 = call i64 @strncmp(i8* %64, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, 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.7, i64 0, i64 0))
br label %105
70: ; preds = %63
%71 = load i8*, i8** %11
%72 = call i64 @strncmp(i8* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, 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.7, i64 0, i64 0))
br label %104
77: ; preds = %70
%78 = load i8*, i8** %11
%79 = call i64 @strncmp(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, 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.7, i64 0, i64 0))
br label %103
84: ; preds = %77
%85 = load i8*, i8** %11
%86 = call i64 @strncmp(i8* %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, 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.7, i64 0, i64 0))
br label %102
91: ; preds = %84
%92 = load i8*, i8** %11
%93 = call i64 @strncmp(i8* %92, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 9)
%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.7, i64 0, i64 0))
br label %101
98: ; preds = %91
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%100 = call i32 @strcat(i8* %99, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %101
101: ; preds = %98, %95
br label %102
102: ; preds = %101, %88
br label %103
103: ; preds = %102, %81
br label %104
104: ; preds = %103, %74
br label %105
105: ; preds = %104, %67
br label %106
106: ; preds = %105, %60
br label %107
107: ; preds = %106, %53
br label %108
108: ; preds = %107, %46
br label %109
109: ; preds = %108, %39
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%111 = load i8*, i8** %10
%112 = call i32 @strcat(i8* %110, i8* %111)
%113 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%114 = call i32 @strcat(i8* %113, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%116 = call i32* @fopen(i8* %115, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
store i32* %116, i32** %6
%117 = load i32*, i32** %6
%118 = icmp eq i32* %117, null
br i1 %118, label %119, label %122
119: ; preds = %109
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* %120)
store i32 -1, i32* %3
br label %177
122: ; preds = %109
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%124 = call i32* @fopen(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
store i32* %124, i32** %7
%125 = load i32*, i32** %7
%126 = icmp eq i32* %125, null
br i1 %126, label %127, label %130
127: ; preds = %122
%128 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.19, i64 0, i64 0), i8* %128)
store i32 -1, i32* %3
br label %177
130: ; preds = %122
%131 = load i32*, i32** %7
%132 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0), i32* %131)
%133 = load i32*, i32** %7
%134 = call i32 @fputs(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0), i32* %133)
%135 = load i32*, i32** %7
%136 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32* %135)
%137 = load i32*, i32** %7
%138 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32* %137)
%139 = load i32*, i32** %7
%140 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0), i32* %139)
br label %141
141: ; preds = %130, %156
%142 = load i32*, i32** %6
%143 = call zeroext i8 @getc(i32* %142)
store i8 %143, i8* %13
%144 = load i32*, i32** %6
%145 = call i64 @feof(i32* %144)
%146 = icmp ne i64 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %141
br label %169
148: ; preds = %141
%149 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%150 = call i32 @memset(i8* %149, i32 0, i32 2)
%151 = load i32, i32* %12
%152 = icmp sge i32 %151, 16
br i1 %152, label %153, label %156
153: ; preds = %148
%154 = load i32*, i32** %7
%155 = call i32 @fputs(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i64 0, i64 0), i32* %154)
store i32 0, i32* %12
br label %156
156: ; preds = %153, %148
%157 = load i32*, i32** %7
%158 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0), i32* %157)
%159 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%160 = load i8, i8* %13
%161 = call i32 @sprintf(i8* %159, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i64 0, i64 0), i8 zeroext %160)
%162 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%163 = load i32*, i32** %7
%164 = call i32 @fputs(i8* %162, i32* %163)
%165 = load i32*, i32** %7
%166 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i32* %165)
%167 = load i32, i32* %12
%168 = add nsw i32 %167, 1
store i32 %168, i32* %12
br label %141
169: ; preds = %147
%170 = load i32*, i32** %7
%171 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i64 0, i64 0), i32* %170)
%172 = load i32*, i32** %6
%173 = call i32 @fclose(i32* %172)
%174 = load i32*, i32** %7
%175 = call i32 @fclose(i32* %174)
%176 = call i32 @exit(i32 0)
unreachable
177: ; preds = %127, %119, %30, %25
%178 = load i32, i32* %3
ret i32 %178
}

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 = [5 x i8] c"3090\00"
@.str.9 = [5 x i8] c"3390\00"
@.str.10 = [5 x i8] c"2070\00"
@.str.11 = [5 x i8] c"3070\00"
@.str.12 = [5 x i8] c"3572\00"
@.str.13 = [5 x i8] c"3370\00"
@.str.14 = [10 x i8] c"USB_COMBO\00"
@.str.15 = [20 x i8] c"/include/firmware.h\00"
@.str.16 = [2 x i8] c"r\00"
@.str.17 = [21 x i8] c"Can't read file %s \0A\00"
@.str.18 = [2 x i8] c"w\00"
@.str.19 = [27 x i8] c"Can't open write file %s \0A\00"
@.str.20 = [41 x i8] c"/* AUTO GEN PLEASE DO NOT MODIFY IT */ \0A\00"
@.str.22 = [29 x i8] c"UCHAR FirmwareImage [] = { \0A\00"
@.str.23 = [3 x i8] c"0x\00"
@.str.24 = [5 x i8] c"%02x\00"
@.str.25 = [3 x i8] c", \00"
@.str.26 = [5 x i8] c"} ;\0A\00"
@str = [43 x i8] c"Environment value \22RT28xx_DIR\22 not export \00"
@str.27 = [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 [2 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 %96
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.27, i64 0, i64 0))
br label %96
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 %50, 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
br i1 %27, label %50, label %28
28: ; preds = %25
%29 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %50, label %31
31: ; preds = %28
%32 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %50, label %34
34: ; preds = %31
%35 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32 4)
%36 = icmp eq i64 %35, 0
br i1 %36, label %50, label %37
37: ; preds = %34
%38 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i32 4)
%39 = icmp eq i64 %38, 0
br i1 %39, label %50, label %40
40: ; preds = %37
%41 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i32 4)
%42 = icmp eq i64 %41, 0
br i1 %42, label %50, 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 %50, label %46
46: ; preds = %43
%47 = call i64 @strncmp(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 9)
%48 = icmp eq i64 %47, 0
%49 = select i1 %48, 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 %50
50: ; preds = %46, %43, %40, %37, %34, %31, %28, %25, %21
%51 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %21 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %25 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %28 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), %31 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %34 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %37 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %40 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %43 ], [ %49, %46 ]
%52 = call i32 @strcat(i8* %6, i8* %51)
%53 = call i32 @strcat(i8* %7, i8* %11)
%54 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.15, i64 0, i64 0))
%55 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i64 0, i64 0), i8* %6)
br label %96
59: ; preds = %50
%60 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.18, i64 0, i64 0))
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.19, i64 0, i64 0), i8* %7)
br label %96
64: ; preds = %59
%65 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0), i64 40, i64 1, i32* %60)
%66 = call i64 @fwrite(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0), i64 40, i64 1, i32* %60)
%67 = call i32 @fputc(i32 10, i32* %60)
%68 = call i32 @fputc(i32 10, i32* %60)
%69 = call i64 @fwrite(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.22, i64 0, i64 0), i64 28, i64 1, i32* %60)
%70 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%71 = call zeroext i8 @getc(i32* %55)
%72 = call i64 @feof(i32* %55)
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %91
74: ; preds = %64, %81
%75 = phi i8 [ %88, %81 ], [ %71, %64 ]
%76 = phi i32 [ %87, %81 ], [ 0, %64 ]
%77 = call i32 @memset(i8* %70, i32 0, i32 2)
%78 = icmp sgt i32 %76, 15
br i1 %78, label %79, label %81
79: ; preds = %74
%80 = call i32 @fputc(i32 10, i32* %60)
br label %81
81: ; preds = %74, %79
%82 = phi i32 [ 0, %79 ], [ %76, %74 ]
%83 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.23, i64 0, i64 0), i64 2, i64 1, i32* %60)
%84 = call i32 @sprintf(i8* %70, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.24, i64 0, i64 0), i8 zeroext %75)
%85 = call i32 @fputs(i8* %70, i32* %60)
%86 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.25, i64 0, i64 0), i64 2, i64 1, i32* %60)
%87 = add nsw i32 %82, 1
%88 = call zeroext i8 @getc(i32* %55)
%89 = call i64 @feof(i32* %55)
%90 = icmp eq i64 %89, 0
br i1 %90, label %74, label %91
91: ; preds = %81, %64
%92 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i64 0, i64 0), i64 4, i64 1, i32* %60)
%93 = call i32 @fclose(i32* %55)
%94 = call i32 @fclose(i32* %60)
%95 = call i32 @exit(i32 0)
unreachable
96: ; preds = %62, %57, %19, %15
ret i32 -1
}