#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;

/* Variables and functions */
int /*<<< orphan*/ dat2h(char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ getenv(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  char infname[512];
  char outfname[512];
  char struct_name[128] = "default_profile_buffer";
  char *rt28xxdir, *rt28xx_mode;
  rt28xxdir = (char *)getenv("RT28xx_DIR");
  rt28xx_mode = (char *)getenv("RT28xx_MODE");
  if (!rt28xxdir) {
    printf("Environment value \"RT28xx_DIR\" not export \n");
    return -1;
  }
  if (strlen(rt28xxdir) > (sizeof(infname) - 100)) {
    printf("Environment value \"RT28xx_DIR\" is too long!\n");
    return -1;
  }
  memset(infname, 0, 512);
  memset(outfname, 0, 512);
  strcat(infname, rt28xxdir);
  strcat(outfname, rt28xxdir);
  if (strncmp(rt28xx_mode, "STA", 3) == 0)
    strcat(infname, "/conf/RT2870STA.dat");
  else
    strcat(infname, "/conf/RT2870AP.dat");
  printf("### dat2h input: %s \n", infname);
  strcat(outfname, "/include/default_profile.h");
  dat2h(infname, outfname, struct_name);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x490(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x80,%edx
call   1080 <memcpy@plt>
lea    0xeb8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x498(%rbp)
lea    0xeb0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x4a0(%rbp)
cmpq   $0x0,-0x498(%rbp)
jne    120f <main+0x7f>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1325 <main+0x195>
mov    -0x498(%rbp),%rdi
call   1050 <strlen@plt>
cltq
cmp    $0x19c,%rax
jbe    1243 <main+0xb3>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1325 <main+0x195>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1070 <memset@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1070 <memset@plt>
lea    -0x210(%rbp),%rdi
mov    -0x498(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x410(%rbp),%rdi
mov    -0x498(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x4a0(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12c9 <main+0x139>
lea    -0x210(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1090 <strcat@plt>
jmp    12dc <main+0x14c>
lea    -0x210(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x210(%rbp),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x410(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    -0x410(%rbp),%rsi
lea    -0x490(%rbp),%rdx
call   10a0 <dat2h@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x488,%rsp
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe77(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe5b(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe3f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe23(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe07(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe7c(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe78(%rip),%rdi
call   1030 <getenv@plt>
test   %rbx,%rbx
je     1238 <main+0xa8>
mov    %rax,%r12
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x19c,%eax
jbe    1258 <main+0xc8>
lea    0xee8(%rip),%rdi
jmp    123f <main+0xaf>
lea    0xeb4(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0x488,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0x280(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
lea    0x80(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1080 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <strcat@plt>
lea    0xdf4(%rip),%rsi
mov    %r12,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
lea    0xde1(%rip),%rax
lea    0xdee(%rip),%rsi
cmove  %rax,%rsi
mov    %r15,%rdi
call   1090 <strcat@plt>
lea    0xdee(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf3(%rip),%rsi
mov    %r14,%rdi
call   1090 <strcat@plt>
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <dat2h@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@__const.main.struct_name = [128 x i8] c"default_profile_buffer\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [12 x i8] c"RT28xx_MODE\00"
@.str.2 = [44 x i8] c"Environment value \22RT28xx_DIR\22 not export \0A\00"
@.str.3 = [45 x i8] c"Environment value \22RT28xx_DIR\22 is too long!\0A\00"
@.str.4 = [4 x i8] c"STA\00"
@.str.5 = [20 x i8] c"/conf/RT2870STA.dat\00"
@.str.6 = [19 x i8] c"/conf/RT2870AP.dat\00"
@.str.7 = [22 x i8] c"### dat2h input: %s \0A\00"
@.str.8 = [27 x i8] c"/include/default_profile.h\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca [128 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [128 x i8]* %8 to i8*
%12 = call i64 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %9
%14 = call i64 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %10
%16 = load i8*, i8** %9
%17 = icmp ne i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %2
%19 = 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 %57
20: ; preds = %2
%21 = load i8*, i8** %9
%22 = call i32 @strlen(i8* %21)
%23 = sext i32 %22 to i64
%24 = icmp ugt i64 %23, 412
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %57
27: ; preds = %20
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i32 0, i32 512)
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%31 = call i32 @memset(i8* %30, i32 0, i32 512)
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%33 = load i8*, i8** %9
%34 = call i32 @strcat(i8* %32, i8* %33)
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%36 = load i8*, i8** %9
%37 = call i32 @strcat(i8* %35, i8* %36)
%38 = load i8*, i8** %10
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %27
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %47
44: ; preds = %27
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %44, %41
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%55 = call i32 @dat2h(i8* %52, i8* %53, i8* %54)
%56 = call i32 @exit(i32 0)
unreachable
57: ; preds = %25, %18
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@__const.main.struct_name = [128 x i8] c"default_profile_buffer\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"RT28xx_DIR\00"
@.str.1 = [12 x i8] c"RT28xx_MODE\00"
@.str.4 = [4 x i8] c"STA\00"
@.str.5 = [20 x i8] c"/conf/RT2870STA.dat\00"
@.str.6 = [19 x i8] c"/conf/RT2870AP.dat\00"
@.str.7 = [22 x i8] c"### dat2h input: %s \0A\00"
@.str.8 = [27 x i8] c"/include/default_profile.h\00"
@str = [43 x i8] c"Environment value \22RT28xx_DIR\22 not export \00"
@str.9 = [44 x i8] c"Environment value \22RT28xx_DIR\22 is too long!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = tail call i64 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = inttoptr i64 %9 to i8*
%11 = tail call i64 @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %9, 0
br i1 %12, label %30, label %13
13: ; preds = %2
%14 = tail call i32 @strlen(i8* %10)
%15 = icmp ugt i32 %14, 412
br i1 %15, label %30, label %16
16: ; preds = %13
%17 = inttoptr i64 %11 to i8*
%18 = call i32 @memset(i8* %6, i32 0, i32 512)
%19 = call i32 @memset(i8* %7, i32 0, i32 512)
%20 = call i32 @strcat(i8* %6, i8* %10)
%21 = call i32 @strcat(i8* %7, i8* %10)
%22 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 3)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0)
%25 = call i32 @strcat(i8* %6, i8* %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%27 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 @dat2h(i8* %6, i8* %7, i8* %8)
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %13, %2
%31 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @str.9, i64 0, i64 0), %13 ]
%32 = tail call i32 @puts(i8* dereferenceable(1) %31)
ret i32 -1
}