#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 */
struct stat {
  int st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOMEM;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
size_t fwrite(char *, int, size_t, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ read_mac(char *, char *);
int stat(char *, struct stat *);
int main(int argc, char **argv) {
  char *buf;
  struct stat statbuf;
  int ret;
  size_t actual;
  FILE *f;
  ret =
      stat("/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin", &statbuf);
  if (ret) {
    perror("Failed to stat "
           "/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin");
    exit(EINVAL);
  }
  f = fopen("/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin", "r");
  if (!f) {
    perror("Failed to open "
           "/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin");
    exit(EINVAL);
  }
  if (statbuf.st_size < 100) {
    perror("nv file too small");
    exit(EINVAL);
  }
  if (statbuf.st_size != 28456)
    perror("Warning - size invalid");
  buf = malloc(statbuf.st_size);
  if (!buf) {
    perror("malloc failed");
    exit(ENOMEM);
  }
  actual = fread(buf, 1, statbuf.st_size, f);
  if (actual != statbuf.st_size) {
    perror("Failed to read from nv");
    exit(EINVAL);
  }
  fclose(f);
  do {
    if (read_mac("/data/etc/wlan_macaddr0", buf + 10)) {
      perror("Warning. Failed to read mac from "
             "MAC0_FILE"
             " - skipping");
    }
  } while (0);
  do {
    if (read_mac("/data/etc/wlan_macaddr1", buf + 16)) {
      perror("Warning. Failed to read mac from "
             "MAC1_FILE"
             " - skipping");
    }
  } while (0);
  do {
    if (read_mac("/data/etc/wlan_macaddr2", buf + 24)) {
      perror("Warning. Failed to read mac from "
             "MAC2_FILE"
             " - skipping");
    }
  } while (0);
  do {
    if (read_mac("/data/etc/wlan_macaddr3", buf + 32)) {
      perror("Warning. Failed to read mac from "
             "MAC3_FILE"
             " - skipping");
    }
  } while (0);
  f = fopen("/data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin", "w+");
  if (!f) {
    perror("Failed to open "
           "/data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin");
    exit(EINVAL);
  }
  actual = fwrite(buf, 1, statbuf.st_size, f);
  if (actual != statbuf.st_size) {
    perror("Failed to write to nv");
    exit(EINVAL);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <stat@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11dd <main+0x4d>
lea    0xe36(%rip),%rdi
call   1090 <perror@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xe73(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1219 <main+0x89>
lea    0xe42(%rip),%rdi
call   1090 <perror@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpl   $0x64,-0x20(%rbp)
jge    123d <main+0xad>
lea    0xe64(%rip),%rdi
call   1090 <perror@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpl   $0x6f28,-0x20(%rbp)
je     1256 <main+0xc6>
lea    0xe4f(%rip),%rdi
call   1090 <perror@plt>
mov    -0x20(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1287 <main+0xf7>
lea    0xe43(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
je     12cb <main+0x13b>
lea    0xe0d(%rip),%rdi
call   1090 <perror@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rsi
add    $0xa,%rsi
lea    0xdf9(%rip),%rdi
call   1050 <read_mac@plt>
cmp    $0x0,%rax
je     12fe <main+0x16e>
lea    0xdfb(%rip),%rdi
call   1090 <perror@plt>
jmp    1303 <main+0x173>
jmp    1308 <main+0x178>
mov    -0x18(%rbp),%rsi
add    $0x10,%rsi
lea    0xe13(%rip),%rdi
call   1050 <read_mac@plt>
cmp    $0x0,%rax
je     1332 <main+0x1a2>
lea    0xe15(%rip),%rdi
call   1090 <perror@plt>
jmp    1337 <main+0x1a7>
jmp    133c <main+0x1ac>
mov    -0x18(%rbp),%rsi
add    $0x18,%rsi
lea    0xe2d(%rip),%rdi
call   1050 <read_mac@plt>
cmp    $0x0,%rax
je     1366 <main+0x1d6>
lea    0xe2f(%rip),%rdi
call   1090 <perror@plt>
jmp    136b <main+0x1db>
jmp    1370 <main+0x1e0>
mov    -0x18(%rbp),%rsi
add    $0x20,%rsi
lea    0xe47(%rip),%rdi
call   1050 <read_mac@plt>
cmp    $0x0,%rax
je     139a <main+0x20a>
lea    0xe49(%rip),%rdi
call   1090 <perror@plt>
jmp    139f <main+0x20f>
lea    0xe80(%rip),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    13db <main+0x24b>
lea    0xe4f(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmp    %rcx,%rax
je     1420 <main+0x290>
lea    0xe46(%rip),%rdi
call   1090 <perror@plt>
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb8(%rip),%rdi
mov    %rsp,%rsi
call   1060 <stat@plt>
test   %eax,%eax
jne    132f <main+0x19f>
lea    0xea1(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1338 <main+0x1a8>
mov    (%rsp),%ebx
cmp    $0x63,%ebx
jle    1341 <main+0x1b1>
mov    %rax,%r15
cmp    $0x6f28,%ebx
jne    12da <main+0x14a>
mov    %ebx,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     134a <main+0x1ba>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
cmp    %rbx,%rax
jne    1364 <main+0x1d4>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xa(%r12),%rsi
lea    0xeb1(%rip),%rdi
call   1050 <read_mac@plt>
test   %rax,%rax
jne    12eb <main+0x15b>
lea    0x10(%r12),%rsi
lea    0xee5(%rip),%rdi
call   1050 <read_mac@plt>
test   %rax,%rax
jne    12fc <main+0x16c>
lea    0x18(%r12),%rsi
lea    0xf19(%rip),%rdi
call   1050 <read_mac@plt>
test   %rax,%rax
jne    130d <main+0x17d>
mov    %r12,%rsi
add    $0x20,%rsi
lea    0xf4b(%rip),%rdi
call   1050 <read_mac@plt>
test   %rax,%rax
jne    131e <main+0x18e>
lea    0xf96(%rip),%rdi
lea    0xf7d(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     136d <main+0x1dd>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rax,%rcx
call   10b0 <fwrite@plt>
cmp    %r14,%rax
jne    1376 <main+0x1e6>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdbf(%rip),%rdi
call   1090 <perror@plt>
jmp    11e6 <main+0x56>
lea    0xe02(%rip),%rdi
call   1090 <perror@plt>
jmp    1239 <main+0xa9>
lea    0xe3f(%rip),%rdi
call   1090 <perror@plt>
jmp    1253 <main+0xc3>
lea    0xe7c(%rip),%rdi
call   1090 <perror@plt>
jmp    126d <main+0xdd>
lea    0xeb9(%rip),%rdi
call   1090 <perror@plt>
jmp    1289 <main+0xf9>
lea    0xcca(%rip),%rdi
jmp    137d <main+0x1ed>
lea    0xd09(%rip),%rdi
jmp    137d <main+0x1ed>
lea    0xd46(%rip),%rdi
jmp    137d <main+0x1ed>
lea    0xd66(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    0xd5a(%rip),%rdi
jmp    137d <main+0x1ed>
lea    0xea3(%rip),%rdi
jmp    137d <main+0x1ed>
lea    0xed6(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [55 x i8] c"/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.1 = [70 x i8] c"Failed to stat /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@EINVAL = global i32 0
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [70 x i8] c"Failed to open /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.4 = [18 x i8] c"nv file too small\00"
@.str.5 = [23 x i8] c"Warning - size invalid\00"
@.str.6 = [14 x i8] c"malloc failed\00"
@ENOMEM = global i32 0
@.str.7 = [23 x i8] c"Failed to read from nv\00"
@.str.8 = [24 x i8] c"/data/etc/wlan_macaddr0\00"
@.str.9 = [54 x i8] c"Warning. Failed to read mac from MAC0_FILE - skipping\00"
@.str.10 = [24 x i8] c"/data/etc/wlan_macaddr1\00"
@.str.11 = [54 x i8] c"Warning. Failed to read mac from MAC1_FILE - skipping\00"
@.str.12 = [24 x i8] c"/data/etc/wlan_macaddr2\00"
@.str.13 = [54 x i8] c"Warning. Failed to read mac from MAC2_FILE - skipping\00"
@.str.14 = [24 x i8] c"/data/etc/wlan_macaddr3\00"
@.str.15 = [54 x i8] c"Warning. Failed to read mac from MAC3_FILE - skipping\00"
@.str.16 = [45 x i8] c"/data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.17 = [3 x i8] c"w+\00"
@.str.18 = [60 x i8] c"Failed to open /data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.19 = [22 x i8] c"Failed to write to nv\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.stat
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @stat(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), %struct.stat* %7)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EINVAL
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = call i32* @fopen(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %10
%20 = load i32*, i32** %10
%21 = icmp ne i32* %20, null
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* @EINVAL
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %18
%27 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, 100
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @EINVAL
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %26
%35 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 28456
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%42 = load i32, i32* %41
%43 = call i8* @malloc(i32 %42)
store i8* %43, i8** %6
%44 = load i8*, i8** %6
%45 = icmp ne i8* %44, null
br i1 %45, label %50, label %46
46: ; preds = %40
%47 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%48 = load i32, i32* @ENOMEM
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %40
%51 = load i8*, i8** %6
%52 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%53 = load i32, i32* %52
%54 = load i32*, i32** %10
%55 = call i64 @fread(i8* %51, i32 1, i32 %53, i32* %54)
store i64 %55, i64* %9
%56 = load i64, i64* %9
%57 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%58 = load i32, i32* %57
%59 = sext i32 %58 to i64
%60 = icmp ne i64 %56, %59
br i1 %60, label %61, label %65
61: ; preds = %50
%62 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%63 = load i32, i32* @EINVAL
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %50
%66 = load i32*, i32** %10
%67 = call i32 @fclose(i32* %66)
br label %68
68: ; preds = %65
%69 = load i8*, i8** %6
%70 = getelementptr inbounds i8, i8* %69, i64 10
%71 = call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %68
%74 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0))
br label %75
75: ; preds = %73, %68
br label %76
76: ; preds = %75
br label %77
77: ; preds = %76
%78 = load i8*, i8** %6
%79 = getelementptr inbounds i8, i8* %78, i64 16
%80 = call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0))
br label %84
84: ; preds = %82, %77
br label %85
85: ; preds = %84
br label %86
86: ; preds = %85
%87 = load i8*, i8** %6
%88 = getelementptr inbounds i8, i8* %87, i64 24
%89 = call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %88)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %86
%92 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0))
br label %93
93: ; preds = %91, %86
br label %94
94: ; preds = %93
br label %95
95: ; preds = %94
%96 = load i8*, i8** %6
%97 = getelementptr inbounds i8, i8* %96, i64 32
%98 = call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %97)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %95
%101 = call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.15, i64 0, i64 0))
br label %102
102: ; preds = %100, %95
br label %103
103: ; preds = %102
%104 = call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
store i32* %104, i32** %10
%105 = load i32*, i32** %10
%106 = icmp ne i32* %105, null
br i1 %106, label %111, label %107
107: ; preds = %103
%108 = call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.18, i64 0, i64 0))
%109 = load i32, i32* @EINVAL
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %103
%112 = load i8*, i8** %6
%113 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%114 = load i32, i32* %113
%115 = sext i32 %114 to i64
%116 = load i32*, i32** %10
%117 = call i64 @fwrite(i8* %112, i32 1, i64 %115, i32* %116)
store i64 %117, i64* %9
%118 = load i64, i64* %9
%119 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%120 = load i32, i32* %119
%121 = sext i32 %120 to i64
%122 = icmp ne i64 %118, %121
br i1 %122, label %123, label %127
123: ; preds = %111
%124 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.19, i64 0, i64 0))
%125 = load i32, i32* @EINVAL
%126 = call i32 @exit(i32 %125)
unreachable
127: ; preds = %111
%128 = load i32*, i32** %10
%129 = call i32 @fclose(i32* %128)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [55 x i8] c"/system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.1 = [70 x i8] c"Failed to stat /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@EINVAL = global i32 0
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [70 x i8] c"Failed to open /system/etc/firmware/wlan/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.4 = [18 x i8] c"nv file too small\00"
@.str.5 = [23 x i8] c"Warning - size invalid\00"
@.str.6 = [14 x i8] c"malloc failed\00"
@ENOMEM = global i32 0
@.str.7 = [23 x i8] c"Failed to read from nv\00"
@.str.8 = [24 x i8] c"/data/etc/wlan_macaddr0\00"
@.str.9 = [54 x i8] c"Warning. Failed to read mac from MAC0_FILE - skipping\00"
@.str.10 = [24 x i8] c"/data/etc/wlan_macaddr1\00"
@.str.11 = [54 x i8] c"Warning. Failed to read mac from MAC1_FILE - skipping\00"
@.str.12 = [24 x i8] c"/data/etc/wlan_macaddr2\00"
@.str.13 = [54 x i8] c"Warning. Failed to read mac from MAC2_FILE - skipping\00"
@.str.14 = [24 x i8] c"/data/etc/wlan_macaddr3\00"
@.str.15 = [54 x i8] c"Warning. Failed to read mac from MAC3_FILE - skipping\00"
@.str.16 = [45 x i8] c"/data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.17 = [3 x i8] c"w+\00"
@.str.18 = [60 x i8] c"Failed to open /data/misc/wifi/prima/WCNSS_qcom_wlan_nv.bin\00"
@.str.19 = [22 x i8] c"Failed to write to nv\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = call i32 @stat(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), %struct.stat* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EINVAL
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = tail call i32* @fopen(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 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 %18
14: ; preds = %11
%15 = tail call i32 @perror(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* @EINVAL
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %11
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = icmp slt i32 %20, 100
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%24 = load i32, i32* @EINVAL
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %18
%27 = icmp eq i32 %20, 28456
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
%31 = tail call i8* @malloc(i32 %20)
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%35 = load i32, i32* @ENOMEM
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %30
%38 = tail call i64 @fread(i8* %31, i32 1, i32 %20, i32* %12)
%39 = zext i32 %20 to i64
%40 = icmp eq i64 %38, %39
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%43 = load i32, i32* @EINVAL
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %37
%46 = tail call i32 @fclose(i32* %12)
%47 = getelementptr inbounds i8, i8* %31, i64 10
%48 = tail call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0))
br label %52
52: ; preds = %45, %50
%53 = getelementptr inbounds i8, i8* %31, i64 16
%54 = tail call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0))
br label %58
58: ; preds = %52, %56
%59 = getelementptr inbounds i8, i8* %31, i64 24
%60 = tail call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0), i8* %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %58
%63 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0))
br label %64
64: ; preds = %58, %62
%65 = getelementptr inbounds i8, i8* %31, i64 32
%66 = tail call i64 @read_mac(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0), i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = tail call i32 @perror(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.15, i64 0, i64 0))
br label %70
70: ; preds = %68, %64
%71 = tail call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %77
73: ; preds = %70
%74 = tail call i32 @perror(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.18, i64 0, i64 0))
%75 = load i32, i32* @EINVAL
%76 = tail call i32 @exit(i32 %75)
unreachable
77: ; preds = %70
%78 = tail call i64 @fwrite(i8* %31, i32 1, i64 %38, i32* %71)
%79 = icmp eq i64 %78, %38
br i1 %79, label %84, label %80
80: ; preds = %77
%81 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.19, i64 0, i64 0))
%82 = load i32, i32* @EINVAL
%83 = tail call i32 @exit(i32 %82)
unreachable
84: ; preds = %77
%85 = tail call i32 @fclose(i32* %71)
ret i32 0
}