// File: /workspace/github_c_makefile_star2_O3/bmottershead[P]DBF2TSV/dbf.c
// Function: DBFReadAttribute
static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
                              char chReqType) {
  unsigned char *pabyRec;
  void *pReturnField = NULL;

  /* Verify selection. */
  if (hEntity < 0 || hEntity >= psDBF->nRecords)
    return (NULL);
  if (iField < 0 || iField >= psDBF->nFields)
    return (NULL);

  /* Have we read the record? */
  if (!DBFLoadRecord(psDBF, hEntity))
    return NULL;
  pabyRec = (unsigned char *) psDBF->pszCurrentRecord;

  /* Ensure we have room to extract the target field. */
  if (psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength) {
    psDBF->nWorkFieldLength = psDBF->panFieldSize[iField] + 100;
    if (psDBF->pszWorkField == NULL)
      psDBF->pszWorkField = (char *) malloc(psDBF->nWorkFieldLength);
    else
      psDBF->pszWorkField = (char *) realloc(psDBF->pszWorkField,psDBF->nWorkFieldLength);
  }

  /* Extract the requested field. */
  strncpy(psDBF->pszWorkField,
          ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
          psDBF->panFieldSize[iField]);
  psDBF->pszWorkField[psDBF->panFieldSize[iField]] = '\0';

  pReturnField = psDBF->pszWorkField;

  /* Decode the field. */
  if (chReqType == 'N') {
    psDBF->dfDoubleField = atof(psDBF->pszWorkField);
    pReturnField = &(psDBF->dfDoubleField);
  }

  /* Should we trim white space off the string attribute value? */
#ifdef TRIM_DBF_WHITESPACE
  else {
    char *pchSrc, *pchDst;

    pchDst = pchSrc = psDBF->pszWorkField;
    while (*pchSrc == ' ')
      pchSrc++;
    while (*pchSrc != '\0')
      *(pchDst++) = *(pchSrc++);
    *pchDst = '\0';
    while (pchDst != psDBF->pszWorkField && *(--pchDst) == ' ')
      *pchDst = '\0';
  }
#endif

  return (pReturnField);
}

// Assembly:
testl %esi, %esi
js 0x21d3
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r15d
xorl %eax, %eax
testl %edx, %edx
js 0x21d8
movq %rdi, %rbx
cmpl %esi, 0x8(%rdi)
jle 0x21d8
cmpl %r15d, 0x14(%rbx)
jle 0x21d6
movl %ecx, %ebp
movq %rbx, %rdi
callq 0x2531
testl %eax, %eax
je 0x21d6
movq 0x20(%rbx), %r12
movq 0x48(%rbx), %r14
movl %r15d, %r15d
movslq (%r12,%r15,4), %rsi
cmpl 0x50(%rbx), %esi
jge 0x21e1
movq 0x58(%rbx), %rdi
jmp 0x2212
xorl %eax, %eax
retq
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0x64, %rsi
movl %esi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x2203
callq 0x1190
movq %rax, %rdi
movq %rax, 0x58(%rbx)
movq 0x20(%rbx), %r12
jmp 0x2212
movq %rsi, %rdi
callq 0x1160
movq %rax, %rdi
movq %rax, 0x58(%rbx)
movq 0x18(%rbx), %rax
movslq (%rax,%r15,4), %rax
addq %rax, %r14
movslq (%r12,%r15,4), %rdx
movq %r14, %rsi
callq 0x1050
movq 0x20(%rbx), %rax
movq 0x58(%rbx), %rcx
movslq (%rax,%r15,4), %rax
movb $0x0, (%rcx,%rax)
movq 0x58(%rbx), %rax
cmpb $0x4e, %bpl
jne 0x225c
movq %rax, %rdi
callq 0x10b0
movsd %xmm0, 0x68(%rbx)
addq $0x68, %rbx
movq %rbx, %rax
jmp 0x21d8
movq %rax, %rdx
movzbl (%rdx), %esi
incq %rdx
cmpl $0x20, %esi
je 0x225f
movq %rax, %rcx
testl %esi, %esi
je 0x2291
movb %sil, (%rcx)
incq %rcx
movb (%rdx), %sil
incq %rdx
testb %sil, %sil
jne 0x2271
jmp 0x2291
cmpb $0x20, -0x1(%rcx)
jne 0x21d8
decq %rcx
movb $0x0, (%rcx)
cmpq 0x58(%rbx), %rcx
jne 0x2284
jmp 0x21d8