// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/expat-2.0.1/lib/xmlparse.c
// Function: XML_Parse
enum XML_Status XMLCALL
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
{
  switch (ps_parsing) {
  case XML_SUSPENDED:
    errorCode = XML_ERROR_SUSPENDED;
    return XML_STATUS_ERROR;
  case XML_FINISHED:
    errorCode = XML_ERROR_FINISHED;
    return XML_STATUS_ERROR;
  default:
    ps_parsing = XML_PARSING;
  }

  if (len == 0) {
    ps_finalBuffer = (XML_Bool)isFinal;
    if (!isFinal)
      return XML_STATUS_OK;
    positionPtr = bufferPtr;
    parseEndPtr = bufferEnd;

    /* If data are left over from last buffer, and we now know that these
       data are the final chunk of input, then we have to check them again
       to detect errors based on that fact.
    */
    errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr);

    if (errorCode == XML_ERROR_NONE) {
      switch (ps_parsing) {
      case XML_SUSPENDED:
        XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
        positionPtr = bufferPtr;
        return XML_STATUS_SUSPENDED;
      case XML_INITIALIZED: 
      case XML_PARSING:
        ps_parsing = XML_FINISHED;
        /* fall through */
      default:
        return XML_STATUS_OK;
      }
    }
    eventEndPtr = eventPtr;
    processor = errorProcessor;
    return XML_STATUS_ERROR;
  }
#ifndef XML_CONTEXT_BYTES
  else if (bufferPtr == bufferEnd) {
    const char *end;
    int nLeftOver;
    enum XML_Status result = 0;
    parseEndByteIndex += len;
    positionPtr = s;
    ps_finalBuffer = (XML_Bool)isFinal;

    errorCode = processor(parser, s, parseEndPtr = s + len, &end);

    if (errorCode != XML_ERROR_NONE) {
      eventEndPtr = eventPtr;
      processor = errorProcessor;
      return XML_STATUS_ERROR;
    }
    else {
      switch (ps_parsing) {
      case XML_SUSPENDED:
        result = XML_STATUS_SUSPENDED;
        break;
      case XML_INITIALIZED:
      case XML_PARSING:
        result = XML_STATUS_OK;
        if (isFinal) {
          ps_parsing = XML_FINISHED;
          return result;
        }
      case XML_FINISHED:
        break;
      }
    }

    XmlUpdatePosition(encoding, positionPtr, end, &position);
    nLeftOver = s + len - end;
    if (nLeftOver) {
      if (buffer == NULL || nLeftOver > bufferLim - buffer) {
        /* FIXME avoid integer overflow */
        char *temp;
        temp = (buffer == NULL
                ? (char *)MALLOC(len * 2)
                : (char *)REALLOC(buffer, len * 2));
        if (temp == NULL) {
          errorCode = XML_ERROR_NO_MEMORY;
          return XML_STATUS_ERROR;
        }
        buffer = temp;
        if (!buffer) {
          errorCode = XML_ERROR_NO_MEMORY;
          eventPtr = eventEndPtr = NULL;
          processor = errorProcessor;
          return XML_STATUS_ERROR;
        }
        bufferLim = buffer + len * 2;
      }
      memcpy(buffer, end, nLeftOver);
    }
    bufferPtr = buffer;
    bufferEnd = buffer + nLeftOver;
    positionPtr = bufferPtr;
    parseEndPtr = bufferEnd;
    eventPtr = bufferPtr;
    eventEndPtr = bufferPtr;
    return result;
  }
#endif  /* not defined XML_CONTEXT_BYTES */
  else {
    void *buff = XML_GetBuffer(parser, len);
    if (buff == NULL)
      return XML_STATUS_ERROR;
    else {
      memcpy(buff, s, len);
      return XML_ParseBuffer(parser, len, isFinal);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x378(%rdi), %eax
cmpl $0x2, %eax
je 0x2549d4
cmpl $0x3, %eax
jne 0x2549e3
movl $0x21, 0x208(%rbx)
jmp 0x254af4
movl $0x24, 0x208(%rbx)
jmp 0x254af4
movl %ecx, %r12d
movl %edx, %r14d
movl $0x1, 0x378(%rbx)
testl %edx, %edx
je 0x254a46
movq %rsi, %r13
movq 0x30(%rbx), %rax
cmpq 0x38(%rbx), %rax
je 0x254aa0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x254c38
testq %rax, %rax
je 0x254af4
movslq %r14d, %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x17660
movq %rbx, %rdi
movl %r14d, %esi
movl %r12d, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x254d40
movb %r12b, 0x37c(%rbx)
movl $0x1, %ebp
testl %r12d, %r12d
je 0x254af6
leaq 0x30(%rbx), %rcx
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
movq %rsi, 0x220(%rbx)
movq %rdx, 0x50(%rbx)
movq %rbx, %rdi
callq *0x200(%rbx)
movl %eax, 0x208(%rbx)
testl %eax, %eax
jne 0x254ad8
movl 0x378(%rbx), %eax
cmpl $0x2, %eax
jae 0x254b28
movl $0x2, 0x378(%rbx)
jmp 0x254af6
movslq %r14d, %r15
addq %r15, 0x48(%rbx)
movq %r13, 0x220(%rbx)
movb %r12b, 0x37c(%rbx)
addq %r13, %r15
movq %r15, 0x50(%rbx)
movq %rsp, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq *0x200(%rbx)
movl %eax, 0x208(%rbx)
testl %eax, %eax
je 0x254b07
movq 0x210(%rbx), %rax
movq %rax, 0x218(%rbx)
leaq 0x144(%rip), %rax       # 0x254c31
movq %rax, 0x200(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x378(%rbx), %eax
cmpl $0x2, %eax
jae 0x254b5b
testl %r12d, %r12d
je 0x254b69
movl $0x2, 0x378(%rbx)
movl $0x1, %ebp
jmp 0x254af6
cmpl $0x3, %eax
jne 0x254af6
movq 0x30(%rbx), %rdx
movq 0x120(%rbx), %rdi
movq 0x220(%rbx), %rsi
leaq 0x2f0(%rbx), %rcx
callq *0x60(%rdi)
movq 0x30(%rbx), %rax
movq %rax, 0x220(%rbx)
movl $0x2, %ebp
jmp 0x254af6
xorl %ebp, %ebp
cmpl $0x3, %eax
jne 0x254b6e
movl $0x2, %ebp
jmp 0x254b6e
movl $0x1, %ebp
movq 0x120(%rbx), %rdi
movq 0x220(%rbx), %rsi
movq (%rsp), %rdx
leaq 0x2f0(%rbx), %rcx
callq *0x60(%rdi)
subq (%rsp), %r15
testl %r15d, %r15d
je 0x254c01
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x254bbc
movslq %r15d, %rax
movq 0x40(%rbx), %rcx
subq %rdi, %rcx
cmpq %rcx, %rax
jle 0x254bf1
testq %rdi, %rdi
je 0x254bbc
leal (%r14,%r14), %eax
movslq %eax, %rsi
callq *0x20(%rbx)
jmp 0x254bc6
leal (%r14,%r14), %eax
movslq %eax, %rdi
callq *0x18(%rbx)
testq %rax, %rax
je 0x254bde
movq %rax, 0x10(%rbx)
addl %r14d, %r14d
movslq %r14d, %rcx
addq %rax, %rcx
movq %rcx, 0x40(%rbx)
jmp 0x254be8
movl $0x1, 0x208(%rbx)
testq %rax, %rax
je 0x254af4
movq 0x10(%rbx), %rdi
movq (%rsp), %rsi
movslq %r15d, %rdx
callq 0x17660
movq 0x10(%rbx), %rax
movq %rax, 0x30(%rbx)
movslq %r15d, %rcx
addq %rax, %rcx
movq %rcx, 0x38(%rbx)
movq %rax, 0x220(%rbx)
movq %rcx, 0x50(%rbx)
movq %rax, 0x210(%rbx)
movq %rax, 0x218(%rbx)
jmp 0x254af6