ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<RIFF_ReadInChunkTBuf>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdx
  lea    0x14(%rsp),%rcx
  lea    0x10(%rsp),%r8
  call   <RIFF_ReadChunkInfo@plt>
  mov    (%r15),%rbp
  mov    (%r14),%edx
  test   %rbp,%rbp
  je     L10
  mov    0x14(%rsp),%eax
  add    $0xff,%eax
  cmp    %edx,%eax
  jge    L25
L13:
  lea    0x8(%rbx),%esi
  xor    %edx,%edx
  mov    %r12,%rdi
  call   <fseek@plt>
  mov    0x14(%rsp),%edx
  mov    %r12,%rcx
  mov    %rbp,%rdi
  mov    $0x1,%esi
  call   <fread@plt>
  mov    0x14(%rsp),%eax
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L38
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L25:
  lea    D4(%rip),%rdi
  mov    %rbp,%rsi
  xor    %eax,%eax
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <free@plt>
L10:
  mov    0x14(%rsp),%eax
  lea    D28(%rip),%rdi
  lea    0x8000(%rax),%r13d
  mov    $0x10000,%eax
  cmp    %eax,%r13d
  cmovl  %eax,%r13d
  xor    %eax,%eax
  movslq %r13d,%rsi
  call   <printf@plt>
  mov    %r13d,%edi
  call   <malloc@plt>
  mov    %r13d,%edx
  lea    D26(%rip),%rdi
  mov    %rax,(%r15)
  mov    %rax,%rbp
  mov    %rax,%rsi
  xor    %eax,%eax
  mov    %r13d,(%r14)
  call   <printf@plt>
  jmp    L13
L38:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D4
type: string
name: retrieve_data
arguments: data_tag: D28
type: string
name: retrieve_data
arguments: data_tag: D26
type: string

tool: D4: RIFF_ReadInChunkTBuf: Free %p %d


tool: D28: RIFF_ReadInChunkTBuf: Malloc %d


tool: D26: RIFF_ReadInChunkTBuf: Malloc OK %p %d


assistant: ```c
int RIFF_ReadInChunkTBuf(FILE *fd, int ofs, void **rbuf, int *rbsz) {
  int cc1, cc2, sz, sz1;
  void *buf;
  RIFF_ReadChunkInfo(fd, ofs, &cc1, &sz, &cc2);
  buf = *rbuf;
  sz1 = *rbsz;
  if (buf && ((sz + 256) > sz1)) {
    printf("RIFF_ReadInChunkTBuf: Free %p %d\n", buf, sz1);
    free(buf);
    buf = NULL;
  }
  if (!buf) {
    sz1 = sz + 32768;
    if (sz1 < 65536)
      sz1 = 65536;
    printf("RIFF_ReadInChunkTBuf: Malloc %d\n", sz1);
    buf = malloc(sz1);
    *rbuf = buf;
    *rbsz = sz1;
    printf("RIFF_ReadInChunkTBuf: Malloc OK %p %d\n", buf, sz1);
  }
  fseek(fd, ofs + 8, 0);
  fread(buf, 1, sz, fd);
  return (sz);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<ephcom_cal2jd>:
  endbr64
  pxor   %xmm1,%xmm1
  pxor   %xmm2,%xmm2
  mov    (%rdi),%eax
  mov    0x4(%rdi),%ecx
  cvtsi2sdl 0x14(%rdi),%xmm1
  movsd  D26(%rip),%xmm0
  cvtsi2sdl 0x10(%rdi),%xmm2
  divsd  %xmm0,%xmm1
  addsd  %xmm2,%xmm1
  divsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sdl 0xc(%rdi),%xmm0
  mov    0x8(%rdi),%edi
  addsd  %xmm0,%xmm1
  divsd  D25(%rip),%xmm1
  subsd  D13(%rip),%xmm1
  cmp    $0xffffffff,%esi
  je     L23
  test   %esi,%esi
  jne    L7
  cmp    $0x62d,%eax
  jg     L25
L23:
  lea    -0x9(%rcx),%esi
  pxor   %xmm0,%xmm0
  movslq %esi,%rdx
  imul   $0xffffffff92492493,%rdx,%rdx
  shr    $0x20,%rdx
  add    %esi,%edx
  sar    $0x1f,%esi
  sar    $0x2,%edx
  sub    %esi,%edx
  lea    0x1389(%rax,%rdx,1),%edx
  lea    0x0(,%rdx,8),%esi
  sub    %edx,%esi
  lea    0x3(%rsi),%edx
  cmovns %esi,%edx
  imul   $0x113,%ecx,%ecx
  imul   $0x16f,%eax,%eax
  sar    $0x2,%edx
  sub    %edx,%eax
  movslq %ecx,%rdx
  sar    $0x1f,%ecx
  imul   $0x38e38e39,%rdx,%rdx
  sar    $0x21,%rdx
  sub    %ecx,%edx
  add    %edx,%eax
  lea    0x1a64f1(%rdi,%rax,1),%eax
  cvtsi2sd %eax,%xmm0
  addsd  %xmm1,%xmm0
  ret
  xchg   %ax,%ax
L25:
  cmp    $0x62e,%eax
  jne    L7
  cmp    $0x9,%ecx
  jle    L23
  cmp    $0xa,%ecx
  jne    L7
  cmp    $0xe,%edi
  jle    L23
L7:
  lea    -0xe(%rcx),%edx
  pxor   %xmm0,%xmm0
  movslq %edx,%rsi
  sar    $0x1f,%edx
  imul   $0x2aaaaaab,%rsi,%rsi
  sar    $0x21,%rsi
  sub    %edx,%esi
  lea    0x0(,%rsi,4),%r8d
  mov    %esi,%edx
  sub    %r8d,%edx
  lea    0x12c0(%rsi,%rax,1),%r8d
  imul   $0x5b5,%r8d,%r8d
  lea    -0x2(%rcx,%rdx,4),%ecx
  imul   $0x16f,%ecx,%ecx
  movslq %ecx,%rdx
  sar    $0x1f,%ecx
  imul   $0x2aaaaaab,%rdx,%rdx
  sar    $0x21,%rdx
  sub    %ecx,%edx
  test   %r8d,%r8d
  lea    0x3(%r8),%ecx
  cmovns %r8d,%ecx
  sar    $0x2,%ecx
  add    %ecx,%edx
  lea    0x1324(%rsi,%rax,1),%ecx
  movslq %ecx,%rax
  sar    $0x1f,%ecx
  imul   $0x51eb851f,%rax,%rax
  sar    $0x25,%rax
  sub    %ecx,%eax
  lea    (%rax,%rax,2),%eax
  test   %eax,%eax
  lea    0x3(%rax),%ecx
  cmovns %eax,%ecx
  mov    %edx,%eax
  sar    $0x2,%ecx
  sub    %ecx,%eax
  lea    -0x7d4b(%rdi,%rax,1),%eax
  cvtsi2sd %eax,%xmm0
  addsd  %xmm1,%xmm0
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D26
type: f64
name: disassemble_data
arguments: data_tag: D25
type: f64
name: disassemble_data
arguments: data_tag: D13
type: f64

tool: D26: 60

tool: D25: 24

tool: D13: 0.5

assistant: ```c
double ephcom_cal2jd(int idate[6], int calendar_type) {
  double tjd;
  int jd;
  tjd = (idate[3] + (idate[4] + idate[5] / 60.0) / 60.0) / 24.0 - 0.5;
  if (calendar_type == -1 || (calendar_type == 0 && (idate[0] < 1582 || (idate[0] == 1582 && (idate[1] < 10 || (idate[1] == 10 && idate[2] < 15)))))) {
    jd = 367 * idate[0] - (7 * (idate[0] + 5001 + (idate[1] - 9) / 7)) / 4 + (275 * idate[1]) / 9 + idate[2] + 1729777;
  } else {
    jd = (1461 * (idate[0] + 4800 + (idate[1] - 14) / 12)) / 4 + (367 * (idate[1] - 2 - 12 * ((idate[1] - 14) / 12))) / 12 - (3 * ((idate[0] + 4900 + (idate[1] - 14) / 12) / 100)) / 4 + idate[2] - 32075;
  }
  tjd += (double)jd;
  return (tjd);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<f2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
L15:
  mov    $0x0,%eax
  call   <last@plt>
  test   %rax,%rax
  jne    L5
  mov    $0x0,%eax
  call   <do_it@plt>
  jmp    L15
L5:
  nop
  mov    $0x0,%eax
  call   <do_it@plt>
  nop
  pop    %rbp
  ret
```

assistant: ```c
__attribute__((no, noclone)) void f2(void) {
  while (1) {
    if (last())
      break;
    do_it();
  }
  do_it();
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  jmp    L6
L8:
  call   <do_it@plt>
L6:
  mov    $0x0,%eax
  call   <last@plt>
  test   %rax,%rax
  je     L8
  mov    $0x0,%eax
  call   <do_it@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
__attribute__((no, noclone)) void f2(void) {
  while (1) {
    if (last())
      break;
    do_it();
  }
  do_it();
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  jmp    L5
  nopw   0x0(%rax,%rax,1)
L14:
  call   <do_it@plt>
L5:
  xor    %eax,%eax
  call   <last@plt>
  test   %rax,%rax
  je     L14
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1070 <do_it@plt>
```

assistant: ```c
__attribute__((no, noclone)) void f2(void) {
  while (1) {
    if (last())
      break;
    do_it();
  }
  do_it();
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  jmp    L9
  nopw   0x0(%rax,%rax,1)
L19:
  call   <do_it@plt>
L9:
  xor    %eax,%eax
  call   <last@plt>
  test   %rax,%rax
  je     L19
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1070 <do_it@plt>
```

assistant: ```c
__attribute__((no, noclone)) void f2(void) {
  while (1) {
    if (last())
      break;
    do_it();
  }
  do_it();
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<pool_alloc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <try_pool_alloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L7
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <pool_expand@plt>
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <try_pool_alloc@plt>
  mov    %rax,-0x8(%rbp)
L7:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

assistant: ```c
uintptr_t pool_alloc(struct memory_pool *pool, size_t size) {
  uintptr_t addr;
  addr = try_pool_alloc(pool, size);
  if (addr == 0) {
    pool_expand(pool);
    addr = try_pool_alloc(pool, size);
  }
  return addr;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<pool_alloc>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  call   <try_pool_alloc@plt>
  test   %rax,%rax
  je     L5
L2:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L5:
  mov    %rbx,%rdi
  call   <pool_expand@plt>
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <try_pool_alloc@plt>
  jmp    L2
```

assistant: ```c
uintptr_t pool_alloc(struct memory_pool *pool, size_t size) {
  uintptr_t addr;
  addr = try_pool_alloc(pool, size);
  if (addr == 0) {
    pool_expand(pool);
    addr = try_pool_alloc(pool, size);
  }
  return addr;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<pool_alloc>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <try_pool_alloc@plt>
  test   %rax,%rax
  je     L2
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L2:
  mov    %rbp,%rdi
  call   <pool_expand@plt>
  add    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    1060 <try_pool_alloc@plt>
```

assistant: ```c
uintptr_t pool_alloc(struct memory_pool *pool, size_t size) {
  uintptr_t addr;
  addr = try_pool_alloc(pool, size);
  if (addr == 0) {
    pool_expand(pool);
    addr = try_pool_alloc(pool, size);
  }
  return addr;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<pool_alloc>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <try_pool_alloc@plt>
  test   %rax,%rax
  je     L8
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L8:
  mov    %rbp,%rdi
  call   <pool_expand@plt>
  add    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    1060 <try_pool_alloc@plt>
```

assistant: ```c
uintptr_t pool_alloc(struct memory_pool *pool, size_t size) {
  uintptr_t addr;
  addr = try_pool_alloc(pool, size);
  if (addr == 0) {
    pool_expand(pool);
    addr = try_pool_alloc(pool, size);
  }
  return addr;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<sam3aSendBytes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  js     L144
  cmpq   $0x0,-0x20(%rbp)
  jne    L169
  cmpl   $0x0,-0x18(%rbp)
  jle    L169
L144:
  mov    $0xffffffff,%eax
  jmp    L17
L39:
  mov    D57(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x18(%rbp),%edx
  mov    -0x8(%rbp),%rsi
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <send@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jns    L156
  mov    D15(%rip),%rax
  mov    (%rax),%rdx
  mov    D62(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L142
  jmp    L169
L142:
  mov    D15(%rip),%rax
  mov    (%rax),%rdx
  mov    D45(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L47
  mov    D15(%rip),%rax
  mov    (%rax),%rdx
  mov    D11(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L32
L47:
  cmpl   $0x1,-0x18(%rbp)
  je     L50
  mov    -0x18(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <sam3aSendBytes>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jns    L156
  mov    -0xc(%rbp),%eax
  jmp    L17
L32:
  mov    $0xffffffff,%eax
  jmp    L17
L156:
  cmpl   $0x0,-0xc(%rbp)
  je     L120
  mov    -0xc(%rbp),%eax
  cltq
  add    %rax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x18(%rbp)
  mov    -0xc(%rbp),%eax
  add    %eax,-0x10(%rbp)
L169:
  cmpl   $0x0,-0x18(%rbp)
  jg     L39
  jmp    L134
L50:
  nop
  jmp    L134
L120:
  nop
L134:
  mov    -0x10(%rbp),%eax
L17:
  leave
  ret
```

assistant: ```c
int sam3aSendBytes(int fd, const void *buf, int bufSize) {
  const char *c = (const char *)buf;
  int total = 0;
  if (fd < 0 || (buf == NULL && bufSize > 0))
    return -1;
  while (bufSize > 0) {
    int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
    if (wr < 0) {
      if (errno == EINTR)
        continue;
      if (errno == EAGAIN || errno == EWOULDBLOCK) {
        if (bufSize == 1)
          break;
        if ((wr = sam3aSendBytes(fd, c, bufSize / 2)) < 0)
          return wr;
      } else {
        return -1;
      }
    }
    if (wr == 0)
      break;
    c += wr;
    bufSize -= wr;
    total += wr;
  }
  return total;
}
```
user: What is the c source code of the assembly code below?

```asm
<sam3aSendBytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  test   %edi,%edi
  js     L144
  mov    %edi,%r13d
  mov    %rsi,%rbp
  mov    %edx,%ebx
  test   %rsi,%rsi
  jne    L166
  test   %edx,%edx
  jg     L146
L166:
  test   %ebx,%ebx
  jle    L118
  mov    $0x0,%r12d
  mov    D24(%rip),%r14
  jmp    L19
L99:
  test   %eax,%eax
  je     L12
  movslq %eax,%rdx
  add    %rdx,%rbp
  sub    %eax,%ebx
  add    %eax,%r12d
L48:
  test   %ebx,%ebx
  jle    L12
L19:
  mov    (%r14),%ecx
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r13d,%edi
  call   <send@plt>
  test   %eax,%eax
  jns    L99
  mov    D30(%rip),%rax
  mov    (%rax),%rax
  mov    D12(%rip),%rdx
  cmp    (%rdx),%rax
  je     L48
  mov    D44(%rip),%rdx
  cmp    (%rdx),%rax
  je     L79
  mov    D16(%rip),%rdx
  cmp    (%rdx),%rax
  jne    L40
L79:
  cmp    $0x1,%ebx
  je     L12
  mov    %ebx,%edx
  shr    $0x1f,%edx
  add    %ebx,%edx
  sar    %edx
  mov    %rbp,%rsi
  mov    %r13d,%edi
  call   <sam3aSendBytes>
  test   %eax,%eax
  jns    L99
  mov    %eax,%r12d
  jmp    L12
L144:
  mov    $0xffffffff,%r12d
  jmp    L12
L146:
  mov    $0xffffffff,%r12d
  jmp    L12
L118:
  mov    $0x0,%r12d
  jmp    L12
L40:
  mov    $0xffffffff,%r12d
L12:
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int sam3aSendBytes(int fd, const void *buf, int bufSize) {
  const char *c = (const char *)buf;
  int total = 0;
  if (fd < 0 || (buf == NULL && bufSize > 0))
    return -1;
  while (bufSize > 0) {
    int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
    if (wr < 0) {
      if (errno == EINTR)
        continue;
      if (errno == EAGAIN || errno == EWOULDBLOCK) {
        if (bufSize == 1)
          break;
        if ((wr = sam3aSendBytes(fd, c, bufSize / 2)) < 0)
          return wr;
      } else {
        return -1;
      }
    }
    if (wr == 0)
      break;
    c += wr;
    bufSize -= wr;
    total += wr;
  }
  return total;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sam3aSendBytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  test   %edi,%edi
  js     L9
  mov    %rsi,%r14
  mov    %edx,%r13d
  test   %rsi,%rsi
  jne    L68
  test   %edx,%edx
  jg     L9
L80:
  xor    %r12d,%r12d
L145:
  pop    %rbx
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L68:
  test   %edx,%edx
  jle    L80
  mov    D39(%rip),%rbp
  mov    %edi,%ebx
  xor    %r12d,%r12d
  jmp    L137
  nopw   0x0(%rax,%rax,1)
L33:
  test   %eax,%eax
  je     L145
  movslq %eax,%rdx
  sub    %eax,%r13d
  add    %eax,%r12d
  add    %rdx,%r14
  test   %r13d,%r13d
  jle    L145
L137:
  mov    0x0(%rbp),%ecx
  mov    %r13d,%edx
  mov    %r14,%rsi
  mov    %ebx,%edi
  call   <send@plt>
  test   %eax,%eax
  jns    L33
  mov    D6(%rip),%rax
  mov    D19(%rip),%rdx
  mov    (%rax),%rax
  cmp    (%rdx),%rax
  je     L137
  mov    D1(%rip),%rdx
  cmp    (%rdx),%rax
  je     L92
  mov    D7(%rip),%rdx
  cmp    (%rdx),%rax
  jne    L9
L92:
  cmp    $0x1,%r13d
  je     L145
  mov    %r13d,%edx
  mov    %r14,%rsi
  mov    %ebx,%edi
  sar    %edx
  call   <sam3aSendBytes>
  test   %eax,%eax
  jns    L33
  mov    %eax,%r12d
  jmp    L145
  nopl   0x0(%rax)
L9:
  mov    $0xffffffff,%r12d
  jmp    L145
```

assistant: ```c
int sam3aSendBytes(int fd, const void *buf, int bufSize) {
  const char *c = (const char *)buf;
  int total = 0;
  if (fd < 0 || (buf == NULL && bufSize > 0))
    return -1;
  while (bufSize > 0) {
    int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
    if (wr < 0) {
      if (errno == EINTR)
        continue;
      if (errno == EAGAIN || errno == EWOULDBLOCK) {
        if (bufSize == 1)
          break;
        if ((wr = sam3aSendBytes(fd, c, bufSize / 2)) < 0)
          return wr;
      } else {
        return -1;
      }
    }
    if (wr == 0)
      break;
    c += wr;
    bufSize -= wr;
    total += wr;
  }
  return total;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<sam3aSendBytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  test   %edi,%edi
  js     L30
  mov    %rsi,%r14
  mov    %edx,%r13d
  test   %rsi,%rsi
  jne    L128
  test   %edx,%edx
  jg     L30
L18:
  xor    %r12d,%r12d
L63:
  pop    %rbx
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L128:
  test   %edx,%edx
  jle    L18
  mov    D36(%rip),%rbp
  mov    %edi,%ebx
  xor    %r12d,%r12d
  jmp    L4
  nopw   0x0(%rax,%rax,1)
L55:
  test   %eax,%eax
  je     L63
  movslq %eax,%rdx
  sub    %eax,%r13d
  add    %eax,%r12d
  add    %rdx,%r14
  test   %r13d,%r13d
  jle    L63
L4:
  mov    0x0(%rbp),%ecx
  mov    %r13d,%edx
  mov    %r14,%rsi
  mov    %ebx,%edi
  call   <send@plt>
  test   %eax,%eax
  jns    L55
  mov    D14(%rip),%rax
  mov    D20(%rip),%rdx
  mov    (%rax),%rax
  cmp    (%rdx),%rax
  je     L4
  mov    D46(%rip),%rdx
  cmp    (%rdx),%rax
  je     L2
  mov    D41(%rip),%rdx
  cmp    (%rdx),%rax
  jne    L30
L2:
  cmp    $0x1,%r13d
  je     L63
  mov    %r13d,%edx
  mov    %r14,%rsi
  mov    %ebx,%edi
  sar    %edx
  call   <sam3aSendBytes>
  test   %eax,%eax
  jns    L55
  mov    %eax,%r12d
  jmp    L63
  nopl   0x0(%rax)
L30:
  mov    $0xffffffff,%r12d
  jmp    L63
```

assistant: ```c
int sam3aSendBytes(int fd, const void *buf, int bufSize) {
  const char *c = (const char *)buf;
  int total = 0;
  if (fd < 0 || (buf == NULL && bufSize > 0))
    return -1;
  while (bufSize > 0) {
    int wr = send(fd, c, bufSize, MSG_NOSIGNAL);
    if (wr < 0) {
      if (errno == EINTR)
        continue;
      if (errno == EAGAIN || errno == EWOULDBLOCK) {
        if (bufSize == 1)
          break;
        if ((wr = sam3aSendBytes(fd, c, bufSize / 2)) < 0)
          return wr;
      } else {
        return -1;
      }
    }
    if (wr == 0)
      break;
    c += wr;
    bufSize -= wr;
    total += wr;
  }
  return total;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<stringToLongArray>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  movl   $0x0,-0x20(%rbp)
  movl   $0x1,-0x1c(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  movq   $0x1,-0x8(%rbp)
  jmp    L121
L14:
  mov    -0x20(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jge    L31
  cmpl   $0x0,-0x1c(%rbp)
  jne    L50
  movsbl -0x21(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L71
  mov    -0x18(%rbp),%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  add    %rax,%rax
  mov    %rax,%rdx
  movsbl -0x21(%rbp),%eax
  sub    $0x30,%eax
  cltq
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  jmp    L121
L71:
  movl   $0x1,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  imul   -0x18(%rbp),%rax
  mov    %rax,(%rdx)
  movq   $0x0,-0x18(%rbp)
  jmp    L121
L50:
  cmpl   $0x1,-0x1c(%rbp)
  jne    L121
  cmpb   $0x2d,-0x21(%rbp)
  jne    L120
  movl   $0x0,-0x1c(%rbp)
  movq   $0xffffffffffffffff,-0x8(%rbp)
  jmp    L121
L120:
  movsbl -0x21(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L121
  movl   $0x0,-0x1c(%rbp)
  movq   $0x1,-0x8(%rbp)
  movsbl -0x21(%rbp),%eax
  sub    $0x30,%eax
  cltq
  mov    %rax,-0x18(%rbp)
L121:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x21(%rbp)
  cmpb   $0x0,-0x21(%rbp)
  jne    L14
  jmp    L39
L31:
  nop
L39:
  cmpl   $0x0,-0x1c(%rbp)
  jne    L87
  mov    -0x20(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x20(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  mov    %rax,(%rdx)
L87:
  mov    -0x20(%rbp),%eax
  leave
  ret
```

assistant: ```c
int stringToLongArray(const char *str, int n, long *values) {
  int idx = 0;
  enum State { e_num, e_sep };
  enum State state = e_sep;
  long val = 0;
  const char *p = str;
  char ch;
  long scale = 1;
  while ((ch = *p++)) {
    if (idx >= n)
      break;
    if (state == e_num) {
      if (isdigit(ch))
        val = val * 10 + (ch - '0');
      else {
        state = e_sep;
        values[idx++] = scale * val;
        val = 0;
      }
    } else if (state == e_sep) {
      if (ch == '-') {
        state = e_num;
        scale = -1;
      } else if (isdigit(ch)) {
        state = e_num;
        scale = 1;
        val = (ch - '0');
      }
    }
  }
  if (state == e_num)
    values[idx++] = val;
  return idx;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<stringToLongArray>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdx,0x8(%rsp)
  movzbl (%rdi),%ebx
  test   %esi,%esi
  jle    L11
  mov    %esi,%r14d
  lea    0x1(%rdi),%rbp
  test   %bl,%bl
  je     L11
  movq   $0x1,(%rsp)
  mov    $0x0,%r15d
  mov    $0x1,%r13d
  mov    $0x0,%r12d
  jmp    L17
L5:
  movsbl %bl,%ebx
  mov    %ebx,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L69
  lea    (%r15,%r15,4),%rax
  sub    $0x30,%ebx
  movslq %ebx,%rbx
  lea    (%rbx,%rax,2),%r15
L3:
  add    $0x1,%rbp
  movzbl -0x1(%rbp),%ebx
  cmp    %r14d,%r12d
  jge    L14
  test   %bl,%bl
  je     L14
L17:
  test   %r13d,%r13d
  je     L5
  cmp    $0x2d,%bl
  jne    L73
  movq   $0xffffffffffffffff,(%rsp)
  mov    $0x0,%r13d
  jmp    L3
L69:
  movslq %r12d,%rdx
  imul   (%rsp),%r15
  mov    0x8(%rsp),%rcx
  mov    %r15,(%rcx,%rdx,8)
  mov    %rax,%r15
  lea    0x1(%r12),%r12d
  mov    $0x1,%r13d
  jmp    L3
L73:
  movsbl %bl,%ebx
  mov    %ebx,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L3
  sub    $0x30,%ebx
  movslq %ebx,%r15
  movq   $0x1,(%rsp)
  mov    $0x0,%r13d
  jmp    L3
L14:
  test   %r13d,%r13d
  jne    L131
  movslq %r12d,%rax
  mov    0x8(%rsp),%rsi
  mov    %r15,(%rsi,%rax,8)
  lea    0x1(%r12),%r12d
L131:
  mov    %r12d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  mov    $0x0,%r12d
  jmp    L131
```

assistant: ```c
int stringToLongArray(const char *str, int n, long *values) {
  int idx = 0;
  enum State { e_num, e_sep };
  enum State state = e_sep;
  long val = 0;
  const char *p = str;
  char ch;
  long scale = 1;
  while ((ch = *p++)) {
    if (idx >= n)
      break;
    if (state == e_num) {
      if (isdigit(ch))
        val = val * 10 + (ch - '0');
      else {
        state = e_sep;
        values[idx++] = scale * val;
        val = 0;
      }
    } else if (state == e_sep) {
      if (ch == '-') {
        state = e_num;
        scale = -1;
      } else if (isdigit(ch)) {
        state = e_num;
        scale = 1;
        val = (ch - '0');
      }
    }
  }
  if (state == e_num)
    values[idx++] = val;
  return idx;
}
```