// File: /workspace/github_c_makefile_star2_O1/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 0x254c5c
cmpl $0x3, %eax
jne 0x254c6d
movl $0x21, 0x208(%rbx)
jmp 0x254c66
movl $0x24, 0x208(%rbx)
xorl %eax, %eax
jmp 0x254d3a
movslq %esi, %rax
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
movq %rcx, %rdi
subq %rdx, %rdi
cmpq %rax, %rdi
jge 0x254d36
movq 0x10(%rbx), %rdi
movq 0x30(%rbx), %rax
subq %rax, %rdx
addl %edx, %esi
movslq %esi, %r8
movq %rcx, %r9
subq %rdi, %r9
cmpq %r8, %r9
jge 0x254d02
subl %eax, %ecx
movl $0x400, %eax            # imm = 0x400
cmovnel %ecx, %eax
addl %eax, %eax
cmpl %esi, %eax
jl 0x254cac
movslq %eax, %r15
movq %r15, %rdi
callq *0x18(%rbx)
movq %rax, %r14
testq %rax, %rax
je 0x254d23
addq %r14, %r15
movq %r15, 0x40(%rbx)
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x254ce9
movq 0x38(%rbx), %rdx
subq %rsi, %rdx
movq %r14, %rdi
callq 0x17660
movq 0x10(%rbx), %rdi
callq *0x28(%rbx)
movq 0x38(%rbx), %rax
subq 0x30(%rbx), %rax
addq %r14, %rax
movq %rax, 0x38(%rbx)
movq %r14, 0x10(%rbx)
movq %r14, 0x30(%rbx)
jmp 0x254d2d
movq %rax, %rsi
callq 0x17cd0
movq 0x38(%rbx), %rax
subq 0x30(%rbx), %rax
movq 0x10(%rbx), %rcx
addq %rcx, %rax
movq %rax, 0x38(%rbx)
movq %rcx, 0x30(%rbx)
jmp 0x254d36
movl $0x1, 0x208(%rbx)
testq %r14, %r14
je 0x254c66
movq 0x38(%rbx), %rax
popq %rbx
popq %r14
popq %r15
retq