// File: /workspace/github_c_makefile_star2_O2/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 0x1fc9cc
cmpl $0x3, %eax
jne 0x1fc9db
movl $0x21, 0x208(%rbx)
jmp 0x1fcaea
movl $0x24, 0x208(%rbx)
jmp 0x1fcaea
movl %ecx, %r12d
movl %edx, %r14d
movl $0x1, 0x378(%rbx)
testl %edx, %edx
je 0x1fca3e
movq %rsi, %r13
movq 0x30(%rbx), %rax
cmpq 0x38(%rbx), %rax
je 0x1fca96
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1fcc20
testq %rax, %rax
je 0x1fcaea
movslq %r14d, %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x17630
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 0x1fcd2a
movb %r12b, 0x37c(%rbx)
pushq $0x1
popq %rbp
testl %r12d, %r12d
je 0x1fcaec
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 0x1fcace
movl 0x378(%rbx), %eax
cmpl $0x2, %eax
jae 0x1fcb1b
movl $0x2, 0x378(%rbx)
jmp 0x1fcaec
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 0x1fcafd
movq 0x210(%rbx), %rax
movq %rax, 0x218(%rbx)
leaq 0x136(%rip), %rax       # 0x1fcc19
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 0x1fcb4c
testl %r12d, %r12d
je 0x1fcb57
movl $0x2, 0x378(%rbx)
pushq $0x1
jmp 0x1fcb49
cmpl $0x3, %eax
jne 0x1fcaec
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)
pushq $0x2
popq %rbp
jmp 0x1fcaec
xorl %ebp, %ebp
cmpl $0x3, %eax
jne 0x1fcb5a
pushq $0x2
jmp 0x1fcb59
pushq $0x1
popq %rbp
movq 0x120(%rbx), %rdi
movq 0x220(%rbx), %rsi
movq (%rsp), %rdx
leaq 0x2f0(%rbx), %rcx
callq *0x60(%rdi)
movq (%rsp), %rsi
subq %rsi, %r15
testl %r15d, %r15d
je 0x1fcba6
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1fcbab
movslq %r15d, %r12
movq 0x40(%rbx), %rax
subq %rdi, %rax
cmpq %rax, %r12
jle 0x1fcbd5
leal (%r14,%r14), %eax
movslq %eax, %rsi
callq *0x20(%rbx)
jmp 0x1fcbb5
xorl %r12d, %r12d
jmp 0x1fcbdd
leal (%r14,%r14), %eax
movslq %eax, %rdi
callq *0x18(%rbx)
movq %rax, %rdi
testq %rax, %rax
je 0x1fcc0a
movq %rdi, 0x10(%rbx)
addl %r14d, %r14d
movslq %r14d, %rax
addq %rdi, %rax
movq %rax, 0x40(%rbx)
movq (%rsp), %rsi
movslq %r15d, %r12
movq %r12, %rdx
callq 0x17630
movq 0x10(%rbx), %rax
movq %rax, 0x30(%rbx)
addq %rax, %r12
movq %r12, 0x38(%rbx)
movq %rax, 0x220(%rbx)
movq %r12, 0x50(%rbx)
movq %rax, 0x210(%rbx)
movq %rax, 0x218(%rbx)
jmp 0x1fcaec
movl $0x1, 0x208(%rbx)
jmp 0x1fcaea