user: Please show me the C implementation that matches the assembly code listed below:

```asm
<EEPROMProgram>:
  endbr64
  push   %r13
  xor    %eax,%eax
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x8,%rsp
  call   <DEBUG_ASSERT@plt>
  mov    0x400af000,%rax
  xor    %edi,%edi
  movzwl %ax,%eax
  shl    $0x2,%rax
  cmp    %rbp,%rax
  seta   %dil
  xor    %eax,%eax
  call   <DEBUG_ASSERT@plt>
  mov    0x400af000,%rax
  lea    0x0(%rbp,%rbx,1),%rdx
  xor    %edi,%edi
  movzwl %ax,%eax
  shl    $0x2,%rax
  cmp    %rax,%rdx
  setbe  %dil
  xor    %eax,%eax
  call   <DEBUG_ASSERT@plt>
  xor    %edi,%edi
  test   $0x3,%bpl
  sete   %dil
  xor    %eax,%eax
  call   <DEBUG_ASSERT@plt>
  xor    %edi,%edi
  test   $0x3,%bl
  sete   %dil
  xor    %eax,%eax
  call   <DEBUG_ASSERT@plt>
  nopw   0x0(%rax,%rax,1)
L112:
  mov    0x400af018,%rax
  test   $0x1,%al
  jne    L112
  mov    %rbp,%rax
  shr    $0x6,%rax
  mov    %rax,0x400af004
  mov    %rbp,%rax
  shr    $0x2,%rax
  and    $0xf,%eax
  shr    $0x2,%rbx
  mov    %rax,0x400af008
  je     L40
  nopl   0x0(%rax,%rax,1)
L82:
  mov    0x400fe000,%rax
  and    $0x70ff0000,%eax
  cmp    $0x10050000,%rax
  je     L33
L98:
  mov    0x0(%r13),%rax
  mov    %rax,0x400af014
  nopl   (%rax)
L3:
  mov    0x400af018,%r12
  test   $0x1,%r12b
  jne    L3
  test   $0x110,%r12d
  jne    L30
  mov    0x400af008,%rax
  add    $0x8,%r13
  sub    $0x1,%rbx
  test   %rax,%rax
  jne    L135
  mov    0x400af004,%rax
  add    $0x1,%rax
  mov    %rax,0x400af004
L135:
  test   %rbx,%rbx
  jne    L82
L40:
  mov    0x400fe000,%rax
  and    $0x70ff0000,%eax
  cmp    $0x10050000,%rax
  je     L138
L146:
  mov    0x400af018,%r12
L65:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L33:
  mov    0x400fe000,%rax
  test   %ax,%ax
  jne    L98
  mov    %rbp,%rdi
  add    $0x4,%rbp
  call   <EEPROMSetSectorMask@plt>
  jmp    L98
L30:
  mov    0x400fe000,%rax
  and    $0x70ff0000,%eax
  cmp    $0x10050000,%rax
  jne    L65
  mov    0x400fe000,%rax
  test   %ax,%ax
  jne    L65
  call   <EEPROMClearSectorMask@plt>
  jmp    L65
L138:
  mov    0x400fe000,%rax
  test   %ax,%ax
  jne    L146
  call   <EEPROMClearSectorMask@plt>
  jmp    L146
```

assistant: ```c
unsigned long EEPROMProgram(unsigned long *pulData, unsigned long ulAddress, unsigned long ulCount) {
  unsigned long ulStatus;
  DEBUG_ASSERT(pulData);
  DEBUG_ASSERT(ulAddress < (((((*((volatile unsigned long *)(0x400AF000)))) & 0x0000FFFF) >> 0) * 4));
  DEBUG_ASSERT((ulAddress + ulCount) <= (((((*((volatile unsigned long *)(0x400AF000)))) & 0x0000FFFF) >> 0) * 4));
  DEBUG_ASSERT((ulAddress & 3) == 0);
  DEBUG_ASSERT((ulCount & 3) == 0);
  do {
    ulStatus = (*((volatile unsigned long *)(0x400AF018)));
  } while (ulStatus & 0x00000001);
  (*((volatile unsigned long *)(0x400AF004))) = ((ulAddress) >> 6);
  (*((volatile unsigned long *)(0x400AF008))) = (((ulAddress) >> 2) & 0x0F);
  ulCount /= 4;
  while (ulCount) {
    if ((((*((volatile unsigned long *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) && (((*((volatile unsigned long *)(0x400FE000))) & (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
      EEPROMSetSectorMask(ulAddress);
      ulAddress += 4;
    }
    (*((volatile unsigned long *)(0x400AF014))) = *pulData;
    do {
      ulStatus = (*((volatile unsigned long *)(0x400AF018)));
    } while (ulStatus & 0x00000001);
    if (ulStatus & (0x00000010 | 0x00000100)) {
      if ((((*((volatile unsigned long *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) && (((*((volatile unsigned long *)(0x400FE000))) & (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
        EEPROMClearSectorMask();
      }
      return (ulStatus);
    }
    pulData++;
    ulCount--;
    if ((*((volatile unsigned long *)(0x400AF008))) == 0) {
      (*((volatile unsigned long *)(0x400AF004))) += 1;
    }
  }
  if ((((*((volatile unsigned long *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00050000)) && (((*((volatile unsigned long *)(0x400FE000))) & (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))) {
    EEPROMClearSectorMask();
  }
  return ((*((volatile unsigned long *)(0x400AF018))));
}
```