#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int db_alloc(int, size_t);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ read32(int, int, int *);
scalar_t__ readcons(int, int, int *, int *);
char *readcstr(int, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
scalar_t__ write32(int, int, int);
scalar_t__ write8(int, int, char const);
scalar_t__ writecons(int, int, int, int);
uint32_t db_store(int dbfd, const char *name, uint8_t type, uint8_t *data) {
  if (!name) {
    fprintf(stderr, "persist: db_store: name==NULL\n");
    return (0);
  }
  size_t sz = 0;
  switch (type & 0xF0) {
  case 0x00:
    sz = 9;
    break;
  case 0x80:
    sz = 2;
    break;
  case 0x90:
    sz = 3;
    break;
  case 0xA0:
    sz = 5;
    break;
  case 0xB0:
    sz = 0;
    break;
  case 0xC0:
    sz = data ? strlen((const char *)data) + 2 : 2;
    break;
  case 0xF0:
    sz = 5;
    break;
  }
  if (!sz) {
    fprintf(stderr, "persist: db_store: unknown size\n");
    return (0);
  }
  uint32_t namehead;
  if (read32(dbfd, 4, &namehead)) {
    fprintf(stderr, "persist: db_store: failed to read namehead at 0x4\n");
    return (0);
  }
  uint32_t nameptr = namehead, namecar, namecdr, oldptr = 0;
  while (nameptr) {
    if (readcons(dbfd, nameptr, &namecar, &namecdr)) {
      fprintf(stderr,
              "persist: db_store: failed to read namelist cons at 0x%08x\n",
              nameptr);
      return (0);
    }
    uint32_t namecaar, namecdar;
    if (readcons(dbfd, namecar, &namecaar, &namecdar)) {
      fprintf(stderr,
              "persist: db_store: failed to read namelist entry at 0x%08x\n",
              namecar);
      return (0);
    }
    char *buf = readcstr(dbfd, namecaar);
    if (strcmp(name, buf) == 0) {
      free(buf);
      break;
    }
    free(buf);
    oldptr = nameptr;
    nameptr = namecdr;
  }
  if (namecar) {
  } else {
    uint32_t nameent = db_alloc(dbfd, 9);
    if (!nameent) {
      fprintf(stderr,
              "persist: db_store: failed to allocate space for new nameent\n");
      return (0);
    }
    if (!namehead) {
      if (write32(dbfd, 4, namehead = nameent)) {
        fprintf(stderr, "persist: db_store: failed to write namehead at 0x4\n");
        return (0);
      }
    } else if (!oldptr) {
      fprintf(stderr, "persist: db_store: internal error (oldptr==NULL)\n");
      return (0);
    } else {
      if (writecons(dbfd, oldptr, namecar, nameent)) {
        fprintf(stderr, "persist: db_store: failed to write to oldptr\n");
        return (0);
      }
    }
    if (!(namecar = db_alloc(dbfd, 9))) {
      fprintf(stderr,
              "persist: db_store: failed to allocate space for new namecar\n");
      return (0);
    }
    if (writecons(dbfd, nameent, namecar, 0)) {
      fprintf(stderr, "persist: db_store: failed to write to nameent\n");
      return (0);
    }
    uint32_t nameaddr = db_alloc(dbfd, strlen(name) + 1);
    if (!nameaddr) {
      fprintf(stderr, "persist: db_store: failed to allocate space for name\n");
      return (0);
    }
    size_t i = 0;
    do
      if (write8(dbfd, nameaddr + i, name[i])) {
        fprintf(stderr, "persist: db_store: failed to write out name\n");
        return (0);
      }
    while (name[i++]);
  }
  uint32_t addr = db_alloc(dbfd, sz);
  if (!addr) {
    fprintf(stderr, "persist: db_store: failed to allocate space for data\n");
    return (0);
  }
  if (write8(dbfd, addr, type)) {
    fprintf(stderr, "persist: db_store: failed to write out type\n");
    return (0);
  }
  for (size_t i = 1; i < sz; i++)
    if (write8(dbfd, addr + i, data[i - 1])) {
      fprintf(stderr, "persist: db_store: failed to write out data\n");
      return (0);
    }
  if (writecons(dbfd, namecar, namecar, 0)) {
    fprintf(stderr, "persist: db_store: failed to write to nameent\n");
    return (0);
  }
  return (addr);
}


x86 assembly (clang, -O0):
<db_store>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f7 <db_store+0x47>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
movq   $0x0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
and    $0xf0,%eax
mov    %eax,-0x74(%rbp)
je     1287 <db_store+0xd7>
jmp    1215 <db_store+0x65>
mov    -0x74(%rbp),%eax
sub    $0x80,%eax
je     1294 <db_store+0xe4>
jmp    1228 <db_store+0x78>
mov    -0x74(%rbp),%eax
sub    $0x90,%eax
je     12a1 <db_store+0xf1>
jmp    123b <db_store+0x8b>
mov    -0x74(%rbp),%eax
sub    $0xa0,%eax
je     12ae <db_store+0xfe>
jmp    124e <db_store+0x9e>
mov    -0x74(%rbp),%eax
sub    $0xb0,%eax
je     12bb <db_store+0x10b>
jmp    1261 <db_store+0xb1>
mov    -0x74(%rbp),%eax
sub    $0xc0,%eax
je     12c8 <db_store+0x118>
jmp    1274 <db_store+0xc4>
mov    -0x74(%rbp),%eax
sub    $0xf0,%eax
je     1302 <db_store+0x152>
jmp    130a <db_store+0x15a>
movq   $0x9,-0x28(%rbp)
jmp    130a <db_store+0x15a>
movq   $0x2,-0x28(%rbp)
jmp    130a <db_store+0x15a>
movq   $0x3,-0x28(%rbp)
jmp    130a <db_store+0x15a>
movq   $0x5,-0x28(%rbp)
jmp    130a <db_store+0x15a>
movq   $0x0,-0x28(%rbp)
jmp    130a <db_store+0x15a>
cmpq   $0x0,-0x20(%rbp)
je     12e7 <db_store+0x137>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x2,%eax
mov    %eax,-0x78(%rbp)
jmp    12f4 <db_store+0x144>
mov    $0x2,%eax
mov    %eax,-0x78(%rbp)
jmp    12f4 <db_store+0x144>
mov    -0x78(%rbp),%eax
cltq
mov    %rax,-0x28(%rbp)
jmp    130a <db_store+0x15a>
movq   $0x5,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1338 <db_store+0x188>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
lea    0xcfa(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
lea    -0x2c(%rbp),%rdx
call   10c0 <read32@plt>
cmp    $0x0,%rax
je     1376 <db_store+0x1c6>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1461 <db_store+0x2b1>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%esi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1090 <readcons@plt>
cmp    $0x0,%rax
je     13d0 <db_store+0x220>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xcb6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    -0x34(%rbp),%esi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rcx
call   1090 <readcons@plt>
cmp    $0x0,%rax
je     1413 <db_store+0x263>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xcae(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1060 <readcstr@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1447 <db_store+0x297>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    1461 <db_store+0x2b1>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1383 <db_store+0x1d3>
cmpl   $0x0,-0x34(%rbp)
je     1470 <db_store+0x2c0>
jmp    16b1 <db_store+0x501>
mov    -0x8(%rbp),%edi
mov    $0x9,%esi
call   10b0 <db_alloc@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    14ad <db_store+0x2fd>
mov    0x2b4f(%rip),%rax
mov    (%rax),%edi
lea    0xc50(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
cmpl   $0x0,-0x2c(%rbp)
jne    14fc <db_store+0x34c>
mov    -0x8(%rbp),%edi
mov    -0x54(%rbp),%edx
mov    %edx,-0x2c(%rbp)
mov    $0x4,%esi
call   1040 <write32@plt>
cmp    $0x0,%rax
je     14f7 <db_store+0x347>
mov    0x2b05(%rip),%rax
mov    (%rax),%edi
lea    0xc43(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
jmp    1571 <db_store+0x3c1>
cmpl   $0x0,-0x3c(%rbp)
jne    1529 <db_store+0x379>
mov    0x2ad3(%rip),%rax
mov    (%rax),%edi
lea    0xc45(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x54(%rbp),%ecx
call   10d0 <writecons@plt>
cmp    $0x0,%rax
je     1567 <db_store+0x3b7>
mov    0x2a95(%rip),%rax
mov    (%rax),%edi
lea    0xc39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
jmp    156c <db_store+0x3bc>
jmp    1571 <db_store+0x3c1>
mov    -0x8(%rbp),%edi
mov    $0x9,%esi
call   10b0 <db_alloc@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jne    15ad <db_store+0x3fd>
mov    0x2a4f(%rip),%rax
mov    (%rax),%edi
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x34(%rbp),%edx
xor    %ecx,%ecx
call   10d0 <writecons@plt>
cmp    $0x0,%rax
je     15ea <db_store+0x43a>
mov    0x2a12(%rip),%rax
mov    (%rax),%edi
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x7c(%rbp),%edi
add    $0x1,%eax
movslq %eax,%rsi
call   10b0 <db_alloc@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jne    1637 <db_store+0x487>
mov    0x29c5(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
movq   $0x0,-0x60(%rbp)
mov    -0x8(%rbp),%edi
movslq -0x58(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
call   10a0 <write8@plt>
cmp    $0x0,%rax
je     168a <db_store+0x4da>
mov    0x2972(%rip),%rax
mov    (%rax),%edi
lea    0xbe6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
jmp    168f <db_store+0x4df>
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x60(%rbp)
cmpb   $0x0,(%rax,%rcx,1)
jne    163f <db_store+0x48f>
jmp    16b1 <db_store+0x501>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   10b0 <db_alloc@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jne    16ed <db_store+0x53d>
mov    0x290f(%rip),%rax
mov    (%rax),%edi
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x8(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    -0x14(%rbp),%eax
movsbl %al,%edx
call   10a0 <write8@plt>
cmp    $0x0,%rax
je     172b <db_store+0x57b>
mov    0x28d1(%rip),%rax
mov    (%rax),%edi
lea    0xba8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
movq   $0x1,-0x70(%rbp)
mov    -0x70(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    17a8 <db_store+0x5f8>
mov    -0x8(%rbp),%edi
movslq -0x64(%rbp),%rax
add    -0x70(%rbp),%rax
mov    %eax,%esi
mov    -0x20(%rbp),%rax
mov    -0x70(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,4),%eax
movsbl %al,%edx
call   10a0 <write8@plt>
cmp    $0x0,%rax
je     1792 <db_store+0x5e2>
mov    0x286a(%rip),%rax
mov    (%rax),%edi
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
jmp    1797 <db_store+0x5e7>
mov    -0x70(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    1733 <db_store+0x583>
mov    -0x8(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x34(%rbp),%edx
xor    %ecx,%ecx
call   10d0 <writecons@plt>
cmp    $0x0,%rax
je     17e5 <db_store+0x635>
mov    0x2817(%rip),%rax
mov    (%rax),%edi
lea    0xa26(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17eb <db_store+0x63b>
mov    -0x64(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_store>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %rsi,%rsi
je     11fd <db_store+0x4d>
mov    %edx,%ebx
mov    %edx,%eax
shr    $0x4,%eax
and    $0xf,%eax
cmp    $0xf,%eax
ja     1312 <db_store+0x162>
mov    %rcx,%r14
mov    %rsi,%rbp
mov    %edi,%r12d
mov    $0x9,%r15d
lea    0xe14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x5,%r15d
jmp    123b <db_store+0x8b>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    $0x3,%r15d
jmp    123b <db_store+0x8b>
test   %r14,%r14
je     1235 <db_store+0x85>
mov    %r14,%rdi
call   1050 <strlen@plt>
add    $0x2,%eax
je     1312 <db_store+0x162>
movslq %eax,%r15
jmp    123b <db_store+0x8b>
mov    $0x2,%r15d
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
mov    $0x4,%esi
call   10c0 <read32@plt>
test   %rax,%rax
je     1267 <db_store+0xb7>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0xc(%rsp),%eax
test   %eax,%eax
mov    %r14,0x20(%rsp)
mov    %r15,0x28(%rsp)
mov    %rbp,0x18(%rsp)
je     1327 <db_store+0x177>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%r14d
mov    %r12d,%edi
mov    %eax,%esi
lea    0x8(%rsp),%rdx
lea    0x14(%rsp),%rcx
call   1090 <readcons@plt>
test   %rax,%rax
jne    1377 <db_store+0x1c7>
mov    0x8(%rsp),%esi
mov    %r12d,%edi
lea    0x10(%rsp),%rdx
lea    0x34(%rsp),%rcx
call   1090 <readcons@plt>
test   %rax,%rax
jne    13a4 <db_store+0x1f4>
mov    0x10(%rsp),%esi
mov    %r12d,%ebp
mov    %r12d,%edi
call   1060 <readcstr@plt>
mov    %rax,%r13
mov    0x18(%rsp),%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   1030 <free@plt>
test   %r12,%r12
je     13c7 <db_store+0x217>
mov    0x14(%rsp),%eax
mov    %r14d,%r15d
test   %eax,%eax
mov    %ebp,%r12d
jne    1290 <db_store+0xe0>
jmp    132a <db_store+0x17a>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
jmp    155e <db_store+0x3ae>
xor    %r14d,%r14d
cmpl   $0x0,0x8(%rsp)
je     13d8 <db_store+0x228>
mov    %r12d,%edi
mov    0x28(%rsp),%rbp
mov    %rbp,%rsi
call   10b0 <db_alloc@plt>
test   %eax,%eax
je     138f <db_store+0x1df>
mov    %eax,%r13d
movsbl %bl,%edx
mov    %r12d,%edi
mov    %eax,%esi
call   10a0 <write8@plt>
test   %rax,%rax
je     1434 <db_store+0x284>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
lea    0xf8e(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
xor    %r13d,%r13d
mov    %r14d,%edx
jmp    13bb <db_store+0x20b>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xf2b(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsp),%edx
lea    0xd36(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1568 <db_store+0x3b8>
mov    %r15d,%r14d
mov    %ebp,%r12d
cmpl   $0x0,0x8(%rsp)
jne    1335 <db_store+0x185>
mov    $0x9,%esi
mov    %r12d,%edi
call   10b0 <db_alloc@plt>
test   %eax,%eax
je     14ab <db_store+0x2fb>
mov    %eax,%r15d
cmpl   $0x0,0xc(%rsp)
je     14c0 <db_store+0x310>
test   %r14d,%r14d
je     152a <db_store+0x37a>
mov    0x8(%rsp),%edx
mov    %r12d,%edi
mov    %r14d,%esi
mov    %r15d,%ecx
call   10d0 <writecons@plt>
test   %rax,%rax
je     14ec <db_store+0x33c>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    %r12d,%ebx
cmp    $0x2,%rbp
mov    0x20(%rsp),%r15
jb     1474 <db_store+0x2c4>
mov    %rbp,%r12
add    $0xffffffffffffffff,%r12
mov    %r13d,%r14d
add    $0x1,%r14d
xor    %ebp,%ebp
lea    (%r14,%rbp,1),%esi
movsbl (%r15,%rbp,4),%edx
mov    %ebx,%edi
call   10a0 <write8@plt>
test   %rax,%rax
jne    153c <db_store+0x38c>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1452 <db_store+0x2a2>
mov    0x8(%rsp),%edx
mov    %ebx,%edi
mov    %edx,%esi
xor    %ecx,%ecx
call   10d0 <writecons@plt>
test   %rax,%rax
je     1568 <db_store+0x3b8>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %r13d,%r13d
jmp    1568 <db_store+0x3b8>
mov    0x2b2e(%rip),%rax
mov    (%rax),%edi
lea    0xc6f(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    %r15d,0xc(%rsp)
mov    %r12d,%edi
mov    $0x4,%esi
mov    %r15d,%edx
call   1040 <write32@plt>
test   %rax,%rax
je     14ec <db_store+0x33c>
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
lea    0xc7d(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    $0x9,%esi
mov    %r12d,%edi
call   10b0 <db_alloc@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
je     154e <db_store+0x39e>
xor    %r13d,%r13d
mov    %r12d,%edi
mov    %r15d,%esi
mov    %eax,%edx
xor    %ecx,%ecx
call   10d0 <writecons@plt>
test   %rax,%rax
je     157a <db_store+0x3ca>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
jmp    1561 <db_store+0x3b1>
mov    0x2aaf(%rip),%rax
mov    (%rax),%edi
lea    0xc61(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0x2a8b(%rip),%rax
mov    (%rax),%edi
lea    0xc9d(%rip),%rsi
xor    %r13d,%r13d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rsi
mov    %r12d,%edi
call   10b0 <db_alloc@plt>
test   %eax,%eax
je     15c3 <db_store+0x413>
mov    %eax,%r14d
movsbl 0x0(%rbp),%edx
mov    %r12d,%edi
mov    %r14d,%esi
call   10a0 <write8@plt>
test   %rax,%rax
jne    15d5 <db_store+0x425>
add    $0x1,%r14d
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    159c <db_store+0x3ec>
jmp    1335 <db_store+0x185>
mov    0x2a16(%rip),%rax
mov    (%rax),%edi
lea    0xc94(%rip),%rsi
jmp    155e <db_store+0x3ae>
mov    0x2a04(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
jmp    155e <db_store+0x3ae>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"persist: db_store: name==NULL\0A\00"
@.str.1 = [33 x i8] c"persist: db_store: unknown size\0A\00"
@.str.2 = [51 x i8] c"persist: db_store: failed to read namehead at 0x4\0A\00"
@.str.3 = [59 x i8] c"persist: db_store: failed to read namelist cons at 0x%08x\0A\00"
@.str.4 = [60 x i8] c"persist: db_store: failed to read namelist entry at 0x%08x\0A\00"
@.str.5 = [61 x i8] c"persist: db_store: failed to allocate space for new nameent\0A\00"
@.str.6 = [52 x i8] c"persist: db_store: failed to write namehead at 0x4\0A\00"
@.str.7 = [50 x i8] c"persist: db_store: internal error (oldptr==NULL)\0A\00"
@.str.8 = [46 x i8] c"persist: db_store: failed to write to oldptr\0A\00"
@.str.9 = [61 x i8] c"persist: db_store: failed to allocate space for new namecar\0A\00"
@.str.10 = [47 x i8] c"persist: db_store: failed to write to nameent\0A\00"
@.str.11 = [54 x i8] c"persist: db_store: failed to allocate space for name\0A\00"
@.str.12 = [45 x i8] c"persist: db_store: failed to write out name\0A\00"
@.str.13 = [54 x i8] c"persist: db_store: failed to allocate space for data\0A\00"
@.str.14 = [45 x i8] c"persist: db_store: failed to write out type\0A\00"
@.str.15 = [45 x i8] c"persist: db_store: failed to write out data\0A\00"
define i32 @db_store(i32 %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i64
%22 = alloca i32
%23 = alloca i64
store i32 %0, i32* %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %29, label %26
26: ; preds = %4
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %255
29: ; preds = %4
store i64 0, i64* %10
%30 = load i32, i32* %8
%31 = and i32 %30, 240
switch i32 %31, label %50 [
i32 0, label %32
i32 128, label %33
i32 144, label %34
i32 160, label %35
i32 176, label %36
i32 192, label %37
i32 240, label %49
]
32: ; preds = %29
store i64 9, i64* %10
br label %50
33: ; preds = %29
store i64 2, i64* %10
br label %50
34: ; preds = %29
store i64 3, i64* %10
br label %50
35: ; preds = %29
store i64 5, i64* %10
br label %50
36: ; preds = %29
store i64 0, i64* %10
br label %50
37: ; preds = %29
%38 = load i32*, i32** %9
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i32*, i32** %9
%42 = bitcast i32* %41 to i8*
%43 = call i32 @strlen(i8* %42)
%44 = add nsw i32 %43, 2
br label %46
45: ; preds = %37
br label %46
46: ; preds = %45, %40
%47 = phi i32 [ %44, %40 ], [ 2, %45 ]
%48 = sext i32 %47 to i64
store i64 %48, i64* %10
br label %50
49: ; preds = %29
store i64 5, i64* %10
br label %50
50: ; preds = %29, %49, %46, %36, %35, %34, %33, %32
%51 = load i64, i64* %10
%52 = icmp ne i64 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %50
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %255
56: ; preds = %50
%57 = load i32, i32* %6
%58 = call i64 @read32(i32 %57, i32 4, i32* %11)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %255
63: ; preds = %56
%64 = load i32, i32* %11
store i32 %64, i32* %12
store i32 0, i32* %15
br label %65
65: ; preds = %97, %63
%66 = load i32, i32* %12
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %102
68: ; preds = %65
%69 = load i32, i32* %6
%70 = load i32, i32* %12
%71 = call i64 @readcons(i32 %69, i32 %70, i32* %13, i32* %14)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = load i32, i32* %12
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %75)
store i32 0, i32* %5
br label %255
77: ; preds = %68
%78 = load i32, i32* %6
%79 = load i32, i32* %13
%80 = call i64 @readcons(i32 %78, i32 %79, i32* %16, i32* %17)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = load i32, i32* %13
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %84)
store i32 0, i32* %5
br label %255
86: ; preds = %77
%87 = load i32, i32* %6
%88 = load i32, i32* %16
%89 = call i8* @readcstr(i32 %87, i32 %88)
store i8* %89, i8** %18
%90 = load i8*, i8** %7
%91 = load i8*, i8** %18
%92 = call i64 @strcmp(i8* %90, i8* %91)
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %86
%95 = load i8*, i8** %18
%96 = call i32 @free(i8* %95)
br label %102
97: ; preds = %86
%98 = load i8*, i8** %18
%99 = call i32 @free(i8* %98)
%100 = load i32, i32* %12
store i32 %100, i32* %15
%101 = load i32, i32* %14
store i32 %101, i32* %12
br label %65
102: ; preds = %94, %65
%103 = load i32, i32* %13
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %102
br label %198
106: ; preds = %102
%107 = load i32, i32* %6
%108 = call i32 @db_alloc(i32 %107, i64 9)
store i32 %108, i32* %19
%109 = load i32, i32* %19
%110 = icmp ne i32 %109, 0
br i1 %110, label %114, label %111
111: ; preds = %106
%112 = load i32, i32* @stderr
%113 = call i32 (i32, i8*, ...) @fprintf(i32 %112, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %5
br label %255
114: ; preds = %106
%115 = load i32, i32* %11
%116 = icmp ne i32 %115, 0
br i1 %116, label %126, label %117
117: ; preds = %114
%118 = load i32, i32* %6
%119 = load i32, i32* %19
store i32 %119, i32* %11
%120 = call i64 @write32(i32 %118, i32 4, i32 %119)
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = load i32, i32* @stderr
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %5
br label %255
125: ; preds = %117
br label %144
126: ; preds = %114
%127 = load i32, i32* %15
%128 = icmp ne i32 %127, 0
br i1 %128, label %132, label %129
129: ; preds = %126
%130 = load i32, i32* @stderr
%131 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %5
br label %255
132: ; preds = %126
%133 = load i32, i32* %6
%134 = load i32, i32* %15
%135 = load i32, i32* %13
%136 = load i32, i32* %19
%137 = call i64 @writecons(i32 %133, i32 %134, i32 %135, i32 %136)
%138 = icmp ne i64 %137, 0
br i1 %138, label %139, label %142
139: ; preds = %132
%140 = load i32, i32* @stderr
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %5
br label %255
142: ; preds = %132
br label %143
143: ; preds = %142
br label %144
144: ; preds = %143, %125
%145 = load i32, i32* %6
%146 = call i32 @db_alloc(i32 %145, i64 9)
store i32 %146, i32* %13
%147 = icmp ne i32 %146, 0
br i1 %147, label %151, label %148
148: ; preds = %144
%149 = load i32, i32* @stderr
%150 = call i32 (i32, i8*, ...) @fprintf(i32 %149, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %5
br label %255
151: ; preds = %144
%152 = load i32, i32* %6
%153 = load i32, i32* %19
%154 = load i32, i32* %13
%155 = call i64 @writecons(i32 %152, i32 %153, i32 %154, i32 0)
%156 = icmp ne i64 %155, 0
br i1 %156, label %157, label %160
157: ; preds = %151
%158 = load i32, i32* @stderr
%159 = call i32 (i32, i8*, ...) @fprintf(i32 %158, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %5
br label %255
160: ; preds = %151
%161 = load i32, i32* %6
%162 = load i8*, i8** %7
%163 = call i32 @strlen(i8* %162)
%164 = add nsw i32 %163, 1
%165 = sext i32 %164 to i64
%166 = call i32 @db_alloc(i32 %161, i64 %165)
store i32 %166, i32* %20
%167 = load i32, i32* %20
%168 = icmp ne i32 %167, 0
br i1 %168, label %172, label %169
169: ; preds = %160
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %5
br label %255
172: ; preds = %160
store i64 0, i64* %21
br label %173
173: ; preds = %190, %172
%174 = load i32, i32* %6
%175 = load i32, i32* %20
%176 = sext i32 %175 to i64
%177 = load i64, i64* %21
%178 = add i64 %176, %177
%179 = trunc i64 %178 to i32
%180 = load i8*, i8** %7
%181 = load i64, i64* %21
%182 = getelementptr inbounds i8, i8* %180, i64 %181
%183 = load i8, i8* %182
%184 = call i64 @write8(i32 %174, i32 %179, i8 signext %183)
%185 = icmp ne i64 %184, 0
br i1 %185, label %186, label %189
186: ; preds = %173
%187 = load i32, i32* @stderr
%188 = call i32 (i32, i8*, ...) @fprintf(i32 %187, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %5
br label %255
189: ; preds = %173
br label %190
190: ; preds = %189
%191 = load i8*, i8** %7
%192 = load i64, i64* %21
%193 = add i64 %192, 1
store i64 %193, i64* %21
%194 = getelementptr inbounds i8, i8* %191, i64 %192
%195 = load i8, i8* %194
%196 = icmp ne i8 %195, 0
br i1 %196, label %173, label %197
197: ; preds = %190
br label %198
198: ; preds = %197, %105
%199 = load i32, i32* %6
%200 = load i64, i64* %10
%201 = call i32 @db_alloc(i32 %199, i64 %200)
store i32 %201, i32* %22
%202 = load i32, i32* %22
%203 = icmp ne i32 %202, 0
br i1 %203, label %207, label %204
204: ; preds = %198
%205 = load i32, i32* @stderr
%206 = call i32 (i32, i8*, ...) @fprintf(i32 %205, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %5
br label %255
207: ; preds = %198
%208 = load i32, i32* %6
%209 = load i32, i32* %22
%210 = load i32, i32* %8
%211 = trunc i32 %210 to i8
%212 = call i64 @write8(i32 %208, i32 %209, i8 signext %211)
%213 = icmp ne i64 %212, 0
br i1 %213, label %214, label %217
214: ; preds = %207
%215 = load i32, i32* @stderr
%216 = call i32 (i32, i8*, ...) @fprintf(i32 %215, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %5
br label %255
217: ; preds = %207
store i64 1, i64* %23
br label %218
218: ; preds = %241, %217
%219 = load i64, i64* %23
%220 = load i64, i64* %10
%221 = icmp ult i64 %219, %220
br i1 %221, label %222, label %244
222: ; preds = %218
%223 = load i32, i32* %6
%224 = load i32, i32* %22
%225 = sext i32 %224 to i64
%226 = load i64, i64* %23
%227 = add i64 %225, %226
%228 = trunc i64 %227 to i32
%229 = load i32*, i32** %9
%230 = load i64, i64* %23
%231 = sub i64 %230, 1
%232 = getelementptr inbounds i32, i32* %229, i64 %231
%233 = load i32, i32* %232
%234 = trunc i32 %233 to i8
%235 = call i64 @write8(i32 %223, i32 %228, i8 signext %234)
%236 = icmp ne i64 %235, 0
br i1 %236, label %237, label %240
237: ; preds = %222
%238 = load i32, i32* @stderr
%239 = call i32 (i32, i8*, ...) @fprintf(i32 %238, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %5
br label %255
240: ; preds = %222
br label %241
241: ; preds = %240
%242 = load i64, i64* %23
%243 = add i64 %242, 1
store i64 %243, i64* %23
br label %218
244: ; preds = %218
%245 = load i32, i32* %6
%246 = load i32, i32* %13
%247 = load i32, i32* %13
%248 = call i64 @writecons(i32 %245, i32 %246, i32 %247, i32 0)
%249 = icmp ne i64 %248, 0
br i1 %249, label %250, label %253
250: ; preds = %244
%251 = load i32, i32* @stderr
%252 = call i32 (i32, i8*, ...) @fprintf(i32 %251, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %5
br label %255
253: ; preds = %244
%254 = load i32, i32* %22
store i32 %254, i32* %5
br label %255
255: ; preds = %253, %250, %237, %214, %204, %186, %169, %157, %148, %139, %129, %122, %111, %82, %73, %60, %53, %26
%256 = load i32, i32* %5
ret i32 %256
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"persist: db_store: name==NULL\0A\00"
@.str.1 = [33 x i8] c"persist: db_store: unknown size\0A\00"
@.str.2 = [51 x i8] c"persist: db_store: failed to read namehead at 0x4\0A\00"
@.str.3 = [59 x i8] c"persist: db_store: failed to read namelist cons at 0x%08x\0A\00"
@.str.4 = [60 x i8] c"persist: db_store: failed to read namelist entry at 0x%08x\0A\00"
@.str.5 = [61 x i8] c"persist: db_store: failed to allocate space for new nameent\0A\00"
@.str.6 = [52 x i8] c"persist: db_store: failed to write namehead at 0x4\0A\00"
@.str.7 = [50 x i8] c"persist: db_store: internal error (oldptr==NULL)\0A\00"
@.str.8 = [46 x i8] c"persist: db_store: failed to write to oldptr\0A\00"
@.str.9 = [61 x i8] c"persist: db_store: failed to allocate space for new namecar\0A\00"
@.str.10 = [47 x i8] c"persist: db_store: failed to write to nameent\0A\00"
@.str.11 = [54 x i8] c"persist: db_store: failed to allocate space for name\0A\00"
@.str.12 = [45 x i8] c"persist: db_store: failed to write out name\0A\00"
@.str.13 = [54 x i8] c"persist: db_store: failed to allocate space for data\0A\00"
@.str.14 = [45 x i8] c"persist: db_store: failed to write out type\0A\00"
@.str.15 = [45 x i8] c"persist: db_store: failed to write out data\0A\00"
define i32 @db_store(i32 %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = icmp eq i8* %1, null
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %183
14: ; preds = %4
%15 = lshr i32 %2, 4
%16 = and i32 %15, 15
switch i32 %16, label %29 [
i32 0, label %32
i32 8, label %17
i32 9, label %18
i32 10, label %19
i32 15, label %22
i32 12, label %20
]
17: ; preds = %14
br label %32
18: ; preds = %14
br label %32
19: ; preds = %14
br label %32
20: ; preds = %14
%21 = icmp eq i32* %3, null
br i1 %21, label %32, label %23
22: ; preds = %14
br label %32
23: ; preds = %20
%24 = bitcast i32* %3 to i8*
%25 = tail call i32 @strlen(i8* %24)
%26 = add nsw i32 %25, 2
%27 = sext i32 %26 to i64
%28 = icmp eq i32 %26, 0
br i1 %28, label %29, label %32
29: ; preds = %14, %23
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %183
32: ; preds = %14, %17, %18, %19, %22, %20, %23
%33 = phi i64 [ %27, %23 ], [ 2, %20 ], [ 2, %17 ], [ 3, %18 ], [ 5, %19 ], [ 5, %22 ], [ 9, %14 ]
%34 = bitcast i32* %5 to i8*
%35 = call i64 @read32(i32 %0, i32 4, i32* %5)
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
br label %181
40: ; preds = %32
%41 = load i32, i32* %5
%42 = bitcast i32* %6 to i8*
%43 = bitcast i32* %7 to i8*
%44 = icmp eq i32 %41, 0
br i1 %44, label %74, label %45
45: ; preds = %40
%46 = bitcast i32* %8 to i8*
%47 = bitcast i32* %9 to i8*
br label %48
48: ; preds = %45, %71
%49 = phi i32 [ %41, %45 ], [ %72, %71 ]
%50 = phi i32 [ 0, %45 ], [ %49, %71 ]
%51 = call i64 @readcons(i32 %0, i32 %49, i32* %6, i32* %7)
%52 = icmp eq i64 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %49)
br label %179
56: ; preds = %48
%57 = load i32, i32* %6
%58 = call i64 @readcons(i32 %0, i32 %57, i32* %8, i32* %9)
%59 = icmp eq i64 %58, 0
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = load i32, i32* %6
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %179
64: ; preds = %56
%65 = load i32, i32* %8
%66 = call i8* @readcstr(i32 %0, i32 %65)
%67 = call i64 @strcmp(i8* %1, i8* %66)
%68 = icmp eq i64 %67, 0
%69 = call i32 @free(i8* %66)
br i1 %68, label %70, label %71
70: ; preds = %64
br label %74
71: ; preds = %64
%72 = load i32, i32* %7
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %48
74: ; preds = %71, %40, %70
%75 = phi i32 [ %50, %70 ], [ 0, %40 ], [ %49, %71 ]
%76 = load i32, i32* %6
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %141
78: ; preds = %74
%79 = call i32 @db_alloc(i32 %0, i64 9)
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = load i32, i32* @stderr
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.5, i64 0, i64 0))
br label %179
84: ; preds = %78
%85 = load i32, i32* %5
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %93
87: ; preds = %84
store i32 %79, i32* %5
%88 = call i64 @write32(i32 %0, i32 4, i32 %79)
%89 = icmp eq i64 %88, 0
br i1 %89, label %105, label %90
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
br label %179
93: ; preds = %84
%94 = icmp eq i32 %75, 0
br i1 %94, label %95, label %98
95: ; preds = %93
%96 = load i32, i32* @stderr
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0))
br label %179
98: ; preds = %93
%99 = load i32, i32* %6
%100 = call i64 @writecons(i32 %0, i32 %75, i32 %99, i32 %79)
%101 = icmp eq i64 %100, 0
br i1 %101, label %105, label %102
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
br label %179
105: ; preds = %98, %87
%106 = call i32 @db_alloc(i32 %0, i64 9)
store i32 %106, i32* %6
%107 = icmp eq i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = load i32, i32* @stderr
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
br label %179
111: ; preds = %105
%112 = call i64 @writecons(i32 %0, i32 %79, i32 %106, i32 0)
%113 = icmp eq i64 %112, 0
br i1 %113, label %117, label %114
114: ; preds = %111
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
br label %179
117: ; preds = %111
%118 = call i32 @strlen(i8* %1)
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = call i32 @db_alloc(i32 %0, i64 %120)
%122 = icmp eq i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %117
%124 = load i32, i32* @stderr
%125 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0))
br label %179
126: ; preds = %117, %137
%127 = phi i64 [ %138, %137 ], [ 0, %117 ]
%128 = trunc i64 %127 to i32
%129 = add i32 %121, %128
%130 = getelementptr inbounds i8, i8* %1, i64 %127
%131 = load i8, i8* %130
%132 = call i64 @write8(i32 %0, i32 %129, i8 signext %131)
%133 = icmp eq i64 %132, 0
br i1 %133, label %137, label %134
134: ; preds = %126
%135 = load i32, i32* @stderr
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.12, i64 0, i64 0))
br label %179
137: ; preds = %126
%138 = add i64 %127, 1
%139 = load i8, i8* %130
%140 = icmp eq i8 %139, 0
br i1 %140, label %141, label %126
141: ; preds = %137, %74
%142 = call i32 @db_alloc(i32 %0, i64 %33)
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %147
144: ; preds = %141
%145 = load i32, i32* @stderr
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0))
br label %179
147: ; preds = %141
%148 = trunc i32 %2 to i8
%149 = call i64 @write8(i32 %0, i32 %142, i8 signext %148)
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %153
151: ; preds = %147
%152 = icmp ugt i64 %33, 1
br i1 %152, label %158, label %172
153: ; preds = %147
%154 = load i32, i32* @stderr
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0))
br label %179
156: ; preds = %158
%157 = icmp eq i64 %168, %33
br i1 %157, label %172, label %158
158: ; preds = %151, %156
%159 = phi i64 [ %168, %156 ], [ 1, %151 ]
%160 = trunc i64 %159 to i32
%161 = add i32 %142, %160
%162 = add i64 %159, -1
%163 = getelementptr inbounds i32, i32* %3, i64 %162
%164 = load i32, i32* %163
%165 = trunc i32 %164 to i8
%166 = call i64 @write8(i32 %0, i32 %161, i8 signext %165)
%167 = icmp eq i64 %166, 0
%168 = add nuw i64 %159, 1
br i1 %167, label %156, label %169
169: ; preds = %158
%170 = load i32, i32* @stderr
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0))
br label %179
172: ; preds = %156, %151
%173 = load i32, i32* %6
%174 = call i64 @writecons(i32 %0, i32 %173, i32 %173, i32 0)
%175 = icmp eq i64 %174, 0
br i1 %175, label %179, label %176
176: ; preds = %172
%177 = load i32, i32* @stderr
%178 = call i32 (i32, i8*, ...) @fprintf(i32 %177, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.10, i64 0, i64 0))
br label %179
179: ; preds = %134, %123, %81, %90, %95, %108, %114, %102, %169, %60, %144, %153, %176, %172, %53
%180 = phi i32 [ 0, %53 ], [ 0, %153 ], [ 0, %176 ], [ 0, %169 ], [ 0, %144 ], [ %142, %172 ], [ 0, %60 ], [ 0, %102 ], [ 0, %114 ], [ 0, %108 ], [ 0, %95 ], [ 0, %90 ], [ 0, %81 ], [ 0, %123 ], [ 0, %134 ]
br label %181
181: ; preds = %179, %37
%182 = phi i32 [ 0, %37 ], [ %180, %179 ]
br label %183
183: ; preds = %29, %181, %11
%184 = phi i32 [ 0, %11 ], [ %182, %181 ], [ 0, %29 ]
ret i32 %184
}