#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 nosqlite {
  int dummy;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ nosqlite_close(struct nosqlite *);
struct nosqlite *nosqlite_open(char *, int);
int nosqlite_set(struct nosqlite *, char *, int /*<<< orphan*/, char *,
                 int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  int rv;
  struct nosqlite *db = NULL;
  FILE *file = NULL;
  int i = 0;
  char line[512], *p = NULL, *k = NULL, *v = NULL;
  int klen, vlen;
  if (argc <= 2) {
    fprintf(stderr,
            "usage: %s sample.dict sample.db (the default max line length is "
            "%dB)\n",
            argv[0], 512);
    goto end;
  }
  file = fopen(argv[2], "r");
  if (file) {
    fprintf(stderr, "error: %s exists, please remove it manuallay\n", argv[2]);
    goto end;
  }
  file = fopen(argv[1], "r");
  if (!file) {
    fprintf(stderr, "failed to open: %s\n", argv[1]);
    goto end;
  }
  db = nosqlite_open(argv[2], 300000);
  if (!db) {
    fprintf(stderr, "failed to open: %s\n", argv[2]);
    goto end;
  }
  for (i = 0;; i++) {
    p = fgets(line, sizeof(line), file);
    if (!p) {
      break;
    }
    p = strchr(line, '\r');
    if (p) {
      *p = '\0';
    }
    p = strchr(line, '\n');
    if (p) {
      *p = '\0';
    }
    p = strchr(line, '\t');
    if (!p) {
      p = strchr(line, ' ');
    }
    if (p == line) {
      fprintf(stderr, "error: line %d starts with whitespace\n", i);
      goto end;
    }
    if (!p) {
      fprintf(stderr,
              "error: line %d has no key value pair separated by whitespace\n",
              i);
      goto end;
    }
    k = line;
    *p = '\0';
    v = p + 1;
    while ((*v == ' ' || *v == '\t') && *v != '\0') {
      v++;
    }
    if (*v == '\0') {
      fprintf(stderr, "line %d has no value\n", i);
    }
    rv = nosqlite_set(db, k, strlen(k), v, strlen(v));
    if (rv == -1) {
      goto end;
    }
  }
  printf("convert %s to %s ok\n", argv[1], argv[2]);
  printf("please do run './benchmark %s %s N 1' to check it, and select a "
         "right capacity value(N)\n",
         argv[1], argv[2]);
end:
  if (file) {
    fclose(file);
  }
  if (db) {
    nosqlite_close(db);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x238(%rbp)
movq   $0x0,-0x240(%rbp)
movq   $0x0,-0x248(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     1223 <main+0x83>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdee(%rip),%rsi
mov    $0x200,%ecx
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe14(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     126a <main+0xca>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdcd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b1 <main+0x111>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x493e0,%esi
call   1070 <nosqlite_open@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12f6 <main+0x156>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
movl   $0x0,-0x2c(%rbp)
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
jne    132c <main+0x18c>
jmp    157f <main+0x3df>
lea    -0x230(%rbp),%rdi
mov    $0xd,%esi
call   1050 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
je     135c <main+0x1bc>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x230(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
je     138c <main+0x1ec>
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x230(%rbp),%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x238(%rbp)
cmpq   $0x0,-0x238(%rbp)
jne    13ca <main+0x22a>
lea    -0x230(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rax
lea    -0x230(%rbp),%rcx
cmp    %rcx,%rax
jne    1400 <main+0x260>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc96(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
cmpq   $0x0,-0x238(%rbp)
jne    142d <main+0x28d>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc90(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    15b7 <main+0x417>
lea    -0x230(%rbp),%rax
mov    %rax,-0x240(%rbp)
mov    -0x238(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x238(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x248(%rbp)
mov    -0x248(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1485 <main+0x2e5>
mov    -0x248(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x251(%rbp)
jne    149b <main+0x2fb>
mov    -0x248(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x251(%rbp)
mov    -0x251(%rbp),%al
test   $0x1,%al
jne    14ae <main+0x30e>
jmp    14c5 <main+0x325>
mov    -0x248(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x248(%rbp)
jmp    1457 <main+0x2b7>
mov    -0x248(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    14f2 <main+0x352>
mov    0x2b01(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc04(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x278(%rbp)
mov    -0x240(%rbp),%rax
mov    %rax,-0x270(%rbp)
mov    -0x240(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x264(%rbp)
mov    -0x248(%rbp),%rax
mov    %rax,-0x260(%rbp)
mov    -0x248(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x278(%rbp),%rdi
mov    -0x270(%rbp),%rsi
mov    -0x264(%rbp),%edx
mov    -0x260(%rbp),%rcx
mov    %eax,%r8d
call   10b0 <nosqlite_set@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    156c <main+0x3cc>
jmp    15b7 <main+0x417>
jmp    1571 <main+0x3d1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12fd <main+0x15d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xb6f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xb68(%rip),%rdi
call   1060 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     15cb <main+0x42b>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     15df <main+0x43f>
mov    -0x20(%rbp),%rdi
call   1080 <nosqlite_close@plt>
xor    %eax,%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     11da <main+0x3a>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe34(%rip),%rsi
mov    $0x200,%ecx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1215 <main+0x75>
mov    0x10(%rbx),%rdi
lea    0xe61(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1229 <main+0x89>
mov    %rax,%r14
lea    0xe4f(%rip),%rsi
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdi
lea    0xe12(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     13a6 <main+0x206>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
mov    $0x493e0,%esi
call   1070 <nosqlite_open@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     13c6 <main+0x226>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     137c <main+0x1dc>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0xd,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12a5 <main+0x105>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     12ba <main+0x11a>
movb   $0x0,(%rax)
mov    %r12,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,%r13
test   %rax,%rax
jne    12df <main+0x13f>
mov    %r12,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,%r13
cmp    %r12,%r13
je     13d2 <main+0x232>
test   %r13,%r13
je     13e4 <main+0x244>
movb   $0x0,0x0(%r13)
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r13
movzbl 0x0(%r13),%eax
cmp    $0x9,%al
je     1300 <main+0x160>
cmp    $0x20,%al
je     1300 <main+0x160>
test   %al,%al
jne    132e <main+0x18e>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    0x8(%rsp),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r13,%rcx
mov    %eax,%r8d
call   10b0 <nosqlite_set@plt>
cmp    $0xffffffff,%eax
je     13fd <main+0x25d>
add    $0x1,%ebp
mov    %r12,%rdi
mov    $0x200,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    1290 <main+0xf0>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xd7a(%rip),%rdi
call   1060 <printf@plt>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xd7b(%rip),%rdi
call   1060 <printf@plt>
jmp    13fd <main+0x25d>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xcbc(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1215 <main+0x75>
lea    0xca9(%rip),%rsi
jmp    11f9 <main+0x59>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
jmp    13f4 <main+0x254>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
lea    0xcbd(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1080 <nosqlite_close@plt>
jmp    1215 <main+0x75>

LLVM IR (-O0):
%struct.nosqlite = type { i32 }
@stderr = global i32 0
@.str = [70 x i8] c"usage: %s sample.dict sample.db (the default max line length is %dB)\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [46 x i8] c"error: %s exists, please remove it manuallay\0A\00"
@.str.3 = [20 x i8] c"failed to open: %s\0A\00"
@.str.4 = [39 x i8] c"error: line %d starts with whitespace\0A\00"
@.str.5 = [62 x i8] c"error: line %d has no key value pair separated by whitespace\0A\00"
@.str.6 = [22 x i8] c"line %d has no value\0A\00"
@.str.7 = [21 x i8] c"convert %s to %s ok\0A\00"
@.str.8 = [89 x i8] c"please do run './benchmark %s %s N 1' to check it, and select a right capacity value(N)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.nosqlite*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [512 x i8]
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.nosqlite* null, %struct.nosqlite** %7
store i32* null, i32** %8
store i32 0, i32* %9
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 2
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* %22, i32 512)
br label %173
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %8
%29 = load i32*, i32** %8
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %37
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* %35)
br label %173
37: ; preds = %24
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %8
%42 = load i32*, i32** %8
%43 = icmp ne i32* %42, null
br i1 %43, label %50, label %44
44: ; preds = %37
%45 = load i32, i32* @stderr
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %48)
br label %173
50: ; preds = %37
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call %struct.nosqlite* @nosqlite_open(i8* %53, i32 300000)
store %struct.nosqlite* %54, %struct.nosqlite** %7
%55 = load %struct.nosqlite*, %struct.nosqlite** %7
%56 = icmp ne %struct.nosqlite* %55, null
br i1 %56, label %63, label %57
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 2
%61 = load i8*, i8** %60
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %61)
br label %173
63: ; preds = %50
store i32 0, i32* %9
br label %64
64: ; preds = %155, %63
%65 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%66 = load i32*, i32** %8
%67 = call i8* @fgets(i8* %65, i32 512, i32* %66)
store i8* %67, i8** %11
%68 = load i8*, i8** %11
%69 = icmp ne i8* %68, null
br i1 %69, label %71, label %70
70: ; preds = %64
br label %158
71: ; preds = %64
%72 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%73 = call i8* @strchr(i8* %72, i8 signext 13)
store i8* %73, i8** %11
%74 = load i8*, i8** %11
%75 = icmp ne i8* %74, null
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = load i8*, i8** %11
store i8 0, i8* %77
br label %78
78: ; preds = %76, %71
%79 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%80 = call i8* @strchr(i8* %79, i8 signext 10)
store i8* %80, i8** %11
%81 = load i8*, i8** %11
%82 = icmp ne i8* %81, null
br i1 %82, label %83, label %85
83: ; preds = %78
%84 = load i8*, i8** %11
store i8 0, i8* %84
br label %85
85: ; preds = %83, %78
%86 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%87 = call i8* @strchr(i8* %86, i8 signext 9)
store i8* %87, i8** %11
%88 = load i8*, i8** %11
%89 = icmp ne i8* %88, null
br i1 %89, label %93, label %90
90: ; preds = %85
%91 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%92 = call i8* @strchr(i8* %91, i8 signext 32)
store i8* %92, i8** %11
br label %93
93: ; preds = %90, %85
%94 = load i8*, i8** %11
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%96 = icmp eq i8* %94, %95
br i1 %96, label %97, label %101
97: ; preds = %93
%98 = load i32, i32* @stderr
%99 = load i32, i32* %9
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %99)
br label %173
101: ; preds = %93
%102 = load i8*, i8** %11
%103 = icmp ne i8* %102, null
br i1 %103, label %108, label %104
104: ; preds = %101
%105 = load i32, i32* @stderr
%106 = load i32, i32* %9
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %106)
br label %173
108: ; preds = %101
%109 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
store i8* %109, i8** %12
%110 = load i8*, i8** %11
store i8 0, i8* %110
%111 = load i8*, i8** %11
%112 = getelementptr inbounds i8, i8* %111, i64 1
store i8* %112, i8** %13
br label %113
113: ; preds = %130, %108
%114 = load i8*, i8** %13
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 32
br i1 %117, label %123, label %118
118: ; preds = %113
%119 = load i8*, i8** %13
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 9
br i1 %122, label %123, label %128
123: ; preds = %118, %113
%124 = load i8*, i8** %13
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp ne i32 %126, 0
br label %128
128: ; preds = %123, %118
%129 = phi i1 [ false, %118 ], [ %127, %123 ]
br i1 %129, label %130, label %133
130: ; preds = %128
%131 = load i8*, i8** %13
%132 = getelementptr inbounds i8, i8* %131, i32 1
store i8* %132, i8** %13
br label %113
133: ; preds = %128
%134 = load i8*, i8** %13
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp eq i32 %136, 0
br i1 %137, label %138, label %142
138: ; preds = %133
%139 = load i32, i32* @stderr
%140 = load i32, i32* %9
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %140)
br label %142
142: ; preds = %138, %133
%143 = load %struct.nosqlite*, %struct.nosqlite** %7
%144 = load i8*, i8** %12
%145 = load i8*, i8** %12
%146 = call i32 @strlen(i8* %145)
%147 = load i8*, i8** %13
%148 = load i8*, i8** %13
%149 = call i32 @strlen(i8* %148)
%150 = call i32 @nosqlite_set(%struct.nosqlite* %143, i8* %144, i32 %146, i8* %147, i32 %149)
store i32 %150, i32* %6
%151 = load i32, i32* %6
%152 = icmp eq i32 %151, -1
br i1 %152, label %153, label %154
153: ; preds = %142
br label %173
154: ; preds = %142
br label %155
155: ; preds = %154
%156 = load i32, i32* %9
%157 = add nsw i32 %156, 1
store i32 %157, i32* %9
br label %64
158: ; preds = %70
%159 = load i8**, i8*** %5
%160 = getelementptr inbounds i8*, i8** %159, i64 1
%161 = load i8*, i8** %160
%162 = load i8**, i8*** %5
%163 = getelementptr inbounds i8*, i8** %162, i64 2
%164 = load i8*, i8** %163
%165 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %161, i8* %164)
%166 = load i8**, i8*** %5
%167 = getelementptr inbounds i8*, i8** %166, i64 1
%168 = load i8*, i8** %167
%169 = load i8**, i8*** %5
%170 = getelementptr inbounds i8*, i8** %169, i64 2
%171 = load i8*, i8** %170
%172 = call i32 @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.8, i64 0, i64 0), i8* %168, i8* %171)
br label %173
173: ; preds = %158, %153, %104, %97, %57, %44, %31, %18
%174 = load i32*, i32** %8
%175 = icmp ne i32* %174, null
br i1 %175, label %176, label %179
176: ; preds = %173
%177 = load i32*, i32** %8
%178 = call i32 @fclose(i32* %177)
br label %179
179: ; preds = %176, %173
%180 = load %struct.nosqlite*, %struct.nosqlite** %7
%181 = icmp ne %struct.nosqlite* %180, null
br i1 %181, label %182, label %185
182: ; preds = %179
%183 = load %struct.nosqlite*, %struct.nosqlite** %7
%184 = call i32 @nosqlite_close(%struct.nosqlite* %183)
br label %185
185: ; preds = %182, %179
ret i32 0
}

LLVM IR (-O2):
%struct.nosqlite = type { i32 }
@stderr = global i32 0
@.str = [70 x i8] c"usage: %s sample.dict sample.db (the default max line length is %dB)\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [46 x i8] c"error: %s exists, please remove it manuallay\0A\00"
@.str.3 = [20 x i8] c"failed to open: %s\0A\00"
@.str.4 = [39 x i8] c"error: line %d starts with whitespace\0A\00"
@.str.5 = [62 x i8] c"error: line %d has no key value pair separated by whitespace\0A\00"
@.str.6 = [22 x i8] c"line %d has no value\0A\00"
@.str.7 = [21 x i8] c"convert %s to %s ok\0A\00"
@.str.8 = [89 x i8] c"please do run './benchmark %s %s N 1' to check it, and select a right capacity value(N)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), i8* %8, i32 512)
br label %91
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %81
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %16
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %91
24: ; preds = %15
%25 = load i8*, i8** %11
%26 = tail call %struct.nosqlite* @nosqlite_open(i8* %25, i32 300000)
%27 = icmp eq %struct.nosqlite* %26, null
br i1 %27, label %81, label %28
28: ; preds = %24
%29 = call i8* @fgets(i8* %4, i32 512, i32* %18)
%30 = icmp eq i8* %29, null
br i1 %30, label %74, label %31
31: ; preds = %28, %70
%32 = phi i32 [ %71, %70 ], [ 0, %28 ]
%33 = call i8* @strchr(i8* %4, i8 signext 13)
%34 = icmp eq i8* %33, null
br i1 %34, label %36, label %35
35: ; preds = %31
store i8 0, i8* %33
br label %36
36: ; preds = %35, %31
%37 = call i8* @strchr(i8* %4, i8 signext 10)
%38 = icmp eq i8* %37, null
br i1 %38, label %40, label %39
39: ; preds = %36
store i8 0, i8* %37
br label %40
40: ; preds = %39, %36
%41 = call i8* @strchr(i8* %4, i8 signext 9)
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i8* @strchr(i8* %4, i8 signext 32)
br label %45
45: ; preds = %43, %40
%46 = phi i8* [ %41, %40 ], [ %44, %43 ]
%47 = icmp eq i8* %46, %4
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %88
51: ; preds = %45
%52 = icmp eq i8* %46, null
br i1 %52, label %53, label %56
53: ; preds = %51
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32 %32)
br label %88
56: ; preds = %51
store i8 0, i8* %46
br label %57
57: ; preds = %61, %56
%58 = phi i8* [ %46, %56 ], [ %59, %61 ]
%59 = getelementptr inbounds i8, i8* %58, i64 1
%60 = load i8, i8* %59
switch i8 %60, label %65 [
i8 32, label %61
i8 9, label %61
i8 0, label %62
]
61: ; preds = %57, %57
br label %57
62: ; preds = %57
%63 = load i32, i32* @stderr
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %32)
br label %65
65: ; preds = %57, %62
%66 = call i32 @strlen(i8* %4)
%67 = call i32 @strlen(i8* %59)
%68 = call i32 @nosqlite_set(%struct.nosqlite* %26, i8* %4, i32 %66, i8* %59, i32 %67)
%69 = icmp eq i32 %68, -1
br i1 %69, label %88, label %70
70: ; preds = %65
%71 = add nuw nsw i32 %32, 1
%72 = call i8* @fgets(i8* %4, i32 512, i32* %18)
%73 = icmp eq i8* %72, null
br i1 %73, label %74, label %31
74: ; preds = %70, %28
%75 = load i8*, i8** %16
%76 = load i8*, i8** %11
%77 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %75, i8* %76)
%78 = load i8*, i8** %16
%79 = load i8*, i8** %11
%80 = call i32 @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.8, i64 0, i64 0), i8* %78, i8* %79)
br label %88
81: ; preds = %24, %10
%82 = phi i8* [ getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), %24 ]
%83 = phi i32* [ %13, %10 ], [ %18, %24 ]
%84 = load i32, i32* @stderr
%85 = load i8*, i8** %11
%86 = tail call i32 (i32, i8*, ...) @fprintf(i32 %84, i8* %82, i8* %85)
%87 = call i32 @fclose(i32* %83)
br label %91
88: ; preds = %65, %48, %53, %74
%89 = call i32 @fclose(i32* %18)
%90 = call i32 @nosqlite_close(%struct.nosqlite* %26)
br label %91
91: ; preds = %81, %6, %20, %88
ret i32 0
}