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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ nosqlite_close(struct nosqlite *);
int nosqlite_get(struct nosqlite *, char *, int, char *, int *);
struct nosqlite *nosqlite_open(char *, int);
scalar_t__ nosqlite_size(struct nosqlite *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  int rv;
  struct nosqlite *db = NULL;
  FILE *file = NULL;
  int i, c, n, capacity, checkvalue;
  char(*keys)[32] = NULL, *p = NULL, *k = NULL, *v = NULL;
  char(*values)[512] = NULL, value[512];
  char line[32 + 512];
  int klen, vlen;
  struct timeval starttime, endtime;
  if (argc <= 4) {
    fprintf(stderr, "usage: %s sample.dict sample.db capacity checkvalue\n",
            argv[0]);
    fprintf(stderr, "\n");
    fprintf(stderr, "    1. the default max key length is %dB\n", 32);
    fprintf(stderr, "    2. the default max value length is %dB\n", 512);
    fprintf(stderr, "    3. capacity: larger capacity need more memory, "
                    "smaller capacity cause lower performance\n");
    fprintf(stderr, "    4. checkvalue: 0 or 1, means check value or not\n");
    goto end;
  }
  checkvalue = atoi(argv[4]);
  file = fopen(argv[1], "r");
  if (!file) {
    fprintf(stderr, "failed to open: %s\n", argv[1]);
    goto end;
  }
  for (n = 0; c != EOF;) {
    c = fgetc(file);
    if (c == '\n') {
      n++;
    }
  }
  keys = (char(*)[32])malloc(32 * n);
  values = (char(*)[512])malloc(512 * n);
  fseek(file, 0, SEEK_SET);
  for (i = 0; i < n; ++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);
    }
    strcpy(keys[i], k);
    strcpy(values[i], v);
  }
  n = i;
  gettimeofday(&starttime, NULL);
  db = nosqlite_open(argv[2], atoi(argv[3]));
  if (!db) {
    fprintf(stderr, "failed to open: %s\n", argv[2]);
    goto end;
  }
  gettimeofday(&endtime, NULL);
  printf("load: %dms\n", (int)((endtime.tv_sec - starttime.tv_sec) * 1000 +
                               (endtime.tv_usec - starttime.tv_usec) / 1000));
  gettimeofday(&starttime, NULL);
  for (i = 0; i < n; ++i) {
    klen = (int)strlen(keys[i]);
    vlen = (int)sizeof(value);
    rv = nosqlite_get(db, keys[i], klen, value, &vlen);
    if (rv) {
      fprintf(stderr, "%s not found\n", keys[i]);
      goto end;
    }
    if (checkvalue == 1) {
      value[vlen] = '\0';
      if (strncmp(values[i], value, vlen) != 0) {
        fprintf(stderr,
                "warning: line %d, key: %s, expected value: \"%s\", actually: "
                "\"%s\"\n",
                i, keys[i], values[i], value);
      }
    }
  }
  gettimeofday(&endtime, NULL);
  printf("memory: %.1fMB\n", ((double)(nosqlite_size(db))) / 1024 / 1024);
  printf("qps: %.1f\n",
         n / ((double)(endtime.tv_sec - starttime.tv_sec) +
              (endtime.tv_usec - starttime.tv_usec) / 1000000.0));
end:
  if (file) {
    fclose(file);
  }
  if (db) {
    nosqlite_close(db);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
cmpl   $0x4,-0x8(%rbp)
jg     131b <main+0xfb>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd7e(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xf6e(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
mov    $0x20,%edx
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
mov    $0x200,%edx
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf3(%rip),%rsi
call   1130 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1372 <main+0x152>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%eax
mov    0x2c65(%rip),%rcx
cmp    (%rcx),%eax
je     13af <main+0x18f>
mov    -0x28(%rbp),%rdi
call   10c0 <fgetc@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xa,-0x30(%rbp)
jne    13aa <main+0x18a>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1379 <main+0x159>
mov    -0x34(%rbp),%edi
shl    $0x5,%edi
call   1100 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x34(%rbp),%edi
shl    $0x9,%edi
call   1100 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2bf8(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1110 <fseek@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    15e2 <main+0x3c2>
lea    -0x490(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x220,%esi
call   10e0 <fgets@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    141d <main+0x1fd>
jmp    15e2 <main+0x3c2>
lea    -0x490(%rbp),%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1444 <main+0x224>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x490(%rbp),%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     146b <main+0x24b>
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x490(%rbp),%rdi
mov    $0x9,%esi
call   1080 <strchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    14a0 <main+0x280>
lea    -0x490(%rbp),%rdi
mov    $0x20,%esi
call   1080 <strchr@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
lea    -0x490(%rbp),%rcx
cmp    %rcx,%rax
jne    14d3 <main+0x2b3>
mov    0x2b1d(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc7c(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
cmpq   $0x0,-0x50(%rbp)
jne    14fd <main+0x2dd>
mov    0x2af3(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
lea    -0x490(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1543 <main+0x323>
mov    -0x60(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x4a9(%rbp)
jne    1556 <main+0x336>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x4a9(%rbp)
mov    -0x4a9(%rbp),%al
test   $0x1,%al
jne    1569 <main+0x349>
jmp    157a <main+0x35a>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    151b <main+0x2fb>
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    15a4 <main+0x384>
mov    0x2a47(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xc0b(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    -0x48(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
add    %rax,%rdi
mov    -0x58(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x68(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x9,%rax
add    %rax,%rdi
mov    -0x60(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13e8 <main+0x1c8>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x4a0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x4b8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1140 <atoi@plt>
mov    -0x4b8(%rbp),%rdi
mov    %eax,%esi
call   10b0 <nosqlite_open@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1655 <main+0x435>
mov    0x29a0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xae6(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
lea    -0x4a8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
mov    -0x4a8(%rbp),%eax
sub    -0x4a0(%rbp),%eax
imul   $0x3e8,%eax,%esi
mov    -0x4a4(%rbp),%eax
sub    -0x49c(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
add    %eax,%esi
lea    0xb2a(%rip),%rdi
call   1090 <printf@plt>
lea    -0x4a0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    17df <main+0x5bf>
mov    -0x48(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
add    %rax,%rdi
call   1070 <strlen@plt>
mov    %eax,-0x494(%rbp)
movl   $0x200,-0x498(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
add    %rax,%rsi
mov    -0x494(%rbp),%edx
lea    -0x270(%rbp),%rcx
lea    -0x498(%rbp),%r8
call   1060 <nosqlite_get@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1744 <main+0x524>
mov    0x28b8(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rdx
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
add    %rax,%rdx
lea    0xa92(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    186e <main+0x64e>
cmpl   $0x1,-0x3c(%rbp)
jne    17cc <main+0x5ac>
movslq -0x498(%rbp),%rax
movb   $0x0,-0x270(%rbp,%rax,1)
mov    -0x68(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x9,%rax
add    %rax,%rdi
lea    -0x270(%rbp),%rsi
mov    -0x498(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     17c7 <main+0x5a7>
mov    0x2849(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x48(%rbp),%rcx
movslq -0x2c(%rbp),%rax
shl    $0x5,%rax
add    %rax,%rcx
mov    -0x68(%rbp),%r8
movslq -0x2c(%rbp),%rax
shl    $0x9,%rax
add    %rax,%r8
lea    -0x270(%rbp),%r9
lea    0xa18(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
jmp    17cc <main+0x5ac>
jmp    17d1 <main+0x5b1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    16b0 <main+0x490>
lea    -0x4a8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
mov    -0x20(%rbp),%rdi
call   1120 <nosqlite_size@plt>
cvtsi2sd %rax,%xmm0
movsd  0x803(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0x7f7(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0x9f9(%rip),%rdi
call   1090 <printf@plt>
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x4a8(%rbp),%eax
sub    -0x4a0(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x4a4(%rbp),%eax
sub    -0x49c(%rbp),%eax
cvtsi2sd %eax,%xmm2
movsd  0x7ae(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0x9c0(%rip),%rdi
call   1090 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1882 <main+0x662>
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     1896 <main+0x676>
mov    -0x20(%rbp),%rdi
call   10d0 <nosqlite_close@plt>
xor    %eax,%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x468,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jg     12b8 <main+0x98>
mov    0x2d98(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%rbx),%rdx
lea    0xdc3(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xfb9(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdd6(%rip),%rsi
mov    $0x20,%edx
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xdea(%rip),%rsi
mov    $0x200,%edx
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe00(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    16d2 <main+0x4b2>
mov    0x20(%rbx),%rdi
call   1140 <atoi@plt>
mov    %eax,0x34(%rsp)
mov    0x8(%rbx),%rdi
lea    0xe5d(%rip),%rsi
call   1130 <fopen@plt>
test   %rax,%rax
je     1458 <main+0x238>
mov    %rax,%rbp
mov    %rbx,0x38(%rsp)
xor    %r15d,%r15d
mov    0x2cf8(%rip),%rbx
mov    %rbp,%rdi
call   10c0 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%r15d
cmp    (%rbx),%eax
jne    12f0 <main+0xd0>
mov    %r15d,%edi
shl    $0x5,%edi
call   1100 <malloc@plt>
mov    %rax,%rbx
mov    %r15d,%edi
shl    $0x9,%edi
call   1100 <malloc@plt>
mov    %rax,0x28(%rsp)
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
xor    %r12d,%r12d
mov    %rbp,%rdi
xor    %esi,%esi
call   1110 <fseek@plt>
test   %r15d,%r15d
mov    %rbp,0x18(%rsp)
je     14b1 <main+0x291>
mov    %r15d,%eax
mov    %rax,0x20(%rsp)
lea    0x240(%rsp),%r14
xor    %r12d,%r12d
jmp    1398 <main+0x178>
xchg   %ax,%ax
mov    %r12,%rdi
shl    $0x5,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
shl    $0x9,%rdi
add    %rbp,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
add    $0x1,%r12
cmp    0x20(%rsp),%r12
mov    0x18(%rsp),%rbp
je     14ae <main+0x28e>
mov    %r14,%rdi
mov    $0x220,%esi
mov    %rbp,%rdx
call   10e0 <fgets@plt>
test   %rax,%rax
je     14b1 <main+0x291>
mov    %r14,%rdi
mov    $0xd,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     13c6 <main+0x1a6>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <strchr@plt>
test   %rax,%rax
mov    0x28(%rsp),%rbp
je     13e0 <main+0x1c0>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    $0x9,%esi
call   1080 <strchr@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1405 <main+0x1e5>
mov    %r14,%rdi
mov    $0x20,%esi
call   1080 <strchr@plt>
mov    %rax,%r13
cmp    %r14,%r13
je     1478 <main+0x258>
test   %r13,%r13
je     148a <main+0x26a>
movb   $0x0,0x0(%r13)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r13
movzbl 0x0(%r13),%eax
cmp    $0x9,%al
je     1420 <main+0x200>
cmp    $0x20,%al
je     1420 <main+0x200>
test   %al,%al
jne    1360 <main+0x140>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
lea    0xd5f(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    1360 <main+0x140>
mov    0x2b79(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xcc3(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    16d2 <main+0x4b2>
mov    0x2b59(%rip),%rax
mov    (%rax),%edi
lea    0xcbb(%rip),%rsi
jmp    149a <main+0x27a>
mov    0x2b47(%rip),%rax
mov    (%rax),%edi
lea    0xcd0(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x18(%rsp),%rbp
jmp    169c <main+0x47c>
mov    %r15d,%r12d
mov    %rbx,%r13
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    0x38(%rsp),%r15
mov    0x10(%r15),%r14
mov    0x18(%r15),%rdi
call   1140 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10b0 <nosqlite_open@plt>
test   %rax,%rax
je     1681 <main+0x461>
mov    %rax,%rbx
mov    %rsp,%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
imul   $0x3e8,%eax,%eax
sub    0xc(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rsi
add    %ecx,%esi
add    %eax,%esi
lea    0xc97(%rip),%rdi
call   1090 <printf@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
test   %r12d,%r12d
je     1606 <main+0x3e6>
mov    %r13,%rbp
mov    %r12d,%eax
mov    %rax,0x20(%rsp)
xor    %r14d,%r14d
jmp    1582 <main+0x362>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    %r15,%rbp
add    $0x20,%rbp
add    $0x200,%r13
mov    %r13,0x28(%rsp)
cmp    %r14,0x20(%rsp)
je     1606 <main+0x3e6>
mov    %rbp,%rdi
call   1070 <strlen@plt>
movl   $0x200,0x14(%rsp)
mov    %rbx,%rdi
mov    %rbp,%r15
mov    %rbp,%rsi
mov    %eax,%edx
lea    0x40(%rsp),%rcx
lea    0x14(%rsp),%r8
call   1060 <nosqlite_get@plt>
test   %eax,%eax
jne    16a6 <main+0x486>
cmpl   $0x1,0x34(%rsp)
mov    0x28(%rsp),%r13
jne    1560 <main+0x340>
movslq 0x14(%rsp),%rdx
movb   $0x0,0x40(%rsp,%rdx,1)
mov    %r13,%rdi
lea    0x40(%rsp),%rsi
call   1030 <strncmp@plt>
test   %rax,%rax
je     1560 <main+0x340>
mov    0x29f5(%rip),%rax
mov    (%rax),%edi
lea    0xbec(%rip),%rsi
mov    %r14d,%edx
mov    %r15,%rcx
mov    %r13,%r8
lea    0x40(%rsp),%r9
xor    %eax,%eax
call   10f0 <fprintf@plt>
jmp    1560 <main+0x340>
mov    %rsp,%rdi
xor    %esi,%esi
call   10a0 <gettimeofday@plt>
mov    %rbx,%rdi
call   1120 <nosqlite_size@plt>
cvtsi2sd %rax,%xmm0
movsd  0x9db(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xbe1(%rip),%rdi
call   1090 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
sub    0x8(%rsp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
sub    0xc(%rsp),%ecx
cvtsi2sd %ecx,%xmm2
divsd  0x9a1(%rip),%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%esi
lea    0xbaf(%rip),%rdi
call   1090 <printf@plt>
jmp    16c0 <main+0x4a0>
mov    0x2950(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r15),%rdx
lea    0xa9a(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
jmp    16d2 <main+0x4b2>
mov    0x292b(%rip),%rax
mov    (%rax),%edi
lea    0xb14(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   10d0 <nosqlite_close@plt>
xor    %eax,%eax
add    $0x468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.nosqlite = type { i32 }
%struct.timeval = type { i32, i32 }
@stderr = global i32 0
@.str = [53 x i8] c"usage: %s sample.dict sample.db capacity checkvalue\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c" 1. the default max key length is %dB\0A\00"
@.str.3 = [44 x i8] c" 2. the default max value length is %dB\0A\00"
@.str.4 = [93 x i8] c" 3. capacity: larger capacity need more memory, smaller capacity cause lower performance\0A\00"
@.str.5 = [53 x i8] c" 4. checkvalue: 0 or 1, means check value or not\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [20 x i8] c"failed to open: %s\0A\00"
@EOF = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [39 x i8] c"error: line %d starts with whitespace\0A\00"
@.str.9 = [62 x i8] c"error: line %d has no key value pair separated by whitespace\0A\00"
@.str.10 = [22 x i8] c"line %d has no value\0A\00"
@.str.11 = [12 x i8] c"load: %dms\0A\00"
@.str.12 = [14 x i8] c"%s not found\0A\00"
@.str.13 = [65 x i8] c"warning: line %d, key: %s, expected value: \22%s\22, actually: \22%s\22\0A\00"
@.str.14 = [16 x i8] c"memory: %.1fMB\0A\00"
@.str.15 = [11 x i8] c"qps: %.1f\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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [32 x i8]*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca [512 x i8]*
%19 = alloca [512 x i8]
%20 = alloca [544 x i8]
%21 = alloca i32
%22 = alloca i32
%23 = alloca %struct.timeval
%24 = alloca %struct.timeval
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 [32 x i8]* null, [32 x i8]** %14
store i8* null, i8** %15
store i8* null, i8** %16
store i8* null, i8** %17
store [512 x i8]* null, [512 x i8]** %18
%25 = load i32, i32* %4
%26 = icmp sle i32 %25, 4
br i1 %26, label %27, label %43
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 32)
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 512)
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
br label %317
43: ; preds = %2
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 4
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %13
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %51, i32** %8
%52 = load i32*, i32** %8
%53 = icmp ne i32* %52, null
br i1 %53, label %60, label %54
54: ; preds = %43
%55 = load i32, i32* @stderr
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %58)
br label %317
60: ; preds = %43
store i32 0, i32* %11
br label %61
61: ; preds = %73, %60
%62 = load i32, i32* %10
%63 = load i32, i32* @EOF
%64 = icmp ne i32 %62, %63
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load i32*, i32** %8
%67 = call i32 @fgetc(i32* %66)
store i32 %67, i32* %10
%68 = load i32, i32* %10
%69 = icmp eq i32 %68, 10
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %73
73: ; preds = %70, %65
br label %61
74: ; preds = %61
%75 = load i32, i32* %11
%76 = mul nsw i32 32, %75
%77 = call i64 @malloc(i32 %76)
%78 = inttoptr i64 %77 to [32 x i8]*
store [32 x i8]* %78, [32 x i8]** %14
%79 = load i32, i32* %11
%80 = mul nsw i32 512, %79
%81 = call i64 @malloc(i32 %80)
%82 = inttoptr i64 %81 to [512 x i8]*
store [512 x i8]* %82, [512 x i8]** %18
%83 = load i32*, i32** %8
%84 = load i32, i32* @SEEK_SET
%85 = call i32 @fseek(i32* %83, i32 0, i32 %84)
store i32 0, i32* %9
br label %86
86: ; preds = %183, %74
%87 = load i32, i32* %9
%88 = load i32, i32* %11
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %186
90: ; preds = %86
%91 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%92 = load i32*, i32** %8
%93 = call i8* @fgets(i8* %91, i32 544, i32* %92)
store i8* %93, i8** %15
%94 = load i8*, i8** %15
%95 = icmp ne i8* %94, null
br i1 %95, label %97, label %96
96: ; preds = %90
br label %186
97: ; preds = %90
%98 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%99 = call i8* @strchr(i8* %98, i8 signext 13)
store i8* %99, i8** %15
%100 = load i8*, i8** %15
%101 = icmp ne i8* %100, null
br i1 %101, label %102, label %104
102: ; preds = %97
%103 = load i8*, i8** %15
store i8 0, i8* %103
br label %104
104: ; preds = %102, %97
%105 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%106 = call i8* @strchr(i8* %105, i8 signext 10)
store i8* %106, i8** %15
%107 = load i8*, i8** %15
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %111
109: ; preds = %104
%110 = load i8*, i8** %15
store i8 0, i8* %110
br label %111
111: ; preds = %109, %104
%112 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%113 = call i8* @strchr(i8* %112, i8 signext 9)
store i8* %113, i8** %15
%114 = load i8*, i8** %15
%115 = icmp ne i8* %114, null
br i1 %115, label %119, label %116
116: ; preds = %111
%117 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%118 = call i8* @strchr(i8* %117, i8 signext 32)
store i8* %118, i8** %15
br label %119
119: ; preds = %116, %111
%120 = load i8*, i8** %15
%121 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
%122 = icmp eq i8* %120, %121
br i1 %122, label %123, label %127
123: ; preds = %119
%124 = load i32, i32* @stderr
%125 = load i32, i32* %9
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %125)
br label %317
127: ; preds = %119
%128 = load i8*, i8** %15
%129 = icmp ne i8* %128, null
br i1 %129, label %134, label %130
130: ; preds = %127
%131 = load i32, i32* @stderr
%132 = load i32, i32* %9
%133 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 %132)
br label %317
134: ; preds = %127
%135 = getelementptr inbounds [544 x i8], [544 x i8]* %20, i64 0, i64 0
store i8* %135, i8** %16
%136 = load i8*, i8** %15
store i8 0, i8* %136
%137 = load i8*, i8** %15
%138 = getelementptr inbounds i8, i8* %137, i64 1
store i8* %138, i8** %17
br label %139
139: ; preds = %156, %134
%140 = load i8*, i8** %17
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
%143 = icmp eq i32 %142, 32
br i1 %143, label %149, label %144
144: ; preds = %139
%145 = load i8*, i8** %17
%146 = load i8, i8* %145
%147 = sext i8 %146 to i32
%148 = icmp eq i32 %147, 9
br i1 %148, label %149, label %154
149: ; preds = %144, %139
%150 = load i8*, i8** %17
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = icmp ne i32 %152, 0
br label %154
154: ; preds = %149, %144
%155 = phi i1 [ false, %144 ], [ %153, %149 ]
br i1 %155, label %156, label %159
156: ; preds = %154
%157 = load i8*, i8** %17
%158 = getelementptr inbounds i8, i8* %157, i32 1
store i8* %158, i8** %17
br label %139
159: ; preds = %154
%160 = load i8*, i8** %17
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = icmp eq i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %159
%165 = load i32, i32* @stderr
%166 = load i32, i32* %9
%167 = call i32 (i32, i8*, ...) @fprintf(i32 %165, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %166)
br label %168
168: ; preds = %164, %159
%169 = load [32 x i8]*, [32 x i8]** %14
%170 = load i32, i32* %9
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds [32 x i8], [32 x i8]* %169, i64 %171
%173 = getelementptr inbounds [32 x i8], [32 x i8]* %172, i64 0, i64 0
%174 = load i8*, i8** %16
%175 = call i32 @strcpy(i8* %173, i8* %174)
%176 = load [512 x i8]*, [512 x i8]** %18
%177 = load i32, i32* %9
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [512 x i8], [512 x i8]* %176, i64 %178
%180 = getelementptr inbounds [512 x i8], [512 x i8]* %179, i64 0, i64 0
%181 = load i8*, i8** %17
%182 = call i32 @strcpy(i8* %180, i8* %181)
br label %183
183: ; preds = %168
%184 = load i32, i32* %9
%185 = add nsw i32 %184, 1
store i32 %185, i32* %9
br label %86
186: ; preds = %96, %86
%187 = load i32, i32* %9
store i32 %187, i32* %11
%188 = call i32 @gettimeofday(%struct.timeval* %23, i32* null)
%189 = load i8**, i8*** %5
%190 = getelementptr inbounds i8*, i8** %189, i64 2
%191 = load i8*, i8** %190
%192 = load i8**, i8*** %5
%193 = getelementptr inbounds i8*, i8** %192, i64 3
%194 = load i8*, i8** %193
%195 = call i32 @atoi(i8* %194)
%196 = call %struct.nosqlite* @nosqlite_open(i8* %191, i32 %195)
store %struct.nosqlite* %196, %struct.nosqlite** %7
%197 = load %struct.nosqlite*, %struct.nosqlite** %7
%198 = icmp ne %struct.nosqlite* %197, null
br i1 %198, label %205, label %199
199: ; preds = %186
%200 = load i32, i32* @stderr
%201 = load i8**, i8*** %5
%202 = getelementptr inbounds i8*, i8** %201, i64 2
%203 = load i8*, i8** %202
%204 = call i32 (i32, i8*, ...) @fprintf(i32 %200, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %203)
br label %317
205: ; preds = %186
%206 = call i32 @gettimeofday(%struct.timeval* %24, i32* null)
%207 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 0
%208 = load i32, i32* %207
%209 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
%210 = load i32, i32* %209
%211 = sub nsw i32 %208, %210
%212 = mul nsw i32 %211, 1000
%213 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%214 = load i32, i32* %213
%215 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
%216 = load i32, i32* %215
%217 = sub nsw i32 %214, %216
%218 = sdiv i32 %217, 1000
%219 = add nsw i32 %212, %218
%220 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %219)
%221 = call i32 @gettimeofday(%struct.timeval* %23, i32* null)
store i32 0, i32* %9
br label %222
222: ; preds = %286, %205
%223 = load i32, i32* %9
%224 = load i32, i32* %11
%225 = icmp slt i32 %223, %224
br i1 %225, label %226, label %289
226: ; preds = %222
%227 = load [32 x i8]*, [32 x i8]** %14
%228 = load i32, i32* %9
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds [32 x i8], [32 x i8]* %227, i64 %229
%231 = getelementptr inbounds [32 x i8], [32 x i8]* %230, i64 0, i64 0
%232 = call i64 @strlen(i8* %231)
%233 = trunc i64 %232 to i32
store i32 %233, i32* %21
store i32 512, i32* %22
%234 = load %struct.nosqlite*, %struct.nosqlite** %7
%235 = load [32 x i8]*, [32 x i8]** %14
%236 = load i32, i32* %9
%237 = sext i32 %236 to i64
%238 = getelementptr inbounds [32 x i8], [32 x i8]* %235, i64 %237
%239 = getelementptr inbounds [32 x i8], [32 x i8]* %238, i64 0, i64 0
%240 = load i32, i32* %21
%241 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%242 = call i32 @nosqlite_get(%struct.nosqlite* %234, i8* %239, i32 %240, i8* %241, i32* %22)
store i32 %242, i32* %6
%243 = load i32, i32* %6
%244 = icmp ne i32 %243, 0
br i1 %244, label %245, label %253
245: ; preds = %226
%246 = load i32, i32* @stderr
%247 = load [32 x i8]*, [32 x i8]** %14
%248 = load i32, i32* %9
%249 = sext i32 %248 to i64
%250 = getelementptr inbounds [32 x i8], [32 x i8]* %247, i64 %249
%251 = getelementptr inbounds [32 x i8], [32 x i8]* %250, i64 0, i64 0
%252 = call i32 (i32, i8*, ...) @fprintf(i32 %246, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %251)
br label %317
253: ; preds = %226
%254 = load i32, i32* %13
%255 = icmp eq i32 %254, 1
br i1 %255, label %256, label %285
256: ; preds = %253
%257 = load i32, i32* %22
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 %258
store i8 0, i8* %259
%260 = load [512 x i8]*, [512 x i8]** %18
%261 = load i32, i32* %9
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds [512 x i8], [512 x i8]* %260, i64 %262
%264 = getelementptr inbounds [512 x i8], [512 x i8]* %263, i64 0, i64 0
%265 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%266 = load i32, i32* %22
%267 = call i64 @strncmp(i8* %264, i8* %265, i32 %266)
%268 = icmp ne i64 %267, 0
br i1 %268, label %269, label %284
269: ; preds = %256
%270 = load i32, i32* @stderr
%271 = load i32, i32* %9
%272 = load [32 x i8]*, [32 x i8]** %14
%273 = load i32, i32* %9
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds [32 x i8], [32 x i8]* %272, i64 %274
%276 = getelementptr inbounds [32 x i8], [32 x i8]* %275, i64 0, i64 0
%277 = load [512 x i8]*, [512 x i8]** %18
%278 = load i32, i32* %9
%279 = sext i32 %278 to i64
%280 = getelementptr inbounds [512 x i8], [512 x i8]* %277, i64 %279
%281 = getelementptr inbounds [512 x i8], [512 x i8]* %280, i64 0, i64 0
%282 = getelementptr inbounds [512 x i8], [512 x i8]* %19, i64 0, i64 0
%283 = call i32 (i32, i8*, ...) @fprintf(i32 %270, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0), i32 %271, i8* %276, i8* %281, i8* %282)
br label %284
284: ; preds = %269, %256
br label %285
285: ; preds = %284, %253
br label %286
286: ; preds = %285
%287 = load i32, i32* %9
%288 = add nsw i32 %287, 1
store i32 %288, i32* %9
br label %222
289: ; preds = %222
%290 = call i32 @gettimeofday(%struct.timeval* %24, i32* null)
%291 = load %struct.nosqlite*, %struct.nosqlite** %7
%292 = call i64 @nosqlite_size(%struct.nosqlite* %291)
%293 = sitofp i64 %292 to double
%294 = fdiv double %293, 1.024000e+03
%295 = fdiv double %294, 1.024000e+03
%296 = fptosi double %295 to i32
%297 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i32 %296)
%298 = load i32, i32* %11
%299 = sitofp i32 %298 to double
%300 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 0
%301 = load i32, i32* %300
%302 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 0
%303 = load i32, i32* %302
%304 = sub nsw i32 %301, %303
%305 = sitofp i32 %304 to double
%306 = getelementptr inbounds %struct.timeval, %struct.timeval* %24, i32 0, i32 1
%307 = load i32, i32* %306
%308 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
%309 = load i32, i32* %308
%310 = sub nsw i32 %307, %309
%311 = sitofp i32 %310 to double
%312 = fdiv double %311, 1.000000e+06
%313 = fadd double %305, %312
%314 = fdiv double %299, %313
%315 = fptosi double %314 to i32
%316 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %315)
br label %317
317: ; preds = %289, %245, %199, %130, %123, %54, %27
%318 = load i32*, i32** %8
%319 = icmp ne i32* %318, null
br i1 %319, label %320, label %323
320: ; preds = %317
%321 = load i32*, i32** %8
%322 = call i32 @fclose(i32* %321)
br label %323
323: ; preds = %320, %317
%324 = load %struct.nosqlite*, %struct.nosqlite** %7
%325 = icmp ne %struct.nosqlite* %324, null
br i1 %325, label %326, label %329
326: ; preds = %323
%327 = load %struct.nosqlite*, %struct.nosqlite** %7
%328 = call i32 @nosqlite_close(%struct.nosqlite* %327)
br label %329
329: ; preds = %326, %323
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.nosqlite = type { i32 }
@stderr = global i32 0
@.str = [53 x i8] c"usage: %s sample.dict sample.db capacity checkvalue\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [42 x i8] c" 1. the default max key length is %dB\0A\00"
@.str.3 = [44 x i8] c" 2. the default max value length is %dB\0A\00"
@.str.4 = [93 x i8] c" 3. capacity: larger capacity need more memory, smaller capacity cause lower performance\0A\00"
@.str.5 = [53 x i8] c" 4. checkvalue: 0 or 1, means check value or not\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [20 x i8] c"failed to open: %s\0A\00"
@EOF = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [39 x i8] c"error: line %d starts with whitespace\0A\00"
@.str.9 = [62 x i8] c"error: line %d has no key value pair separated by whitespace\0A\00"
@.str.10 = [22 x i8] c"line %d has no value\0A\00"
@.str.11 = [12 x i8] c"load: %dms\0A\00"
@.str.12 = [14 x i8] c"%s not found\0A\00"
@.str.13 = [65 x i8] c"warning: line %d, key: %s, expected value: \22%s\22, actually: \22%s\22\0A\00"
@.str.14 = [16 x i8] c"memory: %.1fMB\0A\00"
@.str.15 = [11 x i8] c"qps: %.1f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [544 x i8]
%5 = alloca i32
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [544 x i8], [544 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = bitcast %struct.timeval* %6 to i8*
%12 = bitcast %struct.timeval* %7 to i8*
%13 = icmp slt i32 %0, 5
br i1 %13, label %14, label %28
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32 32)
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 512)
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.5, i64 0, i64 0))
br label %196
28: ; preds = %2
%29 = getelementptr inbounds i8*, i8** %1, i64 4
%30 = load i8*, i8** %29
%31 = tail call i32 @atoi(i8* %30)
%32 = getelementptr inbounds i8*, i8** %1, i64 1
%33 = load i8*, i8** %32
%34 = tail call i32* @fopen(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i8*, i8** %32
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %38)
br label %196
40: ; preds = %28, %40
%41 = phi i32 [ %45, %40 ], [ 0, %28 ]
%42 = tail call i32 @fgetc(i32* %34)
%43 = icmp eq i32 %42, 10
%44 = zext i1 %43 to i32
%45 = add nuw nsw i32 %41, %44
%46 = load i32, i32* @EOF
%47 = icmp eq i32 %42, %46
br i1 %47, label %48, label %40
48: ; preds = %40
%49 = shl nsw i32 %45, 5
%50 = tail call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to [32 x i8]*
%52 = shl nsw i32 %45, 9
%53 = tail call i64 @malloc(i32 %52)
%54 = inttoptr i64 %53 to [512 x i8]*
%55 = load i32, i32* @SEEK_SET
%56 = tail call i32 @fseek(i32* %34, i32 0, i32 %55)
%57 = icmp eq i32 %45, 0
br i1 %57, label %109, label %58
58: ; preds = %48
%59 = zext i32 %45 to i64
br label %60
60: ; preds = %58, %100
%61 = phi i64 [ 0, %58 ], [ %105, %100 ]
%62 = call i8* @fgets(i8* %9, i32 544, i32* %34)
%63 = icmp eq i8* %62, null
%64 = trunc i64 %61 to i32
br i1 %63, label %107, label %65
65: ; preds = %60
%66 = call i8* @strchr(i8* %9, i8 signext 13)
%67 = icmp eq i8* %66, null
br i1 %67, label %69, label %68
68: ; preds = %65
store i8 0, i8* %66
br label %69
69: ; preds = %68, %65
%70 = call i8* @strchr(i8* %9, i8 signext 10)
%71 = icmp eq i8* %70, null
br i1 %71, label %73, label %72
72: ; preds = %69
store i8 0, i8* %70
br label %73
73: ; preds = %72, %69
%74 = call i8* @strchr(i8* %9, i8 signext 9)
%75 = icmp eq i8* %74, null
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i8* @strchr(i8* %9, i8 signext 32)
br label %78
78: ; preds = %76, %73
%79 = phi i8* [ %74, %73 ], [ %77, %76 ]
%80 = icmp eq i8* %79, %9
br i1 %80, label %81, label %85
81: ; preds = %78
%82 = trunc i64 %61 to i32
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i32 %82)
br label %191
85: ; preds = %78
%86 = icmp eq i8* %79, null
br i1 %86, label %87, label %91
87: ; preds = %85
%88 = trunc i64 %61 to i32
%89 = load i32, i32* @stderr
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.9, i64 0, i64 0), i32 %88)
br label %191
91: ; preds = %85
store i8 0, i8* %79
br label %92
92: ; preds = %96, %91
%93 = phi i8* [ %79, %91 ], [ %94, %96 ]
%94 = getelementptr inbounds i8, i8* %93, i64 1
%95 = load i8, i8* %94
switch i8 %95, label %100 [
i8 32, label %96
i8 9, label %96
i8 0, label %97
]
96: ; preds = %92, %92
br label %92
97: ; preds = %92
%98 = load i32, i32* @stderr
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0), i32 %64)
br label %100
100: ; preds = %92, %97
%101 = getelementptr inbounds [32 x i8], [32 x i8]* %51, i64 %61, i64 0
%102 = call i32 @strcpy(i8* %101, i8* %9)
%103 = getelementptr inbounds [512 x i8], [512 x i8]* %54, i64 %61, i64 0
%104 = call i32 @strcpy(i8* %103, i8* %94)
%105 = add nuw nsw i64 %61, 1
%106 = icmp eq i64 %105, %59
br i1 %106, label %109, label %60
107: ; preds = %60
%108 = trunc i64 %61 to i32
br label %109
109: ; preds = %100, %107, %48
%110 = phi i32 [ 0, %48 ], [ %108, %107 ], [ %45, %100 ]
%111 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%112 = getelementptr inbounds i8*, i8** %1, i64 2
%113 = load i8*, i8** %112
%114 = getelementptr inbounds i8*, i8** %1, i64 3
%115 = load i8*, i8** %114
%116 = call i32 @atoi(i8* %115)
%117 = call %struct.nosqlite* @nosqlite_open(i8* %113, i32 %116)
%118 = icmp eq %struct.nosqlite* %117, null
br i1 %118, label %119, label %123
119: ; preds = %109
%120 = load i32, i32* @stderr
%121 = load i8*, i8** %112
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i8* %121)
br label %191
123: ; preds = %109
%124 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%125 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%126 = load i32, i32* %125
%127 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%128 = load i32, i32* %127
%129 = sub nsw i32 %126, %128
%130 = mul nsw i32 %129, 1000
%131 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%132 = load i32, i32* %131
%133 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%134 = load i32, i32* %133
%135 = sub nsw i32 %132, %134
%136 = sdiv i32 %135, 1000
%137 = add nsw i32 %136, %130
%138 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i32 %137)
%139 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%140 = icmp eq i32 %110, 0
br i1 %140, label %169, label %141
141: ; preds = %123
%142 = icmp eq i32 %31, 1
%143 = zext i32 %110 to i64
br label %144
144: ; preds = %141, %166
%145 = phi i64 [ 0, %141 ], [ %167, %166 ]
%146 = getelementptr inbounds [32 x i8], [32 x i8]* %51, i64 %145, i64 0
%147 = call i64 @strlen(i8* dereferenceable(1) %146)
%148 = trunc i64 %147 to i32
store i32 512, i32* %5
%149 = call i32 @nosqlite_get(%struct.nosqlite* %117, i8* %146, i32 %148, i8* %8, i32* %5)
%150 = icmp eq i32 %149, 0
br i1 %150, label %154, label %151
151: ; preds = %144
%152 = load i32, i32* @stderr
%153 = call i32 (i32, i8*, ...) @fprintf(i32 %152, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %146)
br label %193
154: ; preds = %144
br i1 %142, label %155, label %166
155: ; preds = %154
%156 = load i32, i32* %5
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %157
store i8 0, i8* %158
%159 = getelementptr inbounds [512 x i8], [512 x i8]* %54, i64 %145, i64 0
%160 = call i64 @strncmp(i8* %159, i8* %8, i32 %156)
%161 = icmp eq i64 %160, 0
br i1 %161, label %166, label %162
162: ; preds = %155
%163 = load i32, i32* @stderr
%164 = trunc i64 %145 to i32
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.13, i64 0, i64 0), i32 %164, i8* %146, i8* %159, i8* %8)
br label %166
166: ; preds = %154, %162, %155
%167 = add nuw nsw i64 %145, 1
%168 = icmp eq i64 %167, %143
br i1 %168, label %169, label %144
169: ; preds = %166, %123
%170 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%171 = call i64 @nosqlite_size(%struct.nosqlite* %117)
%172 = sitofp i64 %171 to double
%173 = fmul double %172, 0x3F50000000000000
%174 = fmul double %173, 0x3F50000000000000
%175 = fptosi double %174 to i32
%176 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i32 %175)
%177 = sitofp i32 %110 to double
%178 = load i32, i32* %125
%179 = load i32, i32* %127
%180 = sub nsw i32 %178, %179
%181 = sitofp i32 %180 to double
%182 = load i32, i32* %131
%183 = load i32, i32* %133
%184 = sub nsw i32 %182, %183
%185 = sitofp i32 %184 to double
%186 = fdiv double %185, 1.000000e+06
%187 = fadd double %186, %181
%188 = fdiv double %177, %187
%189 = fptosi double %188 to i32
%190 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0), i32 %189)
br label %193
191: ; preds = %81, %87, %119
%192 = call i32 @fclose(i32* %34)
br label %196
193: ; preds = %151, %169
%194 = call i32 @fclose(i32* %34)
%195 = call i32 @nosqlite_close(%struct.nosqlite* %117)
br label %196
196: ; preds = %191, %14, %36, %193
ret i32 0
}