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

```asm
<executable_path>:
  endbr64
  push   %rbp
  mov    $0x400,%edx
  lea    D2(%rip),%rdi
  push   %rbx
  sub    $0x418,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  mov    %rbp,%rsi
  call   <readlink@plt>
  lea    0x1(%rax),%edi
  mov    %eax,%ebx
  call   <malloc@plt>
  mov    %rax,%r8
  test   %ebx,%ebx
  jle    L149
  lea    0x1(%rsp),%rsi
  mov    %r8,%rdx
  lea    -0x1(%rbx),%eax
  mov    %ebx,%ecx
  sub    %rsi,%rdx
  cmp    $0xe,%rdx
  jbe    L60
  cmp    $0x6,%eax
  jbe    L60
  cmp    $0xe,%eax
  jbe    L46
  mov    %ebx,%edx
  xor    %eax,%eax
  shr    $0x4,%edx
  shl    $0x4,%rdx
  nopl   0x0(%rax,%rax,1)
L94:
  movdqa 0x0(%rbp,%rax,1),%xmm0
  movups %xmm0,(%r8,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L94
  mov    %ebx,%edx
  and    $0xfffffff0,%edx
  mov    %edx,%eax
  cmp    %edx,%ebx
  je     L149
  mov    %ebx,%ecx
  sub    %edx,%ecx
  lea    -0x1(%rcx),%esi
  cmp    $0x6,%esi
  jbe    L56
L8:
  mov    (%rsp,%rdx,1),%rsi
  mov    %rsi,(%r8,%rdx,1)
  mov    %ecx,%edx
  and    $0xfffffff8,%edx
  add    %edx,%eax
  cmp    %edx,%ecx
  je     L149
L56:
  movslq %eax,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x1(%rax),%edx
  cmp    %edx,%ebx
  jle    L149
  movslq %edx,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x2(%rax),%edx
  cmp    %edx,%ebx
  jle    L149
  movslq %edx,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x3(%rax),%edx
  cmp    %edx,%ebx
  jle    L149
  movslq %edx,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x4(%rax),%edx
  cmp    %edx,%ebx
  jle    L149
  movslq %edx,%rdx
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x5(%rax),%edx
  cmp    %edx,%ebx
  jle    L149
  movslq %edx,%rdx
  add    $0x6,%eax
  movzbl (%rsp,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  cmp    %eax,%ebx
  jle    L149
  cltq
  movzbl (%rsp,%rax,1),%edx
  mov    %dl,(%r8,%rax,1)
L149:
  movslq %ebx,%rbx
  movb   $0x0,(%r8,%rbx,1)
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  add    $0x418,%rsp
  mov    %r8,%rax
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L60:
  mov    %ebx,%ecx
  xor    %eax,%eax
  nopl   0x0(%rax)
L122:
  movzbl 0x0(%rbp,%rax,1),%edx
  mov    %dl,(%r8,%rax,1)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L122
  jmp    L149
L46:
  xor    %edx,%edx
  xor    %eax,%eax
  jmp    L8
L53:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D2
type: string

tool: D2: /proc/self/exe

assistant: ```c
char *executable_path() {
  char buf[1024];
  ssize_t n = readlink("/proc/self/exe", buf, 1024);
  char *out = malloc(sizeof(char) * (n + 1));
  for (int i = 0; i < n; i++) {
    out[i] = buf[i];
  }
  out[n] = '\0';
  return out;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<validate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L10
L14:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    0x8(%rax),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <classify@plt>
  mov    %eax,-0x4(%rbp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x4(%rbp),%xmm0
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm1
  ucomisd %xmm1,%xmm0
  jp     L17
  ucomisd %xmm1,%xmm0
  jne    L17
  addl   $0x1,-0xc(%rbp)
  jmp    L48
L17:
  addl   $0x1,-0x8(%rbp)
L48:
  addl   $0x1,-0x10(%rbp)
L10:
  mov    -0x10(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L14
  mov    -0x24(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D8(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D8
datatype: string

tool: D8: We get %d correct judgements among %d pictures



assistant: ```c
void validate(double **trainingData, double weight[10][784], int trainingPicNum) {
  int ctr0, ctr1;
  int correctRes = 0, wrongRes = 0;
  for (ctr0 = 0; ctr0 < trainingPicNum; ctr0++) {
    int resIndex = classify(trainingData[ctr0] + 1, weight);
    if (resIndex == trainingData[ctr0][0]) {
      correctRes++;
    } else {
      wrongRes++;
    }
  }
  printf("We get %d correct judgements among %d pictures\n\n", correctRes, trainingPicNum);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<validate>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%r14d
  test   %edx,%edx
  jle    L27
  mov    %rsi,%rbp
  mov    %rdi,%rbx
  lea    -0x1(%rdx),%eax
  lea    0x8(%rdi,%rax,8),%r13
  mov    $0x0,%r12d
  jmp    L9
L19:
  add    $0x8,%rbx
  cmp    %r13,%rbx
  je     L28
L9:
  mov    (%rbx),%rax
  lea    0x8(%rax),%rdi
  mov    %rbp,%rsi
  call   <classify@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mov    (%rbx),%rax
  ucomisd (%rax),%xmm0
  jp     L19
  jne    L19
  add    $0x1,%r12d
  jmp    L19
L27:
  mov    $0x0,%r12d
L28:
  mov    %r14d,%edx
  mov    %r12d,%esi
  lea    D7(%rip),%rdi
  call   <printf@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D7
type_guessed: string

tool: D7: We get %d correct judgements among %d pictures



assistant: ```c
void validate(double **trainingData, double weight[10][784], int trainingPicNum) {
  int ctr0, ctr1;
  int correctRes = 0, wrongRes = 0;
  for (ctr0 = 0; ctr0 < trainingPicNum; ctr0++) {
    int resIndex = classify(trainingData[ctr0] + 1, weight);
    if (resIndex == trainingData[ctr0][0]) {
      correctRes++;
    } else {
      wrongRes++;
    }
  }
  printf("We get %d correct judgements among %d pictures\n\n", correctRes, trainingPicNum);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<validate>:
  endbr64
  push   %r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  test   %edx,%edx
  jle    L3
  lea    -0x1(%rdx),%eax
  mov    %rsi,%rbp
  mov    %rdi,%rbx
  xor    %r12d,%r12d
  lea    0x8(%rdi,%rax,8),%r14
  nopl   0x0(%rax)
L31:
  mov    (%rbx),%rax
  mov    %rbp,%rsi
  lea    0x8(%rax),%rdi
  call   <classify@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mov    (%rbx),%rax
  ucomisd (%rax),%xmm0
  jp     L24
  jne    L24
  add    $0x1,%r12d
L24:
  add    $0x8,%rbx
  cmp    %r14,%rbx
  jne    L31
L46:
  pop    %rbx
  mov    %r13d,%edx
  pop    %rbp
  mov    %r12d,%esi
  lea    D8(%rip),%rdi
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1060 <printf@plt>
  nopl   0x0(%rax)
L3:
  xor    %r12d,%r12d
  jmp    L46
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D8
type_guessed: string

tool: D8: We get %d correct judgements among %d pictures



assistant: ```c
void validate(double **trainingData, double weight[10][784], int trainingPicNum) {
  int ctr0, ctr1;
  int correctRes = 0, wrongRes = 0;
  for (ctr0 = 0; ctr0 < trainingPicNum; ctr0++) {
    int resIndex = classify(trainingData[ctr0] + 1, weight);
    if (resIndex == trainingData[ctr0][0]) {
      correctRes++;
    } else {
      wrongRes++;
    }
  }
  printf("We get %d correct judgements among %d pictures\n\n", correctRes, trainingPicNum);
}
```
user: What is the c source code of the assembly code below?

```asm
<validate>:
  endbr64
  push   %r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  test   %edx,%edx
  jle    L31
  lea    -0x1(%rdx),%eax
  mov    %rsi,%rbp
  mov    %rdi,%rbx
  xor    %r12d,%r12d
  lea    0x8(%rdi,%rax,8),%r14
  nopl   0x0(%rax)
L9:
  mov    (%rbx),%rax
  mov    %rbp,%rsi
  lea    0x8(%rax),%rdi
  call   <classify@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mov    (%rbx),%rax
  ucomisd (%rax),%xmm0
  jp     L7
  jne    L7
  add    $0x1,%r12d
L7:
  add    $0x8,%rbx
  cmp    %r14,%rbx
  jne    L9
L6:
  pop    %rbx
  mov    %r13d,%edx
  pop    %rbp
  mov    %r12d,%esi
  lea    D2(%rip),%rdi
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1060 <printf@plt>
  nopl   0x0(%rax)
L31:
  xor    %r12d,%r12d
  jmp    L6
```

tool_calls: name: retrieve_data
arguments: tag: D2
type_infered: string

tool: D2: We get %d correct judgements among %d pictures



assistant: ```c
void validate(double **trainingData, double weight[10][784], int trainingPicNum) {
  int ctr0, ctr1;
  int correctRes = 0, wrongRes = 0;
  for (ctr0 = 0; ctr0 < trainingPicNum; ctr0++) {
    int resIndex = classify(trainingData[ctr0] + 1, weight);
    if (resIndex == trainingData[ctr0][0]) {
      correctRes++;
    } else {
      wrongRes++;
    }
  }
  printf("We get %d correct judgements among %d pictures\n\n", correctRes, trainingPicNum);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<ShiftRows>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x54(%rbp)
  jmp    L18
L45:
  mov    -0x54(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x54(%rbp),%eax
  cltq
  mov    %edx,-0x50(%rbp,%rax,4)
  addl   $0x1,-0x54(%rbp)
L18:
  cmpl   $0xf,-0x54(%rbp)
  jle    L45
  movl   $0x0,-0x54(%rbp)
  jmp    L11
L2:
  mov    -0x54(%rbp),%eax
  cltd
  shr    $0x1e,%edx
  add    %edx,%eax
  and    $0x3,%eax
  sub    %edx,%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x54(%rbp),%eax
  add    %edx,%eax
  cltd
  shr    $0x1c,%edx
  add    %edx,%eax
  and    $0xf,%eax
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x54(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x68(%rbp),%rax
  add    %rax,%rdx
  movslq %ecx,%rax
  mov    -0x50(%rbp,%rax,4),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x54(%rbp)
L11:
  cmpl   $0xf,-0x54(%rbp)
  jle    L2
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L27
  call   <__stack_chk_fail@plt>
L27:
  leave
  ret
```

assistant: ```c
void ShiftRows(uint8_t InValue[]) {
  uint8_t TempValue[16];
  uint8_t i;
  for (i = 0; i < 16; i++) {
    TempValue[i] = InValue[i];
  }
  for (i = 0; i < 16; i++) {
    InValue[i] = TempValue[(i + ((i % 4) * 4)) % 16];
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<ShiftRows>:
  endbr64
  sub    $0x58,%rsp
  mov    %rdi,%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
L18:
  mov    (%rsi,%rax,1),%edx
  mov    %edx,(%rsp,%rax,1)
  add    $0x4,%rax
  cmp    $0x40,%rax
  jne    L18
  mov    $0x0,%edx
L11:
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  shr    $0x1e,%ecx
  lea    (%rcx,%rdx,1),%eax
  and    $0x3,%eax
  sub    %ecx,%eax
  lea    (%rdx,%rax,4),%eax
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  shr    $0x1c,%ecx
  add    %ecx,%eax
  and    $0xf,%eax
  sub    %ecx,%eax
  cltq
  mov    (%rsp,%rax,4),%eax
  mov    %eax,(%rsi,%rdx,4)
  add    $0x1,%rdx
  cmp    $0x10,%rdx
  jne    L11
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L23
  add    $0x58,%rsp
  ret
L23:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ShiftRows(uint8_t InValue[]) {
  uint8_t TempValue[16];
  uint8_t i;
  for (i = 0; i < 16; i++) {
    TempValue[i] = InValue[i];
  }
  for (i = 0; i < 16; i++) {
    InValue[i] = TempValue[(i + ((i % 4) * 4)) % 16];
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<ShiftRows>:
  endbr64
  sub    $0x58,%rsp
  movdqu (%rdi),%xmm0
  movdqu 0x10(%rdi),%xmm1
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  movdqu 0x20(%rdi),%xmm2
  movdqu 0x30(%rdi),%xmm3
  movaps %xmm0,(%rsp)
  movaps %xmm1,0x10(%rsp)
  movaps %xmm2,0x20(%rsp)
  movaps %xmm3,0x30(%rsp)
  xchg   %ax,%ax
L9:
  lea    (%rax,%rax,4),%edx
  and    $0xf,%edx
  mov    (%rsp,%rdx,4),%edx
  mov    %edx,(%rdi,%rax,4)
  add    $0x1,%rax
  cmp    $0x10,%rax
  jne    L9
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x58,%rsp
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ShiftRows(uint8_t InValue[]) {
  uint8_t TempValue[16];
  uint8_t i;
  for (i = 0; i < 16; i++) {
    TempValue[i] = InValue[i];
  }
  for (i = 0; i < 16; i++) {
    InValue[i] = TempValue[(i + ((i % 4) * 4)) % 16];
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<ShiftRows>:
  endbr64
  sub    $0x58,%rsp
  movdqu (%rdi),%xmm5
  movdqu 0x10(%rdi),%xmm6
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  movdqu 0x20(%rdi),%xmm7
  movd   0x10(%rdi),%xmm2
  movaps %xmm5,(%rsp)
  movdqu 0x30(%rdi),%xmm5
  movd   0x4(%rsp),%xmm4
  movaps %xmm6,0x10(%rsp)
  movd   0xc(%rsp),%xmm6
  movd   0x18(%rsp),%xmm3
  movaps %xmm5,0x30(%rsp)
  movd   0x38(%rsp),%xmm0
  movd   0x1c(%rsp),%xmm5
  movaps %xmm7,0x20(%rsp)
  movd   0x24(%rsp),%xmm7
  movd   0x20(%rsp),%xmm1
  punpckldq %xmm6,%xmm0
  movd   0x34(%rsp),%xmm6
  punpckldq %xmm7,%xmm2
  movd   0x2c(%rsp),%xmm7
  punpcklqdq %xmm0,%xmm2
  movd   0x8(%rsp),%xmm0
  punpckldq %xmm6,%xmm1
  movd   0x14(%rsp),%xmm6
  punpckldq %xmm7,%xmm3
  movups %xmm2,0x10(%rdi)
  punpckldq %xmm5,%xmm0
  movd   0x3c(%rsp),%xmm5
  punpcklqdq %xmm0,%xmm1
  movd   0x30(%rsp),%xmm0
  movups %xmm1,0x20(%rdi)
  punpckldq %xmm4,%xmm0
  movd   0x28(%rsp),%xmm4
  punpcklqdq %xmm3,%xmm0
  movd   (%rsp),%xmm3
  punpckldq %xmm5,%xmm4
  movups %xmm0,0x30(%rdi)
  punpckldq %xmm6,%xmm3
  punpcklqdq %xmm4,%xmm3
  movups %xmm3,(%rdi)
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  add    $0x58,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void ShiftRows(uint8_t InValue[]) {
  uint8_t TempValue[16];
  uint8_t i;
  for (i = 0; i < 16; i++) {
    TempValue[i] = InValue[i];
  }
  for (i = 0; i < 16; i++) {
    InValue[i] = TempValue[(i + ((i % 4) * 4)) % 16];
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<PWMDeadBandEnable>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %rdx,-0x10(%rbp)
  mov    %rcx,-0x18(%rbp)
  mov    -0x4(%rbp),%eax
  add    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  add    $0x2c,%eax
  cltq
  mov    %rax,%rdx
  mov    -0x10(%rbp),%rax
  mov    %rax,(%rdx)
  mov    -0x8(%rbp),%eax
  add    $0x30,%eax
  cltq
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  mov    %rax,(%rdx)
  mov    -0x8(%rbp),%eax
  add    $0x28,%eax
  cltq
  mov    (%rax),%rax
  mov    -0x8(%rbp),%edx
  add    $0x28,%edx
  movslq %edx,%rdx
  or     $0x1,%rax
  mov    %rax,(%rdx)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall) {
  ;
  ;
  ;
  ;
  ui32Gen = ((ui32Base) + (ui32Gen));
  (*((volatile unsigned long *)(ui32Gen + 0x0000002C))) = ui16Rise;
  (*((volatile unsigned long *)(ui32Gen + 0x00000030))) = ui16Fall;
  (*((volatile unsigned long *)(ui32Gen + 0x00000028))) |= 0x00000001;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<PWMDeadBandEnable>:
  endbr64
  add    %esi,%edi
  lea    0x2c(%rdi),%eax
  cltq
  mov    %rdx,(%rax)
  lea    0x30(%rdi),%eax
  cltq
  mov    %rcx,(%rax)
  add    $0x28,%edi
  movslq %edi,%rdi
  mov    (%rdi),%rax
  or     $0x1,%rax
  mov    %rax,(%rdi)
  ret
```

assistant: ```c
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall) {
  ;
  ;
  ;
  ;
  ui32Gen = ((ui32Base) + (ui32Gen));
  (*((volatile unsigned long *)(ui32Gen + 0x0000002C))) = ui16Rise;
  (*((volatile unsigned long *)(ui32Gen + 0x00000030))) = ui16Fall;
  (*((volatile unsigned long *)(ui32Gen + 0x00000028))) |= 0x00000001;
}
```
user: Translate the below assembly code into C programming language:

```asm
<PWMDeadBandEnable>:
  endbr64
  add    %esi,%edi
  lea    0x2c(%rdi),%eax
  cltq
  mov    %rdx,(%rax)
  lea    0x30(%rdi),%eax
  add    $0x28,%edi
  cltq
  movslq %edi,%rdi
  mov    %rcx,(%rax)
  mov    (%rdi),%rax
  or     $0x1,%rax
  mov    %rax,(%rdi)
  ret
```

assistant: ```c
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall) {
  ;
  ;
  ;
  ;
  ui32Gen = ((ui32Base) + (ui32Gen));
  (*((volatile unsigned long *)(ui32Gen + 0x0000002C))) = ui16Rise;
  (*((volatile unsigned long *)(ui32Gen + 0x00000030))) = ui16Fall;
  (*((volatile unsigned long *)(ui32Gen + 0x00000028))) |= 0x00000001;
}
```
user: What is the c source code of the assembly code below:

```asm
<PWMDeadBandEnable>:
  endbr64
  add    %esi,%edi
  lea    0x2c(%rdi),%eax
  cltq
  mov    %rdx,(%rax)
  lea    0x30(%rdi),%eax
  add    $0x28,%edi
  cltq
  movslq %edi,%rdi
  mov    %rcx,(%rax)
  mov    (%rdi),%rax
  or     $0x1,%rax
  mov    %rax,(%rdi)
  ret
```

assistant: ```c
void PWMDeadBandEnable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall) {
  ;
  ;
  ;
  ;
  ui32Gen = ((ui32Base) + (ui32Gen));
  (*((volatile unsigned long *)(ui32Gen + 0x0000002C))) = ui16Rise;
  (*((volatile unsigned long *)(ui32Gen + 0x00000030))) = ui16Fall;
  (*((volatile unsigned long *)(ui32Gen + 0x00000028))) |= 0x00000001;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rresvport>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D64(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    D15(%rip),%rax
  mov    (%rax),%ecx
  mov    D64(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <socket@plt>
  mov    %eax,-0x18(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jns    L22
  mov    $0xffffffff,%eax
  jmp    L48
L22:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %eax,-0x14(%rbp)
  lea    -0x14(%rbp),%rcx
  mov    -0x18(%rbp),%eax
  mov    $0xc,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <bind@plt>
  test   %rax,%rax
  js     L78
  mov    -0x18(%rbp),%eax
  jmp    L48
L78:
  mov    D25(%rip),%rax
  mov    (%rax),%rdx
  mov    D28(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L65
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L48
L65:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    D87(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%ecx
  shr    $0x1f,%ecx
  add    %ecx,%eax
  sar    %eax
  cmp    %eax,%edx
  jne    L22
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    D55(%rip),%rax
  mov    (%rax),%rdx
  mov    D25(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
L48:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

assistant: ```c
int rresvport(int *alport) {
  struct sockaddr_in sin;
  int s;
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  s = socket(AF_INET, SOCK_STREAM, 0);
  if (s < 0)
    return (-1);
  for (;;) {
    sin.sin_port = htons((u_short)*alport);
    if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) {
      return (s);
    }
    if (errno != EADDRINUSE) {
      (void)close(s);
      return (-1);
    }
    (*alport)--;
    if (*alport == IPPORT_RESERVED / 2) {
      (void)close(s);
      errno = EAGAIN;
      return (-1);
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<rresvport>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    D12(%rip),%rax
  mov    (%rax),%edi
  mov    %edi,0x14(%rsp)
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x10(%rsp)
  mov    $0x0,%edx
  mov    D47(%rip),%rax
  mov    (%rax),%esi
  call   <socket@plt>
  test   %eax,%eax
  js     L14
  mov    %eax,%ebp
  lea    0xc(%rsp),%r12
L60:
  mov    (%rbx),%edi
  call   <htons@plt>
  mov    %eax,0xc(%rsp)
  mov    $0xc,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <bind@plt>
  test   %rax,%rax
  jns    L45
  mov    D20(%rip),%rdx
  mov    D70(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L57
  mov    (%rbx),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,(%rbx)
  mov    D13(%rip),%rax
  mov    (%rax),%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  cmp    %eax,%edx
  jne    L60
  mov    %ebp,%edi
  call   <close@plt>
  mov    D46(%rip),%rax
  mov    (%rax),%rdx
  mov    D20(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%ebp
  jmp    L45
L57:
  mov    %ebp,%edi
  call   <close@plt>
  mov    $0xffffffff,%ebp
L45:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    %ebp,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L14:
  mov    $0xffffffff,%ebp
  jmp    L45
L2:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int rresvport(int *alport) {
  struct sockaddr_in sin;
  int s;
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  s = socket(AF_INET, SOCK_STREAM, 0);
  if (s < 0)
    return (-1);
  for (;;) {
    sin.sin_port = htons((u_short)*alport);
    if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) {
      return (s);
    }
    if (errno != EADDRINUSE) {
      (void)close(s);
      return (-1);
    }
    (*alport)--;
    if (*alport == IPPORT_RESERVED / 2) {
      (void)close(s);
      errno = EAGAIN;
      return (-1);
    }
  }
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<rresvport>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  xor    %edx,%edx
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  mov    D41(%rip),%rax
  mov    (%rax),%edi
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edi,0x14(%rsp)
  mov    %eax,0x10(%rsp)
  mov    D24(%rip),%rax
  mov    (%rax),%esi
  call   <socket@plt>
  test   %eax,%eax
  js     L25
  mov    0x0(%r13),%edi
  mov    %eax,%r12d
  lea    0xc(%rsp),%rbp
  jmp    L64
  nop
L9:
  mov    D32(%rip),%rax
  mov    D16(%rip),%rbx
  mov    (%rax),%rax
  cmp    %rax,(%rbx)
  jne    L16
  mov    0x0(%r13),%eax
  lea    -0x1(%rax),%edi
  mov    D43(%rip),%rax
  mov    %edi,0x0(%r13)
  mov    (%rax),%edx
  mov    %edx,%eax
  shr    $0x1f,%eax
  add    %edx,%eax
  sar    %eax
  cmp    %eax,%edi
  je     L44
L64:
  call   <htons@plt>
  mov    $0xc,%edx
  mov    %rbp,%rsi
  mov    %r12d,%edi
  mov    %eax,0xc(%rsp)
  call   <bind@plt>
  test   %rax,%rax
  js     L9
L74:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L16:
  mov    %r12d,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L44:
  mov    %r12d,%edi
  mov    $0xffffffff,%r12d
  call   <close@plt>
  mov    D37(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,(%rbx)
  jmp    L74
L25:
  mov    $0xffffffff,%r12d
  jmp    L74
L54:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int rresvport(int *alport) {
  struct sockaddr_in sin;
  int s;
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = INADDR_ANY;
  s = socket(AF_INET, SOCK_STREAM, 0);
  if (s < 0)
    return (-1);
  for (;;) {
    sin.sin_port = htons((u_short)*alport);
    if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) {
      return (s);
    }
    if (errno != EADDRINUSE) {
      (void)close(s);
      return (-1);
    }
    (*alport)--;
    if (*alport == IPPORT_RESERVED / 2) {
      (void)close(s);
      errno = EAGAIN;
      return (-1);
    }
  }
}
```