// File: /workspace/github_c_makefile_star2_O1/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 0x221b
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
xorl %eax, %eax
testl %edx, %edx
js 0x2220
movq %rdi, %rbx
cmpl %esi, 0x8(%rdi)
jle 0x2220
cmpl %r15d, 0x14(%rbx)
jle 0x221e
movl %ecx, %ebp
movq %rbx, %rdi
callq 0x2559
testl %eax, %eax
je 0x221e
movq 0x20(%rbx), %rax
movq 0x48(%rbx), %r14
movl %r15d, %r15d
movslq (%rax,%r15,4), %rsi
cmpl 0x50(%rbx), %esi
jl 0x2237
addq $0x64, %rsi
movl %esi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
testq %rdi, %rdi
je 0x222b
callq 0x1190
jmp 0x2233
xorl %eax, %eax
retq
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rdi
callq 0x1160
movq %rax, 0x58(%rbx)
movq 0x58(%rbx), %rdi
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movslq (%rax,%r15,4), %rax
addq %rax, %r14
movslq (%rcx,%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 0x2286
movq %rax, %rdi
callq 0x10b0
movsd %xmm0, 0x68(%rbx)
addq $0x68, %rbx
movq %rbx, %rax
jmp 0x2220
movq %rax, %rdx
cmpb $0x20, (%rdx)
leaq 0x1(%rdx), %rdx
je 0x2289
movb -0x1(%rdx), %sil
movq %rax, %rcx
testb %sil, %sil
je 0x22c1
movq %rax, %rcx
movb %sil, (%rcx)
incq %rcx
movb (%rdx), %sil
incq %rdx
testb %sil, %sil
jne 0x22a1
jmp 0x22c1
cmpb $0x20, -0x1(%rcx)
jne 0x2220
decq %rcx
movb $0x0, (%rcx)
cmpq 0x58(%rbx), %rcx
jne 0x22b4
jmp 0x2220