// File: /workspace/github_c_makefile_star2_O0/jflatow[P]jfdb/src/jfdb.c
// Function: load_input
static void load_input(JFDB *db, FILE *input) {
  int c, s = 0, n = 2;
  JFT_Stem *stems = malloc(n * sizeof(JFT_Stem));
  JFT_Boolean escaped = False;
  char *buf = malloc(1 << 20); // NB: static buffer
  size_t bufSize = 0;
  stems[0] = (JFT_Stem) {
    .size = 0,
    .data = (uint8_t *)buf
  };
  while ((c = getc(input)) != EOF) {
    if (escaped) {
      // copy byte no matter what
      buf[bufSize++] = c;
      stems[s].size++;
      escaped = False;
    } else if (c == '\\') {
      // escape the next byte
      escaped = True;
    } else if (c == '\t') {
      // close out current stem, start next one
      if (++s >= n)
        stems = realloc(stems, (n *= 2) * sizeof(JFT_Stem));
      stems[s] = (JFT_Stem) {
        .size = 0,
        .data = (uint8_t *)&buf[bufSize]
      };
    } else if (c == '\n') {
      // close out current stem, write db, reset
      if (s)
        JFDB_store(db, &stems[0], &stems[1], &stems[2], s > 1 ? s - 1 : 0, 0);
      else
        JFDB_annul(db, &stems[0], 0);
      bufSize = s = 0;
      stems[s].size = 0;
    } else {
      // copy byte
      buf[bufSize++] = c;
      stems[s].size++;
    }
  }
  free(stems);
  free(buf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x2, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
imulq $0x18, %rax, %rdi
callq 0x1160
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x1160
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, -0x58(%rbp)
movw $0x0, -0x50(%rbp)
movq -0x38(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rdi
callq 0x1200
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x1f2c
cmpl $0x0, -0x2c(%rbp)
je 0x1dad
movl -0x14(%rbp), %eax
movb %al, %dl
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x40(%rbp)
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw 0x8(%rax), %cx
addw $0x1, %cx
movw %cx, 0x8(%rax)
movl $0x0, -0x2c(%rbp)
jmp 0x1f27
cmpl $0x5c, -0x14(%rbp)
jne 0x1dbf
movl $0x1, -0x2c(%rbp)
jmp 0x1f25
cmpl $0x9, -0x14(%rbp)
jne 0x1e33
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
cmpl -0x1c(%rbp), %eax
jl 0x1dee
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x1c(%rbp)
cltq
imulq $0x18, %rax, %rsi
callq 0x1170
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq $0x0, -0x70(%rbp)
movw $0x0, -0x68(%rbp)
movq -0x38(%rbp), %rcx
addq -0x40(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq -0x70(%rbp), %rcx
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x60(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x1f23
cmpl $0xa, -0x14(%rbp)
jne 0x1eeb
cmpl $0x0, -0x18(%rbp)
je 0x1eb6
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x28(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x80(%rbp)
movq -0x28(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x78(%rbp)
cmpl $0x1, -0x18(%rbp)
jle 0x1e85
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1e8f
xorl %eax, %eax
movl %eax, -0x94(%rbp)
jmp 0x1e8f
movq -0x78(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rdi
movl -0x94(%rbp), %r8d
xorl %r9d, %r9d
callq 0x4810
jmp 0x1ec5
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
xorl %edx, %edx
callq 0x4770
movl $0x0, -0x18(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw $0x0, 0x8(%rax)
jmp 0x1f21
movl -0x14(%rbp), %eax
movb %al, %dl
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x40(%rbp)
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movw 0x8(%rax), %cx
addw $0x1, %cx
movw %cx, 0x8(%rax)
jmp 0x1f23
jmp 0x1f25
jmp 0x1f27
jmp 0x1d50
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x38(%rbp), %rdi
callq 0x1030
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)