user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<EEPROM_Write>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  test   %edx,%edx
  setne  %dl
  cmp    $0x100,%r12d
  setle  %al
  test   %al,%dl
  je     L81
  mov    %edi,%r13d
  cmp    $0xff,%edi
  jg     L81
  lea    0x14(%rsp),%rax
  mov    %rsi,%r14
  lea    0x10(%rsp),%rbx
  mov    %rax,0x8(%rsp)
  nopl   (%rax)
L108:
  mov    %r13d,%eax
  mov    $0x8,%ebp
  mov    0x8(%rsp),%rdi
  mov    %r14,%rsi
  and    $0x7,%eax
  mov    %r13d,0x10(%rsp)
  sub    %eax,%ebp
  cmp    %r12d,%ebp
  cmovg  %r12d,%ebp
  mov    %ebp,%edx
  call   <memcpy@plt>
  lea    0x1(%rbp),%edx
  mov    $0x1,%ecx
  mov    %rbx,%rsi
  mov    $0xa0,%edi
  call   <I2C_Xfer@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  jne    L51
  nopl   0x0(%rax)
L64:
  mov    $0x1,%ecx
  mov    $0x1,%edx
  mov    %rbx,%rsi
  add    $0x1,%r15d
  mov    $0xa0,%edi
  call   <I2C_Xfer@plt>
  mov    %eax,%r8d
  test   %eax,%eax
  je     L78
  cmp    $0x18f,%r15d
  jle    L64
  test   %eax,%eax
  jne    L82
L78:
  movslq %ebp,%rax
  add    %ebp,%r13d
  lea    (%r14,%rax,4),%r14
  sub    %ebp,%r12d
  jne    L108
L40:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  add    $0x48,%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L51:
  lea    D7(%rip),%rdi
  call   <printf@plt>
  mov    $0xfffffffe,%r8d
  jmp    L40
L82:
  lea    D21(%rip),%rdi
  mov    %eax,0x8(%rsp)
  call   <printf@plt>
  mov    0x8(%rsp),%r8d
  jmp    L40
L81:
  lea    D22(%rip),%rdi
  call   <printf@plt>
  mov    $0xfffffffd,%r8d
  jmp    L40
L29:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D7
type_infered: string
name: read_data
arguments: data_label: D21
type_infered: string
name: read_data
arguments: data_label: D22
type_infered: string

tool: D7: 
Failed to write to EEPROM!

tool: D21: 
Timeout getting ACK from EEPROM during write!

tool: D22: 
Invalid EEPROM addressing

assistant: ```c
int32_t EEPROM_Write(uint32_t startdestpos, uint8_t *src, uint32_t len) {
  int32_t retval = 0;
  if (startdestpos < 256 && len && len <= 256) {
    uint8_t tmpbuf[9];
    uint8_t i = startdestpos;
    while (len) {
      uint32_t loopcnt = 0;
      uint8_t startoffset = i & 0x07;
      uint8_t maxcopysize = 8 - startoffset;
      uint8_t bytestocopy = (len > maxcopysize) ? maxcopysize : len;
      tmpbuf[0] = i;
      memcpy(tmpbuf + 1, src, bytestocopy);
      retval = I2C_Xfer((0x50 << 1), tmpbuf, bytestocopy + 1, 1);
      if (!retval) {
        do {
          retval = I2C_Xfer((0x50 << 1), tmpbuf, 1, 1);
          loopcnt++;
        } while (retval && loopcnt < 400);
        if (retval) {
          printf("\nTimeout getting ACK from EEPROM during write!");
          break;
        }
        len -= bytestocopy;
        i += bytestocopy;
        src += bytestocopy;
      } else {
        printf("\nFailed to write to EEPROM!");
        retval = -2;
        break;
      }
    }
  } else {
    printf("\nInvalid EEPROM addressing");
    retval = -3;
  }
  return retval;
}
```