// File: /workspace/github_c_makefile_star2_O3/cktan[P]tomlc99/toml.c
// Function: toml_parse_file
toml_table_t *toml_parse_file(FILE *fp, char *errbuf, int errbufsz) {
  int bufsz = 0;
  char *buf = 0;
  int off = 0;

  /* read from fp into buf */
  while (!feof(fp)) {

    if (off == bufsz) {
      int xsz = bufsz + 1000;
      char *x = expand(buf, bufsz, xsz);
      if (!x) {
        snprintf(errbuf, errbufsz, "out of memory");
        xfree(buf);
        return 0;
      }
      buf = x;
      bufsz = xsz;
    }

    errno = 0;
    int n = fread(buf + off, 1, bufsz - off, fp);
    if (ferror(fp)) {
      snprintf(errbuf, errbufsz, "%s",
               errno ? strerror(errno) : "Error reading file");
      xfree(buf);
      return 0;
    }
    off += n;
  }

  /* tag on a NUL to cap the string */
  if (off == bufsz) {
    int xsz = bufsz + 1;
    char *x = expand(buf, bufsz, xsz);
    if (!x) {
      snprintf(errbuf, errbufsz, "out of memory");
      xfree(buf);
      return 0;
    }
    buf = x;
    bufsz = xsz;
  }
  buf[off] = 0;

  /* parse it, cleanup and finish */
  toml_table_t *ret = toml_parse(buf, errbuf, errbufsz);
  xfree(buf);
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r13
movq %rdi, %r15
callq 0x1170
testl %eax, %eax
je 0x3389
xorl %r14d, %r14d
xorl %ebx, %ebx
leal 0x1(%rbx), %eax
movslq %eax, %rdi
callq *0x5db8(%rip)           # 0x9110
movq %rax, %r12
testq %r14, %r14
je 0x344f
testq %r12, %r12
je 0x344f
movslq %ebx, %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x1180
movq %r14, %rdi
callq *0x5d94(%rip)           # 0x9118
jmp 0x3454
movl %ebp, 0xc(%rsp)
movq %r13, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %ebx, %ebx
cmpl %ebp, %ebx
jne 0x33cd
leal 0x3e8(%rbp), %r13d
movslq %r13d, %rdi
callq *0x5d63(%rip)           # 0x9110
movq %rax, %r14
testq %rax, %rax
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
je 0x33d2
movl %r13d, %ebp
testq %r14, %r14
jne 0x33ec
jmp 0x34e1
movq %r12, %r14
jmp 0x33ec
movslq %ebp, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x1180
movq %r12, %rdi
callq *0x5d2f(%rip)           # 0x9118
movl %r13d, %ebp
callq 0x1050
movq %rax, %r12
movl $0x0, (%rax)
movslq %ebx, %rdi
addq %r14, %rdi
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
movl $0x1, %esi
movq %r15, %rcx
callq 0x1080
movq %rax, %r13
movq %r15, %rdi
callq 0x1070
testl %eax, %eax
jne 0x3471
addl %r13d, %ebx
movq %r15, %rdi
callq 0x1170
movq %r14, %r12
testl %eax, %eax
je 0x3399
movq %r14, %r12
cmpl %ebp, %ebx
movq 0x10(%rsp), %r13
movl 0xc(%rsp), %ebp
je 0x334c
jmp 0x3454
testq %r12, %r12
je 0x3488
movslq %ebx, %rax
movb $0x0, (%r12,%rax)
movq %r12, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x208e
movq %rax, %r15
movq %r12, %r14
jmp 0x34c6
movslq 0xc(%rsp), %r13
movl (%r12), %edi
testl %edi, %edi
je 0x34a1
callq 0x11d0
movq %rax, %rcx
jmp 0x34a8
movslq %ebp, %rsi
leaq 0x2d27(%rip), %rdx      # 0x61b9
xorl %r15d, %r15d
movq %r13, %rdi
xorl %eax, %eax
callq 0x10e0
jmp 0x34c1
leaq 0x2d1f(%rip), %rcx      # 0x61c7
leaq 0x2de6(%rip), %rdx      # 0x6295
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x10e0
testq %r14, %r14
je 0x34cf
movq %r14, %rdi
callq *0x5c49(%rip)           # 0x9118
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0xc(%rsp), %rsi
leaq 0x2ccc(%rip), %rdx      # 0x61b9
xorl %r15d, %r15d
movq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x10e0
movq %r12, %r14
testq %r12, %r12
jne 0x34c6
jmp 0x34cf