#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*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
char *strstr(char *, char *);
int /*<<< orphan*/ system(char *);
int import(char *filename, int offset, int len) {
  char data;
  FILE *fp, *src;
  char buf[4096];
  char *p;
  char q[2];
  FILE *fprod;
  if (!(fp = fopen("/var/uploadCfg", "w+"))) {
    return 1;
  }
  if (!(src = fopen(filename, "r"))) {
    fclose(fp);
    return 1;
  }
  if (fseek(src, offset, SEEK_SET) == -1) {
    printf("fseek error\n");
  }
  while (len > 0) {
    if (!fread(&data, 1, 1, src))
      break;
    fwrite(&data, 1, 1, fp);
    len--;
  }
  fclose(fp);
  fclose(src);
  if ((fp = fopen("/var/uploadCfg", "r")) == NULL)
    return 1;
  else {
    fgets(buf, sizeof(buf), fp);
    fclose(fp);
    if ((p = strstr(buf, "EZP_LOG")) == NULL) {
      system("rm -rf /var/uploadCfg");
      return 1;
    }
    if ((p = strstr(p + strlen("EZP_LOG"), "EZP_")) == NULL) {
      system("rm -rf /var/uploadCfg");
      return 1;
    }
    p += strlen("EZP_");
    system("nvram get prod_cat > /var/prod_cat");
    if ((fprod = fopen("/var/prod_cat", "r")) == NULL)
      return 1;
    else
      fgets(q, 2, fprod);
    fclose(fprod);
    system("rm -rf /var/prod_cat");
    if (p[0] != q[0]) {
      system("rm -rf /var/uploadCfg");
      return 1;
    }
    system("nvram get prod_subcat > /var/prod_subcat");
    if ((fprod = fopen("/var/prod_subcat", "r")) == NULL)
      return 1;
    else
      fgets(q, 2, fprod);
    fclose(fprod);
    system("rm -rf /var/prod_subcat");
    if (p[1] != q[0]) {
      system("rm -rf /var/uploadCfg");
      return 1;
    }
  }
  system("nvram import /var/uploadCfg");
  system("nvram commit");
  system("rm -rf /var/uploadCfg");
  return 0;
}


x86 assembly (clang, -O0):
<import>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
lea    0xe65(%rip),%rdi
lea    0xe3d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11e2 <import+0x42>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
mov    -0x10(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1215 <import+0x75>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
cmp    $0xffffffff,%eax
jne    123f <import+0x9f>
lea    0xdcb(%rip),%rdi
call   1070 <printf@plt>
jmp    1244 <import+0xa4>
cmpl   $0x0,-0x18(%rbp)
jle    1292 <import+0xf2>
mov    -0x30(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%eax
jne    1270 <import+0xd0>
jmp    1292 <import+0xf2>
mov    -0x28(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10b0 <fwrite@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1244 <import+0xa4>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xd76(%rip),%rdi
lea    0xd51(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12d1 <import+0x131>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
lea    -0x1030(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x1000,%esi
call   1080 <fgets@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x1030(%rbp),%rdi
lea    0xd15(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x1038(%rbp)
cmp    $0x0,%rax
jne    132b <import+0x18b>
lea    0xd00(%rip),%rdi
call   1060 <system@plt>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
mov    -0x1038(%rbp),%rax
mov    %rax,-0x1050(%rbp)
lea    0xcd2(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x1050(%rbp),%rdi
cltq
add    %rax,%rdi
lea    0xcd8(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,-0x1038(%rbp)
cmp    $0x0,%rax
jne    1386 <import+0x1e6>
lea    0xca5(%rip),%rdi
call   1060 <system@plt>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
lea    0xca3(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x1038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x1038(%rbp)
lea    0xc86(%rip),%rdi
call   1060 <system@plt>
lea    0xc8f(%rip),%rdi
lea    0xc41(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x1048(%rbp)
cmp    $0x0,%rax
jne    13e4 <import+0x244>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
lea    -0x103a(%rbp),%rdi
mov    -0x1048(%rbp),%rdx
mov    $0x2,%esi
call   1080 <fgets@plt>
mov    -0x1048(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xc49(%rip),%rdi
call   1060 <system@plt>
mov    -0x1038(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x103a(%rbp),%ecx
cmp    %ecx,%eax
je     1445 <import+0x2a5>
lea    0xbe6(%rip),%rdi
call   1060 <system@plt>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
lea    0xc21(%rip),%rdi
call   1060 <system@plt>
lea    0xc2d(%rip),%rdi
lea    0xba4(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x1048(%rbp)
cmp    $0x0,%rax
jne    1481 <import+0x2e1>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
lea    -0x103a(%rbp),%rdi
mov    -0x1048(%rbp),%rdx
mov    $0x2,%esi
call   1080 <fgets@plt>
mov    -0x1048(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xbea(%rip),%rdi
call   1060 <system@plt>
mov    -0x1038(%rbp),%rax
movsbl 0x1(%rax),%eax
movsbl -0x103a(%rbp),%ecx
cmp    %ecx,%eax
je     14e3 <import+0x343>
lea    0xb48(%rip),%rdi
call   1060 <system@plt>
movl   $0x1,-0x4(%rbp)
jmp    1513 <import+0x373>
jmp    14e8 <import+0x348>
lea    0xbbf(%rip),%rdi
call   1060 <system@plt>
lea    0xbcf(%rip),%rdi
call   1060 <system@plt>
lea    0xb13(%rip),%rdi
call   1060 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<import>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1010,%rsp
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xe54(%rip),%rdi
lea    0xe3b(%rip),%rsi
call   10b0 <fopen@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     13f8 <import+0x258>
mov    %rax,%r14
lea    0xeef(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13e2 <import+0x242>
mov    %rax,%rbx
mov    0x2de2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12d,%esi
call   10a0 <fseek@plt>
cmp    $0xffffffff,%eax
jne    121c <import+0x7c>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    125e <import+0xbe>
add    $0x1,%ebp
lea    0xf(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
test   %eax,%eax
je     125e <import+0xbe>
movsbl 0xf(%rsp),%edi
mov    %r14,%rsi
call   1080 <fputc@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
jg     1230 <import+0x90>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xd9d(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f8 <import+0x258>
mov    %rax,%rbx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xd52(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     13ec <import+0x24c>
mov    %rax,%rbx
lea    0xd37(%rip),%rdi
call   1060 <strlen@plt>
cltq
add    %rax,%rbx
lea    0xd44(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <strstr@plt>
test   %rax,%rax
je     13ec <import+0x24c>
mov    %rax,%r14
lea    0xd29(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0xd20(%rip),%rdi
call   1070 <system@plt>
lea    0xd29(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f8 <import+0x258>
mov    %rax,%rbp
movslq %ebx,%r12
lea    0xd(%rsp),%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xcfb(%rip),%rdi
call   1070 <system@plt>
mov    (%r14,%r12,1),%al
cmp    0xd(%rsp),%al
jne    13ec <import+0x24c>
lea    0xcf6(%rip),%rdi
call   1070 <system@plt>
lea    0xd02(%rip),%rdi
lea    0xd57(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13f8 <import+0x258>
mov    %rax,%rbx
lea    0xd(%rsp),%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0xcde(%rip),%rdi
call   1070 <system@plt>
mov    0x1(%r14,%r12,1),%al
cmp    0xd(%rsp),%al
jne    13ec <import+0x24c>
lea    0xcdf(%rip),%rdi
call   1070 <system@plt>
lea    0xcef(%rip),%rdi
call   1070 <system@plt>
lea    0xc33(%rip),%rdi
call   1070 <system@plt>
xor    %r15d,%r15d
jmp    13f8 <import+0x258>
mov    %r14,%rdi
call   1050 <fclose@plt>
jmp    13f8 <import+0x258>
lea    0xc18(%rip),%rdi
call   1070 <system@plt>
mov    %r15d,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/var/uploadCfg\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@.str.3 = [13 x i8] c"fseek error\0A\00"
@.str.4 = [8 x i8] c"EZP_LOG\00"
@.str.5 = [22 x i8] c"rm -rf /var/uploadCfg\00"
@.str.6 = [5 x i8] c"EZP_\00"
@.str.7 = [35 x i8] c"nvram get prod_cat > /var/prod_cat\00"
@.str.8 = [14 x i8] c"/var/prod_cat\00"
@.str.9 = [21 x i8] c"rm -rf /var/prod_cat\00"
@.str.10 = [41 x i8] c"nvram get prod_subcat > /var/prod_subcat\00"
@.str.11 = [17 x i8] c"/var/prod_subcat\00"
@.str.12 = [24 x i8] c"rm -rf /var/prod_subcat\00"
@.str.13 = [28 x i8] c"nvram import /var/uploadCfg\00"
@.str.14 = [13 x i8] c"nvram commit\00"
define i32 @import(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca [4096 x i8]
%12 = alloca i8*
%13 = alloca [2 x i8]
%14 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%15 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %9
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
store i32 1, i32* %4
br label %130
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %20, i32** %10
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32*, i32** %9
%24 = call i32 @fclose(i32* %23)
store i32 1, i32* %4
br label %130
25: ; preds = %18
%26 = load i32*, i32** %10
%27 = load i32, i32* %6
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %26, i32 %27, i32 %28)
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %25
br label %34
34: ; preds = %42, %33
%35 = load i32, i32* %7
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %34
%38 = load i32*, i32** %10
%39 = call i32 @fread(i8* %8, i32 1, i32 1, i32* %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
br label %47
42: ; preds = %37
%43 = load i32*, i32** %9
%44 = call i32 @fwrite(i8* %8, i32 1, i32 1, i32* %43)
%45 = load i32, i32* %7
%46 = add nsw i32 %45, -1
store i32 %46, i32* %7
br label %34
47: ; preds = %41, %34
%48 = load i32*, i32** %9
%49 = call i32 @fclose(i32* %48)
%50 = load i32*, i32** %10
%51 = call i32 @fclose(i32* %50)
%52 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %52, i32** %9
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %55
54: ; preds = %47
store i32 1, i32* %4
br label %130
55: ; preds = %47
%56 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%57 = load i32*, i32** %9
%58 = call i32 @fgets(i8* %56, i32 4096, i32* %57)
%59 = load i32*, i32** %9
%60 = call i32 @fclose(i32* %59)
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%62 = call i8* @strstr(i8* %61, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i8* %62, i8** %12
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %66
64: ; preds = %55
%65 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %4
br label %130
66: ; preds = %55
%67 = load i8*, i8** %12
%68 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
%71 = call i8* @strstr(i8* %70, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i8* %71, i8** %12
%72 = icmp eq i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %66
%74 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %4
br label %130
75: ; preds = %66
%76 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%77 = load i8*, i8** %12
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds i8, i8* %77, i64 %78
store i8* %79, i8** %12
%80 = call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%81 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %81, i32** %14
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %84
83: ; preds = %75
store i32 1, i32* %4
br label %130
84: ; preds = %75
%85 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%86 = load i32*, i32** %14
%87 = call i32 @fgets(i8* %85, i32 2, i32* %86)
br label %88
88: ; preds = %84
%89 = load i32*, i32** %14
%90 = call i32 @fclose(i32* %89)
%91 = call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%92 = load i8*, i8** %12
%93 = getelementptr inbounds i8, i8* %92, i64 0
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp ne i32 %95, %98
br i1 %99, label %100, label %102
100: ; preds = %88
%101 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %4
br label %130
102: ; preds = %88
%103 = call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%104 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %104, i32** %14
%105 = icmp eq i32* %104, null
br i1 %105, label %106, label %107
106: ; preds = %102
store i32 1, i32* %4
br label %130
107: ; preds = %102
%108 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%109 = load i32*, i32** %14
%110 = call i32 @fgets(i8* %108, i32 2, i32* %109)
br label %111
111: ; preds = %107
%112 = load i32*, i32** %14
%113 = call i32 @fclose(i32* %112)
%114 = call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%115 = load i8*, i8** %12
%116 = getelementptr inbounds i8, i8* %115, i64 1
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = getelementptr inbounds [2 x i8], [2 x i8]* %13, i64 0, i64 0
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp ne i32 %118, %121
br i1 %122, label %123, label %125
123: ; preds = %111
%124 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %4
br label %130
125: ; preds = %111
br label %126
126: ; preds = %125
%127 = call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%128 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%129 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %4
br label %130
130: ; preds = %126, %123, %106, %100, %83, %73, %64, %54, %22, %17
%131 = load i32, i32* %4
ret i32 %131
}

LLVM IR (-O2):
@.str = [15 x i8] c"/var/uploadCfg\00"
@.str.1 = [3 x i8] c"w+\00"
@.str.2 = [2 x i8] c"r\00"
@SEEK_SET = global i32 0
@.str.4 = [8 x i8] c"EZP_LOG\00"
@.str.5 = [22 x i8] c"rm -rf /var/uploadCfg\00"
@.str.6 = [5 x i8] c"EZP_\00"
@.str.7 = [35 x i8] c"nvram get prod_cat > /var/prod_cat\00"
@.str.8 = [14 x i8] c"/var/prod_cat\00"
@.str.9 = [21 x i8] c"rm -rf /var/prod_cat\00"
@.str.10 = [41 x i8] c"nvram get prod_subcat > /var/prod_subcat\00"
@.str.11 = [17 x i8] c"/var/prod_subcat\00"
@.str.12 = [24 x i8] c"rm -rf /var/prod_subcat\00"
@.str.13 = [28 x i8] c"nvram import /var/uploadCfg\00"
@.str.14 = [13 x i8] c"nvram commit\00"
@str = [12 x i8] c"fseek error\00"
define i32 @import(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca [4096 x i8]
%6 = alloca [2 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %88, label %11
11: ; preds = %3
%12 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @fclose(i32* %9)
br label %88
16: ; preds = %11
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %12, i32 %1, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = icmp sgt i32 %2, 0
br i1 %23, label %24, label %34
24: ; preds = %22, %28
%25 = phi i32 [ %32, %28 ], [ %2, %22 ]
%26 = call i32 @fread(i8* %4, i32 1, i32 1, i32* %12)
%27 = icmp eq i32 %26, 0
br i1 %27, label %34, label %28
28: ; preds = %24
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = tail call i32 @fputc(i32 %30, i32* %9)
%32 = add nsw i32 %25, -1
%33 = icmp sgt i32 %25, 1
br i1 %33, label %24, label %34
34: ; preds = %28, %24, %22
%35 = tail call i32 @fclose(i32* %9)
%36 = tail call i32 @fclose(i32* %12)
%37 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %88, label %39
39: ; preds = %34
%40 = call i32 @fgets(i8* %7, i32 4096, i32* %37)
%41 = call i32 @fclose(i32* %37)
%42 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %88
46: ; preds = %39
%47 = call i32 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %42, i64 %48
%50 = call i8* @strstr(i8* %49, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %88
54: ; preds = %46
%55 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %50, i64 %56
%58 = call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%59 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp eq i32* %59, null
br i1 %60, label %88, label %61
61: ; preds = %54
%62 = call i32 @fgets(i8* %8, i32 2, i32* %59)
%63 = call i32 @fclose(i32* %59)
%64 = call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%65 = load i8, i8* %57
%66 = load i8, i8* %8
%67 = icmp eq i8 %65, %66
br i1 %67, label %70, label %68
68: ; preds = %61
%69 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %88
70: ; preds = %61
%71 = call i32 @system(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%72 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%73 = icmp eq i32* %72, null
br i1 %73, label %88, label %74
74: ; preds = %70
%75 = call i32 @fgets(i8* %8, i32 2, i32* %72)
%76 = call i32 @fclose(i32* %72)
%77 = call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
%78 = getelementptr inbounds i8, i8* %57, i64 1
%79 = load i8, i8* %78
%80 = load i8, i8* %8
%81 = icmp eq i8 %79, %80
br i1 %81, label %84, label %82
82: ; preds = %74
%83 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %88
84: ; preds = %74
%85 = call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%86 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%87 = call i32 @system(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %88
88: ; preds = %70, %54, %34, %3, %84, %82, %68, %52, %44, %14
%89 = phi i32 [ 1, %44 ], [ 1, %52 ], [ 1, %68 ], [ 1, %82 ], [ 0, %84 ], [ 1, %14 ], [ 1, %3 ], [ 1, %34 ], [ 1, %54 ], [ 1, %70 ]
ret i32 %89
}