// File: /workspace/github_c_makefile_star2_O2/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 0x2124
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r15d
xorl %eax, %eax
testl %edx, %edx
js 0x2129
movq %rdi, %rbx
cmpl %esi, 0x8(%rdi)
jle 0x2129
cmpl %r15d, 0x14(%rbx)
jle 0x2127
movl %ecx, %ebp
movq %rbx, %rdi
callq 0x2467
testl %eax, %eax
je 0x2127
movq 0x20(%rbx), %r12
movq 0x48(%rbx), %r14
movl %r15d, %r15d
movslq (%r12,%r15,4), %rsi
cmpl 0x50(%rbx), %esi
jge 0x2132
movq 0x58(%rbx), %rdi
jmp 0x2163
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 0x2154
callq 0x1190
movq %rax, %rdi
movq %rax, 0x58(%rbx)
movq 0x20(%rbx), %r12
jmp 0x2163
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 0x21ad
movq %rax, %rdi
callq 0x10b0
movsd %xmm0, 0x68(%rbx)
addq $0x68, %rbx
movq %rbx, %rax
jmp 0x2129
movq %rax, %rdx
movb (%rdx), %sil
incq %rdx
cmpb $0x20, %sil
je 0x21b0
xorl %ecx, %ecx
testb %sil, %sil
je 0x21d0
movb %sil, (%rax,%rcx)
movb (%rdx,%rcx), %sil
incq %rcx
jmp 0x21be
addq %rax, %rcx
movb $0x0, (%rcx)
cmpq 0x58(%rbx), %rcx
je 0x2129
cmpb $0x20, -0x1(%rcx)
leaq -0x1(%rcx), %rcx
je 0x21d3
jmp 0x2129