// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/expat-2.0.1/lib/xmlparse.c
// Function: storeEntityValue
static enum XML_Error
storeEntityValue(XML_Parser parser,
                 const ENCODING *enc,
                 const char *entityTextPtr,
                 const char *entityTextEnd)
{
  DTD * const dtd = _dtd;  /* save one level of indirection */
  STRING_POOL *pool = &(dtd->entityValuePool);
  enum XML_Error result = XML_ERROR_NONE;
#ifdef XML_DTD
  int oldInEntityValue = prologState.inEntityValue;
  prologState.inEntityValue = 1;
#endif /* XML_DTD */
  /* never return Null for the value argument in EntityDeclHandler,
     since this would indicate an external entity; therefore we
     have to make sure that entityValuePool.start is not null */
  if (!pool->blocks) {
    if (!poolGrow(pool))
      return XML_ERROR_NO_MEMORY;
  }

  for (;;) {
    const char *next;
    int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
    switch (tok) {
    case XML_TOK_PARAM_ENTITY_REF:
#ifdef XML_DTD
      if (isParamEntity || enc != encoding) {
        const XML_Char *name;
        ENTITY *entity;
        name = poolStoreString(&tempPool, enc,
                               entityTextPtr + enc->minBytesPerChar,
                               next - enc->minBytesPerChar);
        if (!name) {
          result = XML_ERROR_NO_MEMORY;
          goto endEntityValue;
        }
        entity = (ENTITY *)lookup(&dtd->paramEntities, name, 0);
        poolDiscard(&tempPool);
        if (!entity) {
          /* not a well-formedness error - see XML 1.0: WFC Entity Declared */
          /* cannot report skipped entity here - see comments on
             skippedEntityHandler
          if (skippedEntityHandler)
            skippedEntityHandler(handlerArg, name, 0);
          */
          dtd->keepProcessing = dtd->standalone;
          goto endEntityValue;
        }
        if (entity->open) {
          if (enc == encoding)
            eventPtr = entityTextPtr;
          result = XML_ERROR_RECURSIVE_ENTITY_REF;
          goto endEntityValue;
        }
        if (entity->systemId) {
          if (externalEntityRefHandler) {
            dtd->paramEntityRead = XML_FALSE;
            entity->open = XML_TRUE;
            if (!externalEntityRefHandler(externalEntityRefHandlerArg,
                                          0,
                                          entity->base,
                                          entity->systemId,
                                          entity->publicId)) {
              entity->open = XML_FALSE;
              result = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
              goto endEntityValue;
            }
            entity->open = XML_FALSE;
            if (!dtd->paramEntityRead)
              dtd->keepProcessing = dtd->standalone;
          }
          else
            dtd->keepProcessing = dtd->standalone;
        }
        else {
          entity->open = XML_TRUE;
          result = storeEntityValue(parser,
                                    internalEncoding,
                                    (char *)entity->textPtr,
                                    (char *)(entity->textPtr
                                             + entity->textLen));
          entity->open = XML_FALSE;
          if (result)
            goto endEntityValue;
        }
        break;
      }
#endif /* XML_DTD */
      /* In the internal subset, PE references are not legal
         within markup declarations, e.g entity values in this case. */
      eventPtr = entityTextPtr;
      result = XML_ERROR_PARAM_ENTITY_REF;
      goto endEntityValue;
    case XML_TOK_NONE:
      result = XML_ERROR_NONE;
      goto endEntityValue;
    case XML_TOK_ENTITY_REF:
    case XML_TOK_DATA_CHARS:
      if (!poolAppend(pool, enc, entityTextPtr, next)) {
        result = XML_ERROR_NO_MEMORY;
        goto endEntityValue;
      }
      break;
    case XML_TOK_TRAILING_CR:
      next = entityTextPtr + enc->minBytesPerChar;
      /* fall through */
    case XML_TOK_DATA_NEWLINE:
      if (pool->end == pool->ptr && !poolGrow(pool)) {
              result = XML_ERROR_NO_MEMORY;
        goto endEntityValue;
      }
      *(pool->ptr)++ = 0xA;
      break;
    case XML_TOK_CHAR_REF:
      {
        XML_Char buf[XML_ENCODE_MAX];
        int i;
        int n = XmlCharRefNumber(enc, entityTextPtr);
        if (n < 0) {
          if (enc == encoding)
            eventPtr = entityTextPtr;
          result = XML_ERROR_BAD_CHAR_REF;
          goto endEntityValue;
        }
        n = XmlEncode(n, (ICHAR *)buf);
        if (!n) {
          if (enc == encoding)
            eventPtr = entityTextPtr;
          result = XML_ERROR_BAD_CHAR_REF;
          goto endEntityValue;
        }
        for (i = 0; i < n; i++) {
          if (pool->end == pool->ptr && !poolGrow(pool)) {
            result = XML_ERROR_NO_MEMORY;
            goto endEntityValue;
          }
          assert(i < XML_ENCODE_MAX);
          *(pool->ptr)++ = buf[i];
        }
      }
      break;
    case XML_TOK_PARTIAL:
      if (enc == encoding)
        eventPtr = entityTextPtr;
      result = XML_ERROR_INVALID_TOKEN;
      goto endEntityValue;
    case XML_TOK_INVALID:
      if (enc == encoding)
        eventPtr = next;
      result = XML_ERROR_INVALID_TOKEN;
      goto endEntityValue;
    default:
      if (enc == encoding)
        eventPtr = entityTextPtr;
      result = XML_ERROR_UNEXPECTED_STATE;
      goto endEntityValue;
    }
    entityTextPtr = next;
  }
endEntityValue:
#ifdef XML_DTD
  prologState.inEntityValue = oldInEntityValue;
#endif /* XML_DTD */
  return result;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq 0x58(%rsp), %rax
movq 0x290(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
addq $0xd0, %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movq 0x30(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x37aae9
movq 0x30(%rsp), %rdi
callq 0x37a570
cmpb $0x0, %al
jne 0x37aae7
movl $0x1, 0x64(%rsp)
jmp 0x37add2
jmp 0x37aae9
jmp 0x37aaeb
movq 0x50(%rsp), %rdi
movq 0x20(%rdi), %rax
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *%rax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
addl $0x4, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x20, %eax
ja 0x37ad8d
movq 0x8(%rsp), %rax
leaq 0x2237f4(%rip), %rcx    # 0x59e320
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0xa, 0x2c(%rsp)
jmp 0x37adca
movl $0x0, 0x2c(%rsp)
jmp 0x37adca
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x37a2c0
cmpq $0x0, %rax
jne 0x37ab8c
movl $0x1, 0x2c(%rsp)
jmp 0x37adca
jmp 0x37adbb
movq 0x48(%rsp), %rax
movq 0x50(%rsp), %rcx
movslq 0x80(%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x37abd9
movq 0x30(%rsp), %rdi
callq 0x37a570
cmpb $0x0, %al
jne 0x37abd9
movl $0x1, 0x2c(%rsp)
jmp 0x37adca
movq 0x30(%rsp), %rcx
movq 0x18(%rcx), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x18(%rcx)
movb $0xa, (%rax)
jmp 0x37adbb
movq 0x50(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq *%rax
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x10(%rsp)
jge 0x37ac46
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x37ac39
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0xe, 0x2c(%rsp)
jmp 0x37adca
movl 0x10(%rsp), %edi
leaq 0x18(%rsp), %rsi
callq 0x383b40
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x10(%rsp)
jne 0x37ac90
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x37ac83
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0xe, 0x2c(%rsp)
jmp 0x37adca
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jge 0x37ad2c
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x37acd5
movq 0x30(%rsp), %rdi
callq 0x37a570
cmpb $0x0, %al
jne 0x37acd5
movl $0x1, 0x2c(%rsp)
jmp 0x37adca
cmpl $0x4, 0x14(%rsp)
jge 0x37acde
jmp 0x37acfd
leaq 0x223f2a(%rip), %rdi    # 0x59ec0f
leaq 0x2239b7(%rip), %rsi    # 0x59e6a3
movl $0x1400, %edx           # imm = 0x1400
leaq 0x223f2a(%rip), %rcx    # 0x59ec22
callq 0x19490
movslq 0x14(%rsp), %rax
movb 0x18(%rsp,%rax), %cl
movq 0x30(%rsp), %rdx
movq 0x18(%rdx), %rax
movq %rax, %rsi
addq $0x1, %rsi
movq %rsi, 0x18(%rdx)
movb %cl, (%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x37ac98
jmp 0x37adbb
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x37ad55
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0x4, 0x2c(%rsp)
jmp 0x37adca
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x37ad83
movq 0x20(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0x4, 0x2c(%rsp)
jmp 0x37adca
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq 0x120(%rcx), %rax
jne 0x37adb1
movq 0x48(%rsp), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x210(%rax)
movl $0x17, 0x2c(%rsp)
jmp 0x37adca
movq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
jmp 0x37aaeb
movl 0x2c(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopl (%rax,%rax)