ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Demonstrate the C code that generates the assembly output below:

```asm
<betavariate>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%edi
  push   0x28(%rsp)
  push   0x28(%rsp)
  call   <gammavariate@plt>
  mov    $0x1,%edi
  fstpt  0x10(%rsp)
  push   0x48(%rsp)
  push   0x48(%rsp)
  call   <gammavariate@plt>
  fldt   0x20(%rsp)
  add    $0x38,%rsp
  fadd   %st,%st(1)
  fdivp  %st,%st(1)
  ret
```

assistant: ```c
long double betavariate(long double alpha, long double beta) {
  long double x = gammavariate(alpha, 1);
  long double y = gammavariate(beta, 1);
  return x / (x + y);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<betavariate>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x1,%edi
  push   0x28(%rsp)
  push   0x28(%rsp)
  call   <gammavariate@plt>
  mov    $0x1,%edi
  fstpt  0x10(%rsp)
  push   0x48(%rsp)
  push   0x48(%rsp)
  call   <gammavariate@plt>
  fldt   0x20(%rsp)
  add    $0x38,%rsp
  fadd   %st,%st(1)
  fdivp  %st,%st(1)
  ret
```

assistant: ```c
long double betavariate(long double alpha, long double beta) {
  long double x = gammavariate(alpha, 1);
  long double y = gammavariate(beta, 1);
  return x / (x + y);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<_compute_normal>:
  endbr64
  mov    %rdi,%rcx
  mov    0xc(%rsi),%edx
  sub    (%rsi),%edx
  mov    0x10(%rsi),%edi
  sub    0x4(%rsi),%edi
  mov    0x8(%rsi),%r11d
  mov    0x14(%rsi),%r8d
  sub    %r11d,%r8d
  mov    0x18(%rsi),%r9d
  sub    (%rsi),%r9d
  mov    0x1c(%rsi),%r10d
  sub    0x4(%rsi),%r10d
  mov    0x20(%rsi),%eax
  sub    %r11d,%eax
  mov    %edi,%esi
  imul   %eax,%esi
  mov    %r8d,%r11d
  imul   %r10d,%r11d
  sub    %r11d,%esi
  pxor   %xmm2,%xmm2
  cvtsi2sd %esi,%xmm2
  movsd  %xmm2,(%rcx)
  imul   %edx,%eax
  imul   %r9d,%r8d
  sub    %r8d,%eax
  pxor   %xmm3,%xmm3
  cvtsi2sd %eax,%xmm3
  movsd  %xmm3,0x8(%rcx)
  imul   %r10d,%edx
  imul   %r9d,%edi
  sub    %edi,%edx
  pxor   %xmm1,%xmm1
  cvtsi2sd %edx,%xmm1
  movsd  %xmm1,0x10(%rcx)
  movapd %xmm2,%xmm0
  cmp    %eax,%esi
  jg     L37
  movapd %xmm3,%xmm0
L37:
  maxsd  %xmm1,%xmm0
  ucomisd D6(%rip),%xmm0
  jp     L27
  jne    L27
L35:
  ret
L27:
  divsd  %xmm0,%xmm2
  movsd  %xmm2,(%rcx)
  divsd  %xmm0,%xmm3
  movsd  %xmm3,0x8(%rcx)
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x10(%rcx)
  jmp    L35
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D6
type: f64

tool: D6: 0

assistant: ```c
void _compute_normal(double normal[3], const int voxes[9]) {
  int vox_a[3] = {voxes[3 + 0] - voxes[0 + 0], voxes[3 + 1] - voxes[0 + 1], voxes[3 + 2] - voxes[0 + 2]};
  int vox_b[3] = {voxes[6 + 0] - voxes[0 + 0], voxes[6 + 1] - voxes[0 + 1], voxes[6 + 2] - voxes[0 + 2]};
  normal[0] = vox_a[1] * vox_b[2] - vox_a[2] * vox_b[1];
  normal[1] = vox_a[0] * vox_b[2] - vox_a[2] * vox_b[0];
  normal[2] = vox_a[0] * vox_b[1] - vox_a[1] * vox_b[0];
  double _max = normal[0] > normal[1] ? normal[0] : normal[1];
  double max = _max > normal[2] ? _max : normal[2];
  if (max != 0.0) {
    normal[0] /= max;
    normal[1] /= max;
    normal[2] /= max;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<_compute_normal>:
  endbr64
  mov    0x8(%rsi),%r11d
  mov    0x14(%rsi),%r8d
  mov    %rdi,%rcx
  pxor   %xmm2,%xmm2
  mov    0x20(%rsi),%eax
  mov    0x10(%rsi),%edi
  pxor   %xmm3,%xmm3
  pxor   %xmm1,%xmm1
  sub    0x4(%rsi),%edi
  sub    %r11d,%r8d
  mov    0xc(%rsi),%edx
  mov    0x18(%rsi),%r9d
  sub    (%rsi),%edx
  sub    %r11d,%eax
  mov    %r8d,%r11d
  sub    (%rsi),%r9d
  mov    0x1c(%rsi),%r10d
  sub    0x4(%rsi),%r10d
  imul   %r9d,%r8d
  mov    %edi,%esi
  imul   %eax,%esi
  imul   %r10d,%r11d
  imul   %edx,%eax
  imul   %r9d,%edi
  imul   %r10d,%edx
  sub    %r11d,%esi
  sub    %r8d,%eax
  cvtsi2sd %esi,%xmm2
  cvtsi2sd %eax,%xmm3
  sub    %edi,%edx
  cvtsi2sd %edx,%xmm1
  movsd  %xmm2,(%rcx)
  movapd %xmm2,%xmm0
  movsd  %xmm3,0x8(%rcx)
  movsd  %xmm1,0x10(%rcx)
  cmp    %eax,%esi
  jg     L2
  movapd %xmm3,%xmm0
L2:
  maxsd  %xmm1,%xmm0
  ucomisd D4(%rip),%xmm0
  jp     L26
  jne    L26
  ret
  nopl   0x0(%rax,%rax,1)
L26:
  divsd  %xmm0,%xmm2
  divsd  %xmm0,%xmm3
  movsd  %xmm2,(%rcx)
  divsd  %xmm0,%xmm1
  movsd  %xmm3,0x8(%rcx)
  movsd  %xmm1,0x10(%rcx)
  ret
```

tool_calls: name: disassemble_data
arguments: label: D4
type_guessed: f64

tool: D4: 0

assistant: ```c
void _compute_normal(double normal[3], const int voxes[9]) {
  int vox_a[3] = {voxes[3 + 0] - voxes[0 + 0], voxes[3 + 1] - voxes[0 + 1], voxes[3 + 2] - voxes[0 + 2]};
  int vox_b[3] = {voxes[6 + 0] - voxes[0 + 0], voxes[6 + 1] - voxes[0 + 1], voxes[6 + 2] - voxes[0 + 2]};
  normal[0] = vox_a[1] * vox_b[2] - vox_a[2] * vox_b[1];
  normal[1] = vox_a[0] * vox_b[2] - vox_a[2] * vox_b[0];
  normal[2] = vox_a[0] * vox_b[1] - vox_a[1] * vox_b[0];
  double _max = normal[0] > normal[1] ? normal[0] : normal[1];
  double max = _max > normal[2] ? _max : normal[2];
  if (max != 0.0) {
    normal[0] /= max;
    normal[1] /= max;
    normal[2] /= max;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<_compute_normal>:
  endbr64
  mov    0x8(%rsi),%r10d
  mov    0xc(%rsi),%eax
  pxor   %xmm3,%xmm3
  sub    (%rsi),%eax
  mov    0x10(%rsi),%edx
  mov    0x14(%rsi),%ecx
  sub    0x4(%rsi),%edx
  mov    %eax,%r11d
  mov    0x18(%rsi),%r8d
  mov    0x1c(%rsi),%r9d
  sub    (%rsi),%r8d
  sub    0x4(%rsi),%r9d
  sub    %r10d,%ecx
  mov    0x20(%rsi),%esi
  imul   %r9d,%eax
  sub    %r10d,%esi
  imul   %esi,%r11d
  imul   %edx,%esi
  imul   %r8d,%edx
  movd   %r11d,%xmm0
  movd   %esi,%xmm6
  mov    %ecx,%esi
  imul   %r8d,%esi
  punpckldq %xmm6,%xmm0
  sub    %edx,%eax
  imul   %r9d,%ecx
  cvtsi2sd %eax,%xmm3
  movd   %esi,%xmm1
  movd   %ecx,%xmm7
  punpckldq %xmm7,%xmm1
  psubd  %xmm1,%xmm0
  movsd  %xmm3,0x10(%rdi)
  cvtdq2pd %xmm0,%xmm1
  movapd %xmm1,%xmm5
  movapd %xmm1,%xmm4
  movd   %xmm0,%edx
  unpckhpd %xmm5,%xmm5
  pshufd $0xe5,%xmm0,%xmm6
  movd   %xmm6,%eax
  shufpd $0x1,%xmm1,%xmm4
  movapd %xmm5,%xmm2
  movups %xmm4,(%rdi)
  cmp    %eax,%edx
  jl     L29
  movapd %xmm1,%xmm2
L29:
  maxsd  %xmm3,%xmm2
  ucomisd D9(%rip),%xmm2
  movapd %xmm2,%xmm0
  unpcklpd %xmm0,%xmm0
  jp     L6
  jne    L6
  ret
L6:
  divpd  %xmm0,%xmm4
  divsd  %xmm2,%xmm3
  movups %xmm4,(%rdi)
  movsd  %xmm3,0x10(%rdi)
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D9
data_type: f64

tool: D9: 0

assistant: ```c
void _compute_normal(double normal[3], const int voxes[9]) {
  int vox_a[3] = {voxes[3 + 0] - voxes[0 + 0], voxes[3 + 1] - voxes[0 + 1], voxes[3 + 2] - voxes[0 + 2]};
  int vox_b[3] = {voxes[6 + 0] - voxes[0 + 0], voxes[6 + 1] - voxes[0 + 1], voxes[6 + 2] - voxes[0 + 2]};
  normal[0] = vox_a[1] * vox_b[2] - vox_a[2] * vox_b[1];
  normal[1] = vox_a[0] * vox_b[2] - vox_a[2] * vox_b[0];
  normal[2] = vox_a[0] * vox_b[1] - vox_a[1] * vox_b[0];
  double _max = normal[0] > normal[1] ? normal[0] : normal[1];
  double max = _max > normal[2] ? _max : normal[2];
  if (max != 0.0) {
    normal[0] /= max;
    normal[1] /= max;
    normal[2] /= max;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<COM_StripExtension>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  jmp    L17
L0:
  mov    -0x8(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x10(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
L17:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L25
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L0
L25:
  mov    -0x10(%rbp),%rax
  movb   $0x0,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void COM_StripExtension(char *in, char *out) {
  while (*in && *in != '.') {
    *out++ = *in++;
  }
  *out = 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<COM_StripExtension>:
  endbr64
  movzbl (%rdi),%eax
  test   %al,%al
  je     L15
  cmp    $0x2e,%al
  je     L15
L38:
  add    $0x1,%rdi
  add    $0x1,%rsi
  mov    %al,-0x1(%rsi)
  movzbl (%rdi),%eax
  test   %al,%al
  je     L15
  cmp    $0x2e,%al
  jne    L38
L15:
  movb   $0x0,(%rsi)
  ret
```

assistant: ```c
void COM_StripExtension(char *in, char *out) {
  while (*in && *in != '.') {
    *out++ = *in++;
  }
  *out = 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<COM_StripExtension>:
  endbr64
  jmp    L17
  cs nopw 0x0(%rax,%rax,1)
L23:
  mov    %al,(%rsi)
  add    $0x1,%rsi
  add    $0x1,%rdi
L17:
  movzbl (%rdi),%eax
  test   %al,%al
  je     L24
  cmp    $0x2e,%al
  jne    L23
L24:
  movb   $0x0,(%rsi)
  ret
```

assistant: ```c
void COM_StripExtension(char *in, char *out) {
  while (*in && *in != '.') {
    *out++ = *in++;
  }
  *out = 0;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<COM_StripExtension>:
  endbr64
  jmp    L3
  cs nopw 0x0(%rax,%rax,1)
L7:
  mov    %al,(%rsi)
  add    $0x1,%rsi
  add    $0x1,%rdi
L3:
  movzbl (%rdi),%eax
  test   %al,%al
  je     L15
  cmp    $0x2e,%al
  jne    L7
L15:
  movb   $0x0,(%rsi)
  ret
```

assistant: ```c
void COM_StripExtension(char *in, char *out) {
  while (*in && *in != '.') {
    *out++ = *in++;
  }
  *out = 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<EEPROMInit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  mov    $0x0,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    $0x400af01c,%eax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  and    $0xc,%eax
  test   %eax,%eax
  je     L32
  mov    $0xf0005800,%edi
  call   <SysCtlPeripheralReset@plt>
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  mov    $0x0,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    $0x400af01c,%eax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  and    $0xc,%eax
  test   %eax,%eax
  je     L24
  mov    $0x2,%eax
  jmp    L11
L24:
  mov    $0x1,%eax
  jmp    L11
L32:
  mov    $0x0,%eax
L11:
  leave
  ret
```

assistant: ```c
uint32_t EEPROMInit(void) {
  uint32_t ui32Status;
  SysCtlDelay(2);
  _EEPROMWaitForDone();
  ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
  if (ui32Status & (0x00000008 | 0x00000004)) {
    SysCtlPeripheralReset(0xf0005800);
    SysCtlDelay(2);
    _EEPROMWaitForDone();
    ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
    if (ui32Status & (0x00000008 | 0x00000004)) {
      return (2);
    } else {
      return (1);
    }
  }
  return (0);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<EEPROMInit>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  mov    $0x0,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  jne    L1
L2:
  add    $0x8,%rsp
  ret
L1:
  mov    $0xf0005800,%edi
  call   <SysCtlPeripheralReset@plt>
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  mov    $0x0,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  cmp    $0x1,%eax
  mov    $0x1,%eax
  sbb    $0xffffffff,%eax
  jmp    L2
```

assistant: ```c
uint32_t EEPROMInit(void) {
  uint32_t ui32Status;
  SysCtlDelay(2);
  _EEPROMWaitForDone();
  ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
  if (ui32Status & (0x00000008 | 0x00000004)) {
    SysCtlPeripheralReset(0xf0005800);
    SysCtlDelay(2);
    _EEPROMWaitForDone();
    ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
    if (ui32Status & (0x00000008 | 0x00000004)) {
      return (2);
    } else {
      return (1);
    }
  }
  return (0);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<EEPROMInit>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  xor    %eax,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  jne    L3
  add    $0x8,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L3:
  mov    $0xf0005800,%edi
  call   <SysCtlPeripheralReset@plt>
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  xor    %eax,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  cmp    $0x1,%eax
  mov    $0x1,%eax
  sbb    $0xffffffff,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
uint32_t EEPROMInit(void) {
  uint32_t ui32Status;
  SysCtlDelay(2);
  _EEPROMWaitForDone();
  ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
  if (ui32Status & (0x00000008 | 0x00000004)) {
    SysCtlPeripheralReset(0xf0005800);
    SysCtlDelay(2);
    _EEPROMWaitForDone();
    ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
    if (ui32Status & (0x00000008 | 0x00000004)) {
      return (2);
    } else {
      return (1);
    }
  }
  return (0);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<EEPROMInit>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  xor    %eax,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  jne    L0
  add    $0x8,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  mov    $0xf0005800,%edi
  call   <SysCtlPeripheralReset@plt>
  mov    $0x2,%edi
  call   <SysCtlDelay@plt>
  xor    %eax,%eax
  call   <_EEPROMWaitForDone@plt>
  mov    0x400af01c,%eax
  and    $0xc,%eax
  cmp    $0x1,%eax
  mov    $0x1,%eax
  sbb    $0xffffffff,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
uint32_t EEPROMInit(void) {
  uint32_t ui32Status;
  SysCtlDelay(2);
  _EEPROMWaitForDone();
  ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
  if (ui32Status & (0x00000008 | 0x00000004)) {
    SysCtlPeripheralReset(0xf0005800);
    SysCtlDelay(2);
    _EEPROMWaitForDone();
    ui32Status = (*((volatile uint32_t *)(0x400AF01C)));
    if (ui32Status & (0x00000008 | 0x00000004)) {
      return (2);
    } else {
      return (1);
    }
  }
  return (0);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<ppdirbackward>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
L57:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L15
  mov    -0x8(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  jne    L15
  subq   $0x1,-0x8(%rbp)
  jmp    L15
L52:
  mov    -0x8(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L9
  mov    -0x8(%rbp),%rax
  jmp    L7
L9:
  subq   $0x1,-0x8(%rbp)
L15:
  mov    -0x8(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jbe    L91
  mov    -0x8(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  je     L91
  mov    -0x8(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L52
L91:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x23,%al
  je     L2
  mov    -0x18(%rbp),%rax
  jmp    L7
L2:
  subq   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L57
L7:
  pop    %rbp
  ret
```

assistant: ```c
char *ppdirbackward(p, limit)
char *p;
char *limit;
{
  char *np = p;
  for (;; p = --np) {
    if (*np == '\n' && np[-1] == '\r')
      --np;
    for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
      if (np[-1] == 0)
        return np;
    if (*np != '#')
      return p;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<ppdirbackward>:
  endbr64
  jmp    L48
L78:
  cmpb   $0xd,-0x1(%rdi)
  je     L11
  cmp    %rsi,%rdi
  jbe    L43
  mov    %rdi,%rax
  jmp    L59
L11:
  lea    -0x1(%rdi),%rax
  jmp    L62
L0:
  cmpb   $0x23,(%rax)
  jne    L126
  lea    -0x1(%rax),%rdi
L48:
  mov    %rdi,%rax
  cmpb   $0xa,(%rdi)
  je     L78
L62:
  cmp    %rax,%rsi
  jae    L0
L59:
  movzbl -0x1(%rax),%edx
  cmp    $0xa,%dl
  je     L0
  cmp    $0xd,%dl
  je     L0
  test   %dl,%dl
  je     L43
  sub    $0x1,%rax
  cmp    %rax,%rsi
  jb     L59
  jmp    L0
L126:
  mov    %rdi,%rax
  ret
L43:
  ret
```

assistant: ```c
char *ppdirbackward(p, limit)
char *p;
char *limit;
{
  char *np = p;
  for (;; p = --np) {
    if (*np == '\n' && np[-1] == '\r')
      --np;
    for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
      if (np[-1] == 0)
        return np;
    if (*np != '#')
      return p;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ppdirbackward>:
  endbr64
  cmpb   $0xa,(%rdi)
  mov    %rdi,%rax
  je     L114
L55:
  cmp    %rax,%rsi
  jb     L36
  jmp    L15
  nopl   0x0(%rax,%rax,1)
L25:
  cmp    $0xa,%dl
  je     L15
  test   %dl,%dl
  je     L74
  sub    $0x1,%rax
  cmp    %rax,%rsi
  jae    L35
L36:
  movzbl -0x1(%rax),%edx
L85:
  cmp    $0xd,%dl
  jne    L25
L15:
  movzbl (%rax),%edx
L35:
  cmp    $0x23,%dl
  jne    L8
  lea    -0x1(%rax),%rdi
  cmpb   $0xa,(%rdi)
  mov    %rdi,%rax
  jne    L55
L114:
  movzbl -0x1(%rdi),%edx
  cmp    $0xd,%dl
  je     L22
  cmp    %rsi,%rdi
  ja     L85
L74:
  ret
  cs nopw 0x0(%rax,%rax,1)
L22:
  lea    -0x1(%rdi),%rax
  jmp    L55
L8:
  mov    %rdi,%rax
  ret
```

assistant: ```c
char *ppdirbackward(p, limit)
char *p;
char *limit;
{
  char *np = p;
  for (;; p = --np) {
    if (*np == '\n' && np[-1] == '\r')
      --np;
    for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
      if (np[-1] == 0)
        return np;
    if (*np != '#')
      return p;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<ppdirbackward>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0xa,%al
  je     L17
L12:
  mov    %rdi,%r8
  cmp    %rsi,%rdi
  ja     L77
  jmp    L55
  nopl   (%rax)
L119:
  cmp    $0xa,%al
  je     L62
  test   %al,%al
  je     L93
  sub    $0x1,%r8
  cmp    %r8,%rsi
  jae    L55
L77:
  movzbl -0x1(%r8),%eax
L36:
  cmp    $0xd,%al
  jne    L119
L62:
  movzbl (%r8),%eax
L55:
  cmp    $0x23,%al
  jne    L67
  movzbl -0x1(%r8),%eax
  lea    -0x1(%r8),%rdi
  cmp    $0xa,%al
  jne    L12
L17:
  movzbl -0x1(%rdi),%eax
  cmp    $0xd,%al
  je     L31
  mov    %rdi,%r8
  cmp    %rsi,%rdi
  ja     L36
L93:
  mov    %r8,%rax
  ret
  nopl   0x0(%rax,%rax,1)
L31:
  lea    -0x1(%rdi),%r8
  cmp    %rsi,%r8
  ja     L77
L67:
  mov    %rdi,%r8
  jmp    L93
```

assistant: ```c
char *ppdirbackward(p, limit)
char *p;
char *limit;
{
  char *np = p;
  for (;; p = --np) {
    if (*np == '\n' && np[-1] == '\r')
      --np;
    for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
      if (np[-1] == 0)
        return np;
    if (*np != '#')
      return p;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<permute_args>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %esi,-0x38(%rbp)
  mov    %edx,-0x3c(%rbp)
  mov    %rcx,-0x48(%rbp)
  mov    -0x38(%rbp),%eax
  sub    -0x34(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x3c(%rbp),%eax
  sub    -0x38(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <gcd@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x3c(%rbp),%eax
  sub    -0x34(%rbp),%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L39
L29:
  mov    -0x38(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  movl   $0x0,-0x24(%rbp)
  jmp    L53
L26:
  mov    -0x20(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L49
  mov    -0x1c(%rbp),%eax
  sub    %eax,-0x20(%rbp)
  jmp    L0
L49:
  mov    -0x18(%rbp),%eax
  add    %eax,-0x20(%rbp)
L0:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x48(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rax,(%rdx)
  addl   $0x1,-0x24(%rbp)
L53:
  mov    -0x24(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L26
  addl   $0x1,-0x28(%rbp)
L39:
  mov    -0x28(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L29
  nop
  nop
  leave
  ret
```

assistant: ```c
void permute_args(nonopt_start, nonopt_end, opt_end, nargv) int nonopt_start;
int nonopt_end;
int opt_end;
char *const *nargv;
{
  int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
  char *swap;
  nnonopts = nonopt_end - nonopt_start;
  nopts = opt_end - nonopt_end;
  ncycle = gcd(nnonopts, nopts);
  cyclelen = (opt_end - nonopt_start) / ncycle;
  for (i = 0; i < ncycle; i++) {
    cstart = nonopt_end + i;
    pos = cstart;
    for (j = 0; j < cyclelen; j++) {
      if (pos >= nonopt_end)
        pos -= nnonopts;
      else
        pos += nopts;
      swap = nargv[pos];
      ((char **)nargv)[pos] = nargv[cstart];
      ((char **)nargv)[cstart] = swap;
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<permute_args>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%r15d
  mov    %esi,%ebx
  mov    %edx,%r14d
  mov    %rcx,%rbp
  mov    %esi,%r12d
  sub    %edi,%r12d
  mov    %edx,%r13d
  sub    %esi,%r13d
  mov    %r13d,%esi
  mov    %r12d,%edi
  mov    $0x0,%eax
  call   <gcd@plt>
  mov    %eax,%r11d
  mov    %r14d,%eax
  sub    %r15d,%eax
  cltd
  idiv   %r11d
  test   %r11d,%r11d
  jle    L28
  movslq %ebx,%rdx
  lea    0x0(%rbp,%rdx,8),%rdi
  mov    %ebx,%r10d
  add    %ebx,%r11d
L4:
  mov    %r10d,%edx
  test   %eax,%eax
  jle    L35
  mov    $0x0,%ecx
L39:
  mov    %edx,%esi
  sub    %r12d,%esi
  lea    (%rdx,%r13,1),%r8d
  cmp    %edx,%ebx
  mov    %esi,%edx
  cmovg  %r8d,%edx
  movslq %edx,%rsi
  lea    0x0(%rbp,%rsi,8),%rsi
  mov    (%rsi),%r8
  mov    (%rdi),%r9
  mov    %r9,(%rsi)
  mov    %r8,(%rdi)
  add    $0x1,%ecx
  cmp    %ecx,%eax
  jne    L39
L35:
  add    $0x8,%rdi
  add    $0x1,%r10d
  cmp    %r11d,%r10d
  jne    L4
L28:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void permute_args(nonopt_start, nonopt_end, opt_end, nargv) int nonopt_start;
int nonopt_end;
int opt_end;
char *const *nargv;
{
  int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
  char *swap;
  nnonopts = nonopt_end - nonopt_start;
  nopts = opt_end - nonopt_end;
  ncycle = gcd(nnonopts, nopts);
  cyclelen = (opt_end - nonopt_start) / ncycle;
  for (i = 0; i < ncycle; i++) {
    cstart = nonopt_end + i;
    pos = cstart;
    for (j = 0; j < cyclelen; j++) {
      if (pos >= nonopt_end)
        pos -= nnonopts;
      else
        pos += nopts;
      swap = nargv[pos];
      ((char **)nargv)[pos] = nargv[cstart];
      ((char **)nargv)[cstart] = swap;
    }
  }
}
```