// File: /workspace/github_c_makefile_star2_O0/bmottershead[P]DBF2TSV/dbf.c
// Function: DBFWriteAttribute
static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, void *pValue) {
  int i, j, nRetResult = TRUE;
  unsigned char *pabyRec;
  char szSField[400], szFormat[20];

  /* Is this a valid record? */
  if (hEntity < 0 || hEntity > psDBF->nRecords)
    return (FALSE);
  if (psDBF->bNoHeader)
    DBFWriteHeader(psDBF);

  /* Is this a brand new record? */
  if (hEntity == psDBF->nRecords) {
    if (!DBFFlushRecord(psDBF))
      return FALSE;
    psDBF->nRecords++;
    for (i = 0; i < psDBF->nRecordLength; i++)
      psDBF->pszCurrentRecord[i] = ' ';
    psDBF->nCurrentRecord = hEntity;
  }

  /* Is this an existing record, but different than the last one */
  /* we accessed? */
  if (!DBFLoadRecord(psDBF, hEntity))
    return FALSE;
  pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
  psDBF->bCurrentRecordModified = TRUE;
  psDBF->bUpdated = TRUE;

  /* Translate NULL value to valid DBF file representation. */
  if (pValue == NULL) {
    memset((char *) (pabyRec + psDBF->panFieldOffset[iField]),
           DBFGetNullCharacter(psDBF->pachFieldType[iField]),
           psDBF->panFieldSize[iField]);
    return TRUE;
  }

  /* Assign all the record fields. */
  switch (psDBF->pachFieldType[iField]) {
  case 'D':
  case 'N':
  case 'F':
    if (psDBF->panFieldDecimals[iField] == 0) {
      int nWidth = psDBF->panFieldSize[iField];
      if ((int) sizeof(szSField) - 2 < nWidth)
        nWidth = sizeof(szSField) - 2;
      sprintf(szFormat, "%%%dd", nWidth);
      sprintf(szSField, szFormat, (int) *((double *) pValue));
      if ((int) strlen(szSField) > psDBF->panFieldSize[iField]) {
        szSField[psDBF->panFieldSize[iField]] = '\0';
        nRetResult = FALSE;
      }
      strncpy((char *) (pabyRec + psDBF->panFieldOffset[iField]),szSField, strlen(szSField));
    } else {
      int nWidth = psDBF->panFieldSize[iField];
      if ((int) sizeof(szSField) - 2 < nWidth)
        nWidth = sizeof(szSField) - 2;
      sprintf(szFormat, "%%%d.%df",
              nWidth, psDBF->panFieldDecimals[iField]);
      sprintf(szSField, szFormat, *((double *) pValue));
      if ((int) strlen(szSField) > psDBF->panFieldSize[iField]) {
        szSField[psDBF->panFieldSize[iField]] = '\0';
        nRetResult = FALSE;
      }
      strncpy((char *) (pabyRec + psDBF->panFieldOffset[iField]),szSField, strlen(szSField));
    }
    break;

  case 'L':
    if (psDBF->panFieldSize[iField] >= 1 &&
        (*(char *) pValue == 'F' || *(char *) pValue == 'T'))
      *(pabyRec + psDBF->panFieldOffset[iField]) = *(char *) pValue;
    break;

  default:
    if ((int) strlen((char *) pValue) > psDBF->panFieldSize[iField]) {
      j = psDBF->panFieldSize[iField];
      nRetResult = FALSE;
    } else {
      memset(pabyRec + psDBF->panFieldOffset[iField], ' ',psDBF->panFieldSize[iField]);
      j = strlen((char *) pValue);
    }
    strncpy((char *) (pabyRec + psDBF->panFieldOffset[iField]), (char *) pValue, j);
    break;
  }

  return (nRetResult);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x1, -0x2c(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x3352
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0x335e
movl $0x0, -0x4(%rbp)
jmp 0x37b2
movq -0x10(%rbp), %rax
cmpl $0x0, 0x60(%rax)
je 0x3371
movq -0x10(%rbp), %rdi
callq 0x1670
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x33dc
movq -0x10(%rbp), %rdi
callq 0x17b0
cmpl $0x0, %eax
jne 0x3397
movl $0x0, -0x4(%rbp)
jmp 0x37b2
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x33d2
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movslq -0x24(%rbp), %rcx
movb $0x20, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x33ab
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x31c0
cmpl $0x0, %eax
jne 0x33f9
movl $0x0, -0x4(%rbp)
jmp 0x37b2
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x44(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x64(%rax)
cmpq $0x0, -0x20(%rbp)
jne 0x3483
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movq %rax, -0x200(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %edi
callq 0x2940
movq -0x200(%rbp), %rdi
movsbl %al, %eax
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rdx
movzbl %al, %esi
callq 0x10e0
movl $0x1, -0x4(%rbp)
jmp 0x37b2
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x18(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $-0x44, %eax
movl %eax, %ecx
movq %rcx, -0x208(%rbp)
subl $0xa, %eax
ja 0x3716
movq -0x208(%rbp), %rax
leaq 0x1bfa(%rip), %rcx      # 0x50b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x35c8
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1f4(%rbp)
movl $0x18e, %eax            # imm = 0x18E
cmpl -0x1f4(%rbp), %eax
jge 0x3501
movl $0x18e, -0x1f4(%rbp)    # imm = 0x18E
leaq -0x1f0(%rbp), %rdi
movl -0x1f4(%rbp), %edx
leaq 0x1c75(%rip), %rsi      # 0x518a
movb $0x0, %al
callq 0x11b0
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
movq -0x20(%rbp), %rax
cvttsd2si (%rax), %edx
movb $0x0, %al
callq 0x11b0
leaq -0x1d0(%rbp), %rdi
callq 0x10c0
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x3575
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movb $0x0, -0x1d0(%rbp,%rax)
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movq %rax, -0x218(%rbp)
leaq -0x1d0(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x10c0
movq -0x218(%rbp), %rdi
movq -0x210(%rbp), %rsi
movq %rax, %rdx
callq 0x1040
jmp 0x36c5
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1f8(%rbp)
movl $0x18e, %eax            # imm = 0x18E
cmpl -0x1f8(%rbp), %eax
jge 0x35f4
movl $0x18e, -0x1f8(%rbp)    # imm = 0x18E
leaq -0x1f0(%rbp), %rdi
movl -0x1f8(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x1a35(%rip), %rsi      # 0x504c
movb $0x0, %al
callq 0x11b0
leaq -0x1d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
movb $0x1, %al
callq 0x11b0
leaq -0x1d0(%rbp), %rdi
callq 0x10c0
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x3677
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movb $0x0, -0x1d0(%rbp,%rax)
movl $0x0, -0x2c(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movq %rax, -0x228(%rbp)
leaq -0x1d0(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x10c0
movq -0x228(%rbp), %rdi
movq -0x220(%rbp), %rsi
movq %rax, %rdx
callq 0x1040
jmp 0x37ac
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
cmpl $0x1, (%rax,%rcx,4)
jl 0x3711
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x46, %eax
je 0x36f4
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x54, %eax
jne 0x3711
movq -0x20(%rbp), %rax
movb (%rax), %dl
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq -0x18(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movb %dl, (%rax,%rcx)
jmp 0x37ac
movq -0x20(%rbp), %rdi
callq 0x10c0
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x18(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x374b
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x3788
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
movl $0x20, %esi
callq 0x10e0
movq -0x20(%rbp), %rdi
callq 0x10c0
movl %eax, -0x28(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movslq -0x28(%rbp), %rdx
callq 0x1040
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nop