#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*/ wchar_t;
struct varstr {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int rkey(int /*<<< orphan*/ *, struct varstr *);
int rval(int /*<<< orphan*/ *, struct varstr *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ store_kv(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ varstr_free(struct varstr *);
struct varstr *varstr_init();
int /*<<< orphan*/ *varstr_pack(struct varstr *);
extern int load(char *filename) {
  FILE *fp;
  fp = fopen(filename, "r");
  if (fp == NULL) {
    if (errno == ENOENT) {
      return 2;
    }
    perror("load(): opening file");
    return 1;
  }
  struct varstr *key = NULL, *val = NULL;
  wchar_t *k = NULL, *v = NULL;
  signed int retval = -1;
  bool valonly = false;
  signed int is_ss = -1;
  do {
    key = varstr_init();
    val = varstr_init();
    if (key == NULL || val == NULL) {
      perror("load(): varstr_init failed");
      return 1;
    }
    valonly = false;
    is_ss = rkey(fp, key);
  newval:
    if (is_ss >= 0)
      retval = rval(fp, val);
    if (is_ss < 0 || retval < 0) {
      if (is_ss < 0)
        retval = is_ss;
      if (retval == -2) {
        fwprintf(stderr, L"load(): database corrupted\n");
        return 1;
      }
      if (retval == -3) {
        if (ferror(fp)) {
          perror("load(): error reading file");
          return 1;
        }
        if (is_ss < 0)
          break;
        if ((k = varstr_pack(key)) == NULL || (v = varstr_pack(val)) == NULL) {
          perror("load(): varstr_pack failed");
          return 1;
        }
        key = val = NULL;
        store_kv(k, v, is_ss);
        break;
      }
      perror("load(): internal error");
      return 1;
    }
    if ((!valonly && (k = varstr_pack(key)) == NULL) ||
        (v = varstr_pack(val)) == NULL) {
      perror("load(): varstr_pack failed");
      return 1;
    }
    key = val = NULL;
    store_kv(k, v, (is_ss == 1 ? true : false));
    if (retval == 1) {
      if ((val = varstr_init()) == NULL) {
        perror("load(): varstr_init failed");
        return 1;
      }
      valonly = true;
      goto newval;
    }
  } while (true);
  if (key != NULL)
    varstr_free(key);
  if (val != NULL)
    varstr_free(val);
  return 0;
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1209 <load+0x69>
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
mov    0x2dec(%rip),%rcx
cmp    (%rcx),%rax
jne    11f1 <load+0x51>
movl   $0x2,-0x4(%rbp)
jmp    14cc <load+0x32c>
lea    0xe08(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0xffffffff,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0xffffffff,-0x44(%rbp)
mov    $0x0,%al
call   1040 <varstr_init@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <varstr_init@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     126a <load+0xca>
cmpq   $0x0,-0x28(%rbp)
jne    1282 <load+0xe2>
lea    0xda4(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <rkey@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     12b3 <load+0x113>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <rval@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     12c7 <load+0x127>
cmpl   $0x0,-0x3c(%rbp)
jge    13c9 <load+0x229>
cmpl   $0x0,-0x44(%rbp)
jge    12d7 <load+0x137>
mov    -0x44(%rbp),%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0xfffffffe,-0x3c(%rbp)
jne    1302 <load+0x162>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
lea    0xd8f(%rip),%rsi
call   10a0 <fwprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
cmpl   $0xfffffffd,-0x3c(%rbp)
jne    13b1 <load+0x211>
mov    -0x18(%rbp),%rdi
call   1050 <ferror@plt>
cmp    $0x0,%rax
je     1337 <load+0x197>
lea    0xd0a(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
cmpl   $0x0,-0x44(%rbp)
jge    1346 <load+0x1a6>
jmp    149d <load+0x2fd>
mov    -0x20(%rbp),%rdi
call   1080 <varstr_pack@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1374 <load+0x1d4>
mov    -0x28(%rbp),%rdi
call   1080 <varstr_pack@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    138c <load+0x1ec>
lea    0xcd0(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x44(%rbp),%edx
call   1060 <store_kv@plt>
jmp    149d <load+0x2fd>
lea    0xcae(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
cmpl   $0x0,-0x40(%rbp)
jne    13ea <load+0x24a>
mov    -0x20(%rbp),%rdi
call   1080 <varstr_pack@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1401 <load+0x261>
mov    -0x28(%rbp),%rdi
call   1080 <varstr_pack@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1419 <load+0x279>
lea    0xc43(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x44(%rbp),%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x1,%ecx
cmove  %eax,%edx
call   1060 <store_kv@plt>
cmpl   $0x1,-0x3c(%rbp)
jne    1489 <load+0x2e9>
mov    $0x0,%al
call   1040 <varstr_init@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    147d <load+0x2dd>
lea    0xba9(%rip),%rdi
call   10c0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <load+0x32c>
movl   $0x1,-0x40(%rbp)
jmp    1299 <load+0xf9>
jmp    148e <load+0x2ee>
mov    $0x1,%al
test   $0x1,%al
jne    123e <load+0x9e>
jmp    149d <load+0x2fd>
cmpq   $0x0,-0x20(%rbp)
je     14b1 <load+0x311>
mov    -0x20(%rbp),%rdi
call   1030 <varstr_free@plt>
cmpq   $0x0,-0x28(%rbp)
je     14c5 <load+0x325>
mov    -0x28(%rbp),%rdi
call   1030 <varstr_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xec6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     12c4 <load+0x124>
xor    %eax,%eax
call   1040 <varstr_init@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <varstr_init@plt>
test   %rbx,%rbx
je     12b8 <load+0x118>
mov    %rax,%r14
test   %rax,%rax
je     12b8 <load+0x118>
xor    %ebp,%ebp
mov    %rbx,%r13
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <rkey@plt>
xor    %r15d,%r15d
mov    %eax,0xc(%rsp)
cmp    $0x1,%eax
sete   %r15b
mov    %r14,%rbx
mov    $0x1,%r14b
mov    %r13,0x18(%rsp)
mov    %rbx,0x20(%rsp)
xchg   %ax,%ax
cmpl   $0x0,0xc(%rsp)
js     12ef <load+0x14f>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1090 <rval@plt>
mov    %eax,%r12d
test   %eax,%eax
js     12fe <load+0x15e>
test   $0x1,%r14b
je     125d <load+0xbd>
mov    %r13,%rdi
call   1080 <varstr_pack@plt>
mov    %rax,%rbp
test   %rax,%rax
je     137e <load+0x1de>
mov    %rbx,%rdi
call   1080 <varstr_pack@plt>
test   %rax,%rax
je     137e <load+0x1de>
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r15d,%edx
call   1060 <store_kv@plt>
xor    %eax,%eax
call   1040 <varstr_init@plt>
mov    %rax,%rbx
cmp    $0x1,%r12d
jne    12a0 <load+0x100>
xor    %r13d,%r13d
mov    $0x0,%r14d
test   %rbx,%rbx
jne    1220 <load+0x80>
jmp    12b8 <load+0x118>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <varstr_init@plt>
test   %rbx,%rbx
je     12b8 <load+0x118>
mov    %rax,%r14
test   %rax,%rax
jne    11f0 <load+0x50>
lea    0xd56(%rip),%rdi
jmp    1397 <load+0x1f7>
mov    0x2d0d(%rip),%rax
mov    (%rax),%rcx
mov    0x2cf3(%rip),%rdx
mov    $0x2,%eax
cmp    (%rdx),%rcx
je     13a1 <load+0x201>
lea    0xd16(%rip),%rdi
jmp    1397 <load+0x1f7>
mov    0x18(%rsp),%r13
mov    0x20(%rsp),%rbx
mov    0xc(%rsp),%r12d
cmp    $0xfffffffd,%r12d
je     1321 <load+0x181>
cmp    $0xfffffffe,%r12d
jne    1387 <load+0x1e7>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
call   10a0 <fwprintf@plt>
jmp    139c <load+0x1fc>
mov    0x10(%rsp),%rdi
call   1050 <ferror@plt>
test   %rax,%rax
jne    1390 <load+0x1f0>
cmpl   $0x0,0xc(%rsp)
js     1365 <load+0x1c5>
mov    %r13,%rdi
call   1080 <varstr_pack@plt>
test   %rax,%rax
je     137e <load+0x1de>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1080 <varstr_pack@plt>
test   %rax,%rax
je     137e <load+0x1de>
mov    %rbp,%rdi
mov    %rax,%rsi
mov    0xc(%rsp),%edx
call   1060 <store_kv@plt>
jmp    137a <load+0x1da>
test   %r13,%r13
je     1372 <load+0x1d2>
mov    %r13,%rdi
call   1030 <varstr_free@plt>
mov    %rbx,%rdi
call   1030 <varstr_free@plt>
xor    %eax,%eax
jmp    13a1 <load+0x201>
lea    0xcc6(%rip),%rdi
jmp    1397 <load+0x1f7>
lea    0xcd8(%rip),%rdi
jmp    1397 <load+0x1f7>
lea    0xc99(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.varstr = type { i32 }
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [21 x i8] c"load(): opening file\00"
@.str.2 = [27 x i8] c"load(): varstr_init failed\00"
@stderr = global i32 0
@.str.3 = [28 x i32] [i32 108, i32 111, i32 97, i32 100, i32 40, i32 41, i32 58, i32 32, i32 100, i32 97, i32 116, i32 97, i32 98, i32 97, i32 115, i32 101, i32 32, i32 99, i32 111, i32 114, i32 114, i32 117, i32 112, i32 116, i32 101, i32 100, i32 10, i32 0]
@.str.4 = [27 x i8] c"load(): error reading file\00"
@.str.5 = [27 x i8] c"load(): varstr_pack failed\00"
@.str.6 = [23 x i8] c"load(): internal error\00"
define i32 @load(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.varstr*
%6 = alloca %struct.varstr*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %3
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %1
%17 = load i64, i64* @errno
%18 = load i64, i64* @ENOENT
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 2, i32* %2
br label %136
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %136
23: ; preds = %1
store %struct.varstr* null, %struct.varstr** %5
store %struct.varstr* null, %struct.varstr** %6
store i32* null, i32** %7
store i32* null, i32** %8
store i32 -1, i32* %9
store i32 0, i32* %10
store i32 -1, i32* %11
br label %24
24: ; preds = %122, %23
%25 = call %struct.varstr* (...) @varstr_init()
store %struct.varstr* %25, %struct.varstr** %5
%26 = call %struct.varstr* (...) @varstr_init()
store %struct.varstr* %26, %struct.varstr** %6
%27 = load %struct.varstr*, %struct.varstr** %5
%28 = icmp eq %struct.varstr* %27, null
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load %struct.varstr*, %struct.varstr** %6
%31 = icmp eq %struct.varstr* %30, null
br i1 %31, label %32, label %34
32: ; preds = %29, %24
%33 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %136
34: ; preds = %29
store i32 0, i32* %10
%35 = load i32*, i32** %4
%36 = load %struct.varstr*, %struct.varstr** %5
%37 = call i32 @rkey(i32* %35, %struct.varstr* %36)
store i32 %37, i32* %11
br label %38
38: ; preds = %120, %34
%39 = load i32, i32* %11
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32*, i32** %4
%43 = load %struct.varstr*, %struct.varstr** %6
%44 = call i32 @rval(i32* %42, %struct.varstr* %43)
store i32 %44, i32* %9
br label %45
45: ; preds = %41, %38
%46 = load i32, i32* %11
%47 = icmp slt i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %9
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %92
51: ; preds = %48, %45
%52 = load i32, i32* %11
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load i32, i32* %11
store i32 %55, i32* %9
br label %56
56: ; preds = %54, %51
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, -2
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* @stderr
%61 = call i32 @fwprintf(i32 %60, i8* bitcast ([28 x i32]* @.str.3 to i8*))
store i32 1, i32* %2
br label %136
62: ; preds = %56
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, -3
br i1 %64, label %65, label %90
65: ; preds = %62
%66 = load i32*, i32** %4
%67 = call i64 @ferror(i32* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %136
71: ; preds = %65
%72 = load i32, i32* %11
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %71
br label %123
75: ; preds = %71
%76 = load %struct.varstr*, %struct.varstr** %5
%77 = call i32* @varstr_pack(%struct.varstr* %76)
store i32* %77, i32** %7
%78 = icmp eq i32* %77, null
br i1 %78, label %83, label %79
79: ; preds = %75
%80 = load %struct.varstr*, %struct.varstr** %6
%81 = call i32* @varstr_pack(%struct.varstr* %80)
store i32* %81, i32** %8
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %85
83: ; preds = %79, %75
%84 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %136
85: ; preds = %79
store %struct.varstr* null, %struct.varstr** %6
store %struct.varstr* null, %struct.varstr** %5
%86 = load i32*, i32** %7
%87 = load i32*, i32** %8
%88 = load i32, i32* %11
%89 = call i32 @store_kv(i32* %86, i32* %87, i32 %88)
br label %123
90: ; preds = %62
%91 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %136
92: ; preds = %48
%93 = load i32, i32* %10
%94 = icmp ne i32 %93, 0
br i1 %94, label %99, label %95
95: ; preds = %92
%96 = load %struct.varstr*, %struct.varstr** %5
%97 = call i32* @varstr_pack(%struct.varstr* %96)
store i32* %97, i32** %7
%98 = icmp eq i32* %97, null
br i1 %98, label %103, label %99
99: ; preds = %95, %92
%100 = load %struct.varstr*, %struct.varstr** %6
%101 = call i32* @varstr_pack(%struct.varstr* %100)
store i32* %101, i32** %8
%102 = icmp eq i32* %101, null
br i1 %102, label %103, label %105
103: ; preds = %99, %95
%104 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %136
105: ; preds = %99
store %struct.varstr* null, %struct.varstr** %6
store %struct.varstr* null, %struct.varstr** %5
%106 = load i32*, i32** %7
%107 = load i32*, i32** %8
%108 = load i32, i32* %11
%109 = icmp eq i32 %108, 1
%110 = zext i1 %109 to i64
%111 = select i1 %109, i32 1, i32 0
%112 = call i32 @store_kv(i32* %106, i32* %107, i32 %111)
%113 = load i32, i32* %9
%114 = icmp eq i32 %113, 1
br i1 %114, label %115, label %121
115: ; preds = %105
%116 = call %struct.varstr* (...) @varstr_init()
store %struct.varstr* %116, %struct.varstr** %6
%117 = icmp eq %struct.varstr* %116, null
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %2
br label %136
120: ; preds = %115
store i32 1, i32* %10
br label %38
121: ; preds = %105
br label %122
122: ; preds = %121
br i1 true, label %24, label %123
123: ; preds = %122, %85, %74
%124 = load %struct.varstr*, %struct.varstr** %5
%125 = icmp ne %struct.varstr* %124, null
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load %struct.varstr*, %struct.varstr** %5
%128 = call i32 @varstr_free(%struct.varstr* %127)
br label %129
129: ; preds = %126, %123
%130 = load %struct.varstr*, %struct.varstr** %6
%131 = icmp ne %struct.varstr* %130, null
br i1 %131, label %132, label %135
132: ; preds = %129
%133 = load %struct.varstr*, %struct.varstr** %6
%134 = call i32 @varstr_free(%struct.varstr* %133)
br label %135
135: ; preds = %132, %129
store i32 0, i32* %2
br label %136
136: ; preds = %135, %118, %103, %90, %83, %69, %59, %32, %21, %20
%137 = load i32, i32* %2
ret i32 %137
}

LLVM IR (-O2):
%struct.varstr = type { i32 }
@.str = [2 x i8] c"r\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [21 x i8] c"load(): opening file\00"
@.str.2 = [27 x i8] c"load(): varstr_init failed\00"
@stderr = global i32 0
@.str.3 = [28 x i32] [i32 108, i32 111, i32 97, i32 100, i32 40, i32 41, i32 58, i32 32, i32 100, i32 97, i32 116, i32 97, i32 98, i32 97, i32 115, i32 101, i32 32, i32 99, i32 111, i32 114, i32 114, i32 117, i32 112, i32 116, i32 101, i32 100, i32 10, i32 0]
@.str.4 = [27 x i8] c"load(): error reading file\00"
@.str.5 = [27 x i8] c"load(): varstr_pack failed\00"
@.str.6 = [23 x i8] c"load(): internal error\00"
define i32 @load(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call %struct.varstr* (...) @varstr_init()
%6 = tail call %struct.varstr* (...) @varstr_init()
%7 = icmp eq %struct.varstr* %5, null
%8 = icmp eq %struct.varstr* %6, null
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %21, label %23
10: ; preds = %1
%11 = load i64, i64* @errno
%12 = load i64, i64* @ENOENT
%13 = icmp eq i64 %11, %12
br i1 %13, label %88, label %14
14: ; preds = %10
%15 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %88
16: ; preds = %72
%17 = tail call %struct.varstr* (...) @varstr_init()
%18 = icmp eq %struct.varstr* %75, null
%19 = icmp eq %struct.varstr* %17, null
%20 = select i1 %18, i1 true, i1 %19
br i1 %20, label %21, label %23
21: ; preds = %16, %4
%22 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %88
23: ; preds = %4, %16
%24 = phi %struct.varstr* [ %17, %16 ], [ %6, %4 ]
%25 = phi %struct.varstr* [ %75, %16 ], [ %5, %4 ]
%26 = phi i32* [ %67, %16 ], [ null, %4 ]
%27 = tail call i32 @rkey(i32* %2, %struct.varstr* %25)
%28 = icmp sgt i32 %27, -1
%29 = icmp eq i32 %27, 1
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %76, %23
%32 = phi %struct.varstr* [ %25, %23 ], [ null, %76 ]
%33 = phi %struct.varstr* [ %24, %23 ], [ %75, %76 ]
%34 = phi i32* [ %26, %23 ], [ %67, %76 ]
%35 = phi i1 [ true, %23 ], [ false, %76 ]
br i1 %28, label %36, label %39
36: ; preds = %31
%37 = tail call i32 @rval(i32* %2, %struct.varstr* %33)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %62
39: ; preds = %31, %36
%40 = phi %struct.varstr* [ %25, %31 ], [ %32, %36 ]
%41 = phi %struct.varstr* [ %24, %31 ], [ %33, %36 ]
%42 = phi i32 [ %27, %31 ], [ %37, %36 ]
switch i32 %42, label %60 [
i32 -2, label %43
i32 -3, label %46
]
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = tail call i32 @fwprintf(i32 %44, i8* bitcast ([28 x i32]* @.str.3 to i8*))
br label %88
46: ; preds = %39
%47 = tail call i64 @ferror(i32* %2)
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %88
51: ; preds = %46
br i1 %28, label %52, label %80
52: ; preds = %51
%53 = tail call i32* @varstr_pack(%struct.varstr* %40)
%54 = icmp eq i32* %53, null
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = tail call i32* @varstr_pack(%struct.varstr* %41)
%57 = icmp eq i32* %56, null
br i1 %57, label %58, label %84
58: ; preds = %55, %52
%59 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %88
60: ; preds = %39
%61 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %88
62: ; preds = %36
br i1 %35, label %63, label %66
63: ; preds = %62
%64 = tail call i32* @varstr_pack(%struct.varstr* %32)
%65 = icmp eq i32* %64, null
br i1 %65, label %70, label %66
66: ; preds = %63, %62
%67 = phi i32* [ %34, %62 ], [ %64, %63 ]
%68 = tail call i32* @varstr_pack(%struct.varstr* %33)
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %72
70: ; preds = %66, %63
%71 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %88
72: ; preds = %66
%73 = tail call i32 @store_kv(i32* %67, i32* %68, i32 %30)
%74 = icmp eq i32 %37, 1
%75 = tail call %struct.varstr* (...) @varstr_init()
br i1 %74, label %76, label %16
76: ; preds = %72
%77 = icmp eq %struct.varstr* %75, null
br i1 %77, label %78, label %31
78: ; preds = %76
%79 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %88
80: ; preds = %51
%81 = icmp eq %struct.varstr* %40, null
br i1 %81, label %86, label %82
82: ; preds = %80
%83 = tail call i32 @varstr_free(%struct.varstr* %40)
br label %86
84: ; preds = %55
%85 = tail call i32 @store_kv(i32* %53, i32* %56, i32 %27)
br label %88
86: ; preds = %82, %80
%87 = tail call i32 @varstr_free(%struct.varstr* %41)
br label %88
88: ; preds = %84, %21, %43, %49, %58, %60, %70, %78, %86, %10, %14
%89 = phi i32 [ 1, %14 ], [ 2, %10 ], [ 1, %21 ], [ 1, %43 ], [ 1, %49 ], [ 1, %58 ], [ 1, %60 ], [ 1, %70 ], [ 1, %78 ], [ 0, %86 ], [ 0, %84 ]
ret i32 %89
}