// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/expat-2.0.1/lib/xmlparse.c
// Function: XML_GetBuffer
void * XMLCALL
XML_GetBuffer(XML_Parser parser, int len)
{
  switch (ps_parsing) {
  case XML_SUSPENDED:
    errorCode = XML_ERROR_SUSPENDED;
    return NULL;
  case XML_FINISHED:
    errorCode = XML_ERROR_FINISHED;
    return NULL;
  default: ;
  }

  if (len > bufferLim - bufferEnd) {
    /* FIXME avoid integer overflow */
    int neededSize = len + (int)(bufferEnd - bufferPtr);
#ifdef XML_CONTEXT_BYTES
    int keep = (int)(bufferPtr - buffer);

    if (keep > XML_CONTEXT_BYTES)
      keep = XML_CONTEXT_BYTES;
    neededSize += keep;
#endif  /* defined XML_CONTEXT_BYTES */
    if (neededSize  <= bufferLim - buffer) {
#ifdef XML_CONTEXT_BYTES
      if (keep < bufferPtr - buffer) {
        int offset = (int)(bufferPtr - buffer) - keep;
        memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
        bufferEnd -= offset;
        bufferPtr -= offset;
      }
#else
      memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
      bufferEnd = buffer + (bufferEnd - bufferPtr);
      bufferPtr = buffer;
#endif  /* not defined XML_CONTEXT_BYTES */
    }
    else {
      char *newBuf;
      int bufferSize = (int)(bufferLim - bufferPtr);
      if (bufferSize == 0)
        bufferSize = INIT_BUFFER_SIZE;
      do {
        bufferSize *= 2;
      } while (bufferSize < neededSize);
      newBuf = (char *)MALLOC(bufferSize);
      if (newBuf == 0) {
        errorCode = XML_ERROR_NO_MEMORY;
        return NULL;
      }
      bufferLim = newBuf + bufferSize;
#ifdef XML_CONTEXT_BYTES
      if (bufferPtr) {
        int keep = (int)(bufferPtr - buffer);
        if (keep > XML_CONTEXT_BYTES)
          keep = XML_CONTEXT_BYTES;
        memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep);
        FREE(buffer);
        buffer = newBuf;
        bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;
        bufferPtr = buffer + keep;
      }
      else {
        bufferEnd = newBuf + (bufferEnd - bufferPtr);
        bufferPtr = buffer = newBuf;
      }
#else
      if (bufferPtr) {
        memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
        FREE(buffer);
      }
      bufferEnd = newBuf + (bufferEnd - bufferPtr);
      bufferPtr = buffer = newBuf;
#endif  /* not defined XML_CONTEXT_BYTES */
    }
  }
  return bufferEnd;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x378(%rdi), %eax
cmpl $0x2, %eax
je 0x1fcc44
cmpl $0x3, %eax
jne 0x1fcc56
movl $0x21, 0x208(%rbx)
jmp 0x1fcc4e
movl $0x24, 0x208(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
movslq %esi, %rcx
movq 0x38(%rbx), %rax
movq 0x40(%rbx), %rdx
movq %rdx, %rdi
subq %rax, %rdi
cmpq %rcx, %rdi
jge 0x1fcc50
movq 0x10(%rbx), %rdi
movq 0x30(%rbx), %rcx
subq %rcx, %rax
addl %eax, %esi
movslq %esi, %r8
movq %rdx, %r9
subq %rdi, %r9
cmpq %r8, %r9
jge 0x1fccd4
subl %ecx, %edx
movl $0x400, %eax            # imm = 0x400
cmovnel %edx, %eax
addl %eax, %eax
cmpl %esi, %eax
jl 0x1fcc91
movslq %eax, %r15
movq %r15, %rdi
callq *0x18(%rbx)
testq %rax, %rax
je 0x1fccfb
movq %rax, %r14
addq %rax, %r15
movq %r15, 0x40(%rbx)
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x1fcd0a
movq 0x38(%rbx), %rdx
subq %rsi, %rdx
movq %r14, %rdi
callq 0x17630
movq 0x10(%rbx), %rdi
callq *0x28(%rbx)
movq 0x30(%rbx), %rax
jmp 0x1fcd0c
movq %rcx, %rsi
movq %rax, %rdx
callq 0x17c50
movq 0x38(%rbx), %rax
subq 0x30(%rbx), %rax
movq 0x10(%rbx), %rcx
addq %rcx, %rax
movq %rax, 0x38(%rbx)
movq %rcx, 0x30(%rbx)
jmp 0x1fcc50
movl $0x1, 0x208(%rbx)
jmp 0x1fcc4e
xorl %eax, %eax
movq 0x38(%rbx), %rcx
subq %rax, %rcx
movq %r14, %rax
addq %rcx, %rax
movq %rax, 0x38(%rbx)
movq %r14, 0x10(%rbx)
movq %r14, 0x30(%rbx)
jmp 0x1fcc50