ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将以下的汇编代码转换成C语言代码:

```asm
<randperm>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L10
L19:
  mov    $0x0,%eax
  call   <rand@plt>
  mov    -0x10(%rbp),%edx
  lea    0x1(%rdx),%ecx
  cltd
  idiv   %ecx
  mov    %edx,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
L10:
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L19
  mov    -0x8(%rbp),%rax
  leave
  ret
```

assistant: ```c
int *randperm(int N) {
  int *ord = malloc(N * sizeof(int));
  int i = 0;
  for (i = 0; i < N; ++i) {
    int j = rand() % (i + 1);
    ord[i] = ord[j];
    ord[j] = i;
  }
  return ord;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<randperm>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%r12d
  lea    0x0(,%rdi,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %r12d,%r12d
  jle    L0
  mov    %r12d,%r12d
  mov    $0x0,%ebx
L10:
  mov    $0x0,%eax
  call   <rand@plt>
  lea    0x1(%rbx),%ecx
  cltd
  idiv   %ecx
  movslq %edx,%rdx
  lea    0x0(%rbp,%rdx,4),%rax
  mov    (%rax),%edx
  mov    %edx,0x0(%rbp,%rbx,4)
  mov    %ebx,(%rax)
  add    $0x1,%rbx
  cmp    %r12,%rbx
  jne    L10
L0:
  mov    %rbp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int *randperm(int N) {
  int *ord = malloc(N * sizeof(int));
  int i = 0;
  for (i = 0; i < N; ++i) {
    int j = rand() % (i + 1);
    ord[i] = ord[j];
    ord[j] = i;
  }
  return ord;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<randperm>:
  endbr64
  push   %r12
  push   %rbp
  movslq %edi,%rbp
  push   %rbx
  lea    0x0(,%rbp,4),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %ebp,%ebp
  jle    L16
  xor    %ebx,%ebx
L5:
  xor    %eax,%eax
  call   <rand@plt>
  lea    0x1(%rbx),%ecx
  cltd
  idiv   %ecx
  movslq %edx,%rdx
  lea    (%r12,%rdx,4),%rax
  mov    (%rax),%edx
  mov    %edx,(%r12,%rbx,4)
  mov    %ebx,(%rax)
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L5
L16:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int *randperm(int N) {
  int *ord = malloc(N * sizeof(int));
  int i = 0;
  for (i = 0; i < N; ++i) {
    int j = rand() % (i + 1);
    ord[i] = ord[j];
    ord[j] = i;
  }
  return ord;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<randperm>:
  endbr64
  push   %r12
  push   %rbp
  movslq %edi,%rbp
  push   %rbx
  lea    0x0(,%rbp,4),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %ebp,%ebp
  jle    L0
  xor    %ebx,%ebx
L4:
  xor    %eax,%eax
  call   <rand@plt>
  lea    0x1(%rbx),%ecx
  cltd
  idiv   %ecx
  movslq %edx,%rdx
  lea    (%r12,%rdx,4),%rax
  mov    (%rax),%edx
  mov    %edx,(%r12,%rbx,4)
  mov    %ebx,(%rax)
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L4
L0:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int *randperm(int N) {
  int *ord = malloc(N * sizeof(int));
  int i = 0;
  for (i = 0; i < N; ++i) {
    int j = rand() % (i + 1);
    ord[i] = ord[j];
    ord[j] = i;
  }
  return ord;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<swapRow>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L18
L9:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  mov    (%rdx,%rax,4),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%eax
  cltq
  mov    (%rsi,%rax,4),%edx
  mov    -0x8(%rbp),%eax
  cltq
  mov    %edx,(%rcx,%rax,4)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%eax
  cltq
  mov    -0x4(%rbp),%edx
  mov    %edx,(%rcx,%rax,4)
  addl   $0x1,-0x8(%rbp)
L18:
  mov    -0x8(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L9
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void swapRow(int matriz[4][5], int fil1, int fil2, int cols) {
  int i, aux;
  for (i = 0; i < cols; i++) {
    aux = matriz[fil1][i];
    matriz[fil1][i] = matriz[fil2][i];
    matriz[fil2][i] = aux;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<swapRow>:
  endbr64
  test   %ecx,%ecx
  jle    L17
  movslq %esi,%rsi
  lea    (%rsi,%rsi,4),%rax
  lea    (%rdi,%rax,4),%rsi
  movslq %edx,%rdx
  lea    (%rdx,%rdx,4),%rax
  lea    (%rdi,%rax,4),%rdx
  mov    $0x0,%eax
L14:
  mov    (%rsi,%rax,4),%edi
  mov    (%rdx,%rax,4),%r8d
  mov    %r8d,(%rsi,%rax,4)
  mov    %edi,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L14
L17:
  ret
```

assistant: ```c
void swapRow(int matriz[4][5], int fil1, int fil2, int cols) {
  int i, aux;
  for (i = 0; i < cols; i++) {
    aux = matriz[fil1][i];
    matriz[fil1][i] = matriz[fil2][i];
    matriz[fil2][i] = aux;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<swapRow>:
  endbr64
  test   %ecx,%ecx
  jle    L12
  movslq %esi,%rsi
  movslq %edx,%rdx
  lea    (%rsi,%rsi,4),%rax
  lea    (%rdi,%rax,4),%rsi
  lea    (%rdx,%rdx,4),%rax
  lea    (%rdi,%rax,4),%rdx
  xor    %eax,%eax
L17:
  mov    (%rsi,%rax,4),%edi
  mov    (%rdx,%rax,4),%r8d
  mov    %r8d,(%rsi,%rax,4)
  mov    %edi,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L17
L12:
  ret
```

assistant: ```c
void swapRow(int matriz[4][5], int fil1, int fil2, int cols) {
  int i, aux;
  for (i = 0; i < cols; i++) {
    aux = matriz[fil1][i];
    matriz[fil1][i] = matriz[fil2][i];
    matriz[fil2][i] = aux;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<swapRow>:
  endbr64
  mov    %rdi,%r9
  test   %ecx,%ecx
  jle    L92
  movslq %esi,%rsi
  movslq %edx,%rdx
  lea    (%rsi,%rsi,4),%r10
  lea    (%rdx,%rdx,4),%rax
  shl    $0x2,%r10
  shl    $0x2,%rax
  lea    0x10(%r10),%r11
  lea    (%r9,%rax,1),%r8
  cmp    %rax,%r11
  lea    (%rdi,%r10,1),%rdi
  setle  %r11b
  add    $0x10,%rax
  cmp    %r10,%rax
  setle  %al
  or     %al,%r11b
  je     L77
  cmp    $0x1,%ecx
  je     L77
  lea    -0x1(%rcx),%eax
  mov    %ecx,%r11d
  cmp    $0x2,%eax
  jbe    L146
  movdqu (%rdi),%xmm0
  movdqu (%r8),%xmm1
  shr    $0x2,%r11d
  movups %xmm1,(%rdi)
  movups %xmm0,(%r8)
  cmp    $0x1,%r11d
  je     L86
  mov    $0x10,%eax
  mov    $0x1,%r10d
L131:
  movdqu (%rdi,%rax,1),%xmm0
  movdqu (%r8,%rax,1),%xmm2
  add    $0x1,%r10d
  movups %xmm2,(%rdi,%rax,1)
  movups %xmm0,(%r8,%rax,1)
  add    $0x10,%rax
  cmp    %r11d,%r10d
  jne    L131
L86:
  mov    %ecx,%r10d
  and    $0xfffffffc,%r10d
  mov    %r10d,%eax
  cmp    %r10d,%ecx
  je     L92
  sub    %r10d,%ecx
  mov    %ecx,%r11d
  cmp    $0x1,%ecx
  je     L40
L97:
  lea    (%rsi,%rsi,4),%rcx
  lea    (%rdx,%rdx,4),%rdx
  add    %r10,%rcx
  add    %r10,%rdx
  lea    (%r9,%rcx,4),%rcx
  lea    (%r9,%rdx,4),%rdx
  mov    (%rdx),%r9
  mov    (%rcx),%rsi
  mov    %r9,(%rcx)
  mov    %rsi,(%rdx)
  mov    %r11d,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%r11d
  je     L92
L40:
  cltq
  mov    (%rdi,%rax,4),%edx
  mov    (%r8,%rax,4),%ecx
  mov    %ecx,(%rdi,%rax,4)
  mov    %edx,(%r8,%rax,4)
  ret
  nopl   0x0(%rax,%rax,1)
L77:
  mov    (%rdi),%eax
  mov    (%r8),%edx
  mov    %edx,(%rdi)
  mov    %eax,(%r8)
  cmp    $0x1,%ecx
  je     L92
  mov    0x4(%rdi),%eax
  mov    0x4(%r8),%edx
  mov    %edx,0x4(%rdi)
  mov    %eax,0x4(%r8)
  cmp    $0x2,%ecx
  je     L92
  mov    0x8(%rdi),%eax
  mov    0x8(%r8),%edx
  mov    %edx,0x8(%rdi)
  mov    %eax,0x8(%r8)
  cmp    $0x3,%ecx
  je     L92
  mov    0xc(%rdi),%eax
  mov    0xc(%r8),%edx
  mov    %edx,0xc(%rdi)
  mov    %eax,0xc(%r8)
  cmp    $0x4,%ecx
  je     L92
  mov    0x10(%rdi),%eax
  mov    0x10(%r8),%edx
  mov    %edx,0x10(%rdi)
  mov    %eax,0x10(%r8)
  cmp    $0x5,%ecx
  je     L92
  mov    0x14(%rdi),%eax
  mov    0x14(%r8),%edx
  mov    %edx,0x14(%rdi)
  mov    %eax,0x14(%r8)
  cmp    $0x6,%ecx
  je     L92
  mov    $0x6,%eax
L42:
  mov    (%rdi,%rax,4),%edx
  mov    (%r8,%rax,4),%esi
  mov    %esi,(%rdi,%rax,4)
  mov    %edx,(%r8,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L42
L92:
  ret
  nopw   0x0(%rax,%rax,1)
L146:
  xor    %r10d,%r10d
  xor    %eax,%eax
  jmp    L97
```

assistant: ```c
void swapRow(int matriz[4][5], int fil1, int fil2, int cols) {
  int i, aux;
  for (i = 0; i < cols; i++) {
    aux = matriz[fil1][i];
    matriz[fil1][i] = matriz[fil2][i];
    matriz[fil2][i] = aux;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<get_item_field_id>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    %edx,-0xc(%rbp)
  mov    -0x8(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0xc(%rbp),%ecx
  mov    -0x4(%rbp),%eax
  mov    %ecx,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  lea    D5(%rip),%rax
  mov    %rax,%rsi
  lea    D27(%rip),%rax
  mov    %rax,%rdi
  call   <sprintf@plt>
  lea    D27(%rip),%rax
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D5
data_type: string

tool: D5: %d.%d.%d

assistant: ```c
char *get_item_field_id(int class_num, int field_num, int item_num) {
  static char name[32];
  sprintf(name, "%d.%d.%d", class_num, field_num + 1, item_num);
  return name;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<get_item_field_id>:
  endbr64
  push   %rbx
  mov    %edx,%r8d
  lea    0x1(%rsi),%ecx
  mov    %edi,%edx
  lea    D1(%rip),%rsi
  lea    D17(%rip),%rbx
  mov    %rbx,%rdi
  call   <sprintf@plt>
  mov    %rbx,%rax
  pop    %rbx
  ret
```

tool_calls: name: retrieve_data
arguments: label: D1
type: string

tool: D1: %d.%d.%d

assistant: ```c
char *get_item_field_id(int class_num, int field_num, int item_num) {
  static char name[32];
  sprintf(name, "%d.%d.%d", class_num, field_num + 1, item_num);
  return name;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<get_item_field_id>:
  endbr64
  push   %r12
  lea    D6(%rip),%r12
  mov    %edx,%r8d
  lea    0x1(%rsi),%ecx
  mov    %edi,%edx
  lea    D3(%rip),%rsi
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D3
type_guessed: string

tool: D3: %d.%d.%d

assistant: ```c
char *get_item_field_id(int class_num, int field_num, int item_num) {
  static char name[32];
  sprintf(name, "%d.%d.%d", class_num, field_num + 1, item_num);
  return name;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<get_item_field_id>:
  endbr64
  push   %r12
  lea    D19(%rip),%r12
  mov    %edx,%r8d
  lea    0x1(%rsi),%ecx
  mov    %edi,%edx
  lea    D3(%rip),%rsi
  mov    %r12,%rdi
  call   <sprintf@plt>
  mov    %r12,%rax
  pop    %r12
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D3
type: string

tool: D3: %d.%d.%d

assistant: ```c
char *get_item_field_id(int class_num, int field_num, int item_num) {
  static char name[32];
  sprintf(name, "%d.%d.%d", class_num, field_num + 1, item_num);
  return name;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<HibernateCalendarGet>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
L22:
  mov    $0x400fc314,%eax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  jns    L22
L38:
  mov    $0x400fc310,%eax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jns    L38
  mov    $0x400fc314,%eax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  je     L58
  mov    $0xffffffff,%eax
  jmp    L0
L58:
  mov    -0x4(%rbp),%eax
  sar    $0x8,%eax
  and    $0x3f,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  and    $0x3f,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x4(%rax)
  mov    -0x8(%rbp),%eax
  sar    $0x8,%eax
  and    $0xf,%eax
  lea    -0x1(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x8(%rax)
  mov    -0x8(%rbp),%eax
  and    $0x1f,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0xc(%rax)
  mov    -0x8(%rbp),%eax
  sar    $0x18,%eax
  and    $0x7,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x10(%rax)
  mov    -0x8(%rbp),%eax
  sar    $0x10,%eax
  and    $0x7f,%eax
  lea    0x64(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x14(%rax)
  mov    -0x4(%rbp),%eax
  sar    $0x10,%eax
  and    $0x1f,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x18(%rax)
  mov    $0x400fc300,%eax
  mov    (%rax),%eax
  and    $0x4,%eax
  test   %eax,%eax
  jne    L21
  mov    -0x4(%rbp),%eax
  and    $0x400000,%eax
  test   %eax,%eax
  je     L21
  mov    -0x18(%rbp),%rax
  mov    0x18(%rax),%eax
  lea    0xc(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,0x18(%rax)
L21:
  mov    $0x0,%eax
L0:
  pop    %rbp
  ret
```

assistant: ```c
int HibernateCalendarGet(struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ;
  do {
    ui32Date = (*((volatile uint32_t *)(0x400FC314)));
  } while ((ui32Date & 0x80000000) == 0);
  do {
    ui32Time = (*((volatile uint32_t *)(0x400FC310)));
  } while ((ui32Time & 0x80000000) == 0);
  if (ui32Date != (*((volatile uint32_t *)(0x400FC314)))) {
    return (-1);
  }
  psTime->tm_min = (ui32Time & 0x00003F00) >> 8;
  psTime->tm_sec = (ui32Time & 0x0000003F) >> 0;
  psTime->tm_mon = (((ui32Date & 0x00000F00) >> 8) - 1);
  psTime->tm_mday = (ui32Date & 0x0000001F) >> 0;
  psTime->tm_wday = (ui32Date & 0x07000000) >> 24;
  psTime->tm_year = ((ui32Date & 0x007F0000) >> 16) + 100;
  psTime->tm_hour = (ui32Time & 0x001F0000) >> 16;
  if ((((*((volatile uint32_t *)(0x400FC300))) & 0x00000004) == 0) && (ui32Time & 0x00400000)) {
    psTime->tm_hour += 12;
  }
  return (0);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<HibernateCalendarGet>:
  endbr64
  mov    %rdi,%rcx
L24:
  mov    0x400fc314,%eax
  test   %eax,%eax
  jns    L24
L3:
  mov    0x400fc310,%edx
  test   %edx,%edx
  jns    L3
  mov    0x400fc314,%esi
  cmp    %eax,%esi
  jne    L57
  mov    %edx,%esi
  sar    $0x8,%esi
  and    $0x3f,%esi
  mov    %esi,(%rcx)
  mov    %edx,%esi
  and    $0x3f,%esi
  mov    %esi,0x4(%rcx)
  mov    %eax,%esi
  sar    $0x8,%esi
  and    $0xf,%esi
  sub    $0x1,%esi
  mov    %esi,0x8(%rcx)
  mov    %eax,%esi
  and    $0x1f,%esi
  mov    %esi,0xc(%rcx)
  mov    %eax,%esi
  sar    $0x18,%esi
  and    $0x7,%esi
  mov    %esi,0x10(%rcx)
  sar    $0x10,%eax
  and    $0x7f,%eax
  add    $0x64,%eax
  mov    %eax,0x14(%rcx)
  mov    %edx,%eax
  sar    $0x10,%eax
  and    $0x1f,%eax
  mov    %eax,0x18(%rcx)
  mov    0x400fc300,%esi
  mov    $0x0,%edi
  and    $0x4,%esi
  jne    L30
  mov    %edx,%edi
  and    $0x400000,%edi
  je     L30
  add    $0xc,%eax
  mov    %eax,0x18(%rcx)
  mov    %esi,%edi
L30:
  mov    %edi,%eax
  ret
L57:
  mov    $0xffffffff,%edi
  jmp    L30
```

assistant: ```c
int HibernateCalendarGet(struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ;
  do {
    ui32Date = (*((volatile uint32_t *)(0x400FC314)));
  } while ((ui32Date & 0x80000000) == 0);
  do {
    ui32Time = (*((volatile uint32_t *)(0x400FC310)));
  } while ((ui32Time & 0x80000000) == 0);
  if (ui32Date != (*((volatile uint32_t *)(0x400FC314)))) {
    return (-1);
  }
  psTime->tm_min = (ui32Time & 0x00003F00) >> 8;
  psTime->tm_sec = (ui32Time & 0x0000003F) >> 0;
  psTime->tm_mon = (((ui32Date & 0x00000F00) >> 8) - 1);
  psTime->tm_mday = (ui32Date & 0x0000001F) >> 0;
  psTime->tm_wday = (ui32Date & 0x07000000) >> 24;
  psTime->tm_year = ((ui32Date & 0x007F0000) >> 16) + 100;
  psTime->tm_hour = (ui32Time & 0x001F0000) >> 16;
  if ((((*((volatile uint32_t *)(0x400FC300))) & 0x00000004) == 0) && (ui32Time & 0x00400000)) {
    psTime->tm_hour += 12;
  }
  return (0);
}
```
user: What is the c source code of the assembly code below?

```asm
<HibernateCalendarGet>:
  endbr64
  mov    %rdi,%rcx
  nopw   0x0(%rax,%rax,1)
L42:
  mov    0x400fc314,%eax
  test   %eax,%eax
  jns    L42
  nopl   0x0(%rax,%rax,1)
L30:
  mov    0x400fc310,%edx
  test   %edx,%edx
  jns    L30
  mov    0x400fc314,%esi
  cmp    %eax,%esi
  jne    L46
  mov    %edx,%esi
  xor    %r8d,%r8d
  sar    $0x8,%esi
  and    $0x3f,%esi
  mov    %esi,(%rcx)
  mov    %edx,%esi
  and    $0x3f,%esi
  mov    %esi,0x4(%rcx)
  mov    %eax,%esi
  sar    $0x8,%esi
  and    $0xf,%esi
  sub    $0x1,%esi
  mov    %esi,0x8(%rcx)
  mov    %eax,%esi
  and    $0x1f,%esi
  mov    %esi,0xc(%rcx)
  mov    %eax,%esi
  sar    $0x10,%eax
  and    $0x7f,%eax
  sar    $0x18,%esi
  add    $0x64,%eax
  and    $0x7,%esi
  mov    %eax,0x14(%rcx)
  mov    %edx,%eax
  sar    $0x10,%eax
  mov    %esi,0x10(%rcx)
  and    $0x1f,%eax
  mov    %eax,0x18(%rcx)
  mov    0x400fc300,%esi
  and    $0x4,%esi
  jne    L59
  and    $0x400000,%edx
  mov    %edx,%r8d
  je     L59
  add    $0xc,%eax
  xor    %r8d,%r8d
  mov    %eax,0x18(%rcx)
L59:
  mov    %r8d,%eax
  ret
L46:
  mov    $0xffffffff,%r8d
  jmp    L59
```

assistant: ```c
int HibernateCalendarGet(struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ;
  do {
    ui32Date = (*((volatile uint32_t *)(0x400FC314)));
  } while ((ui32Date & 0x80000000) == 0);
  do {
    ui32Time = (*((volatile uint32_t *)(0x400FC310)));
  } while ((ui32Time & 0x80000000) == 0);
  if (ui32Date != (*((volatile uint32_t *)(0x400FC314)))) {
    return (-1);
  }
  psTime->tm_min = (ui32Time & 0x00003F00) >> 8;
  psTime->tm_sec = (ui32Time & 0x0000003F) >> 0;
  psTime->tm_mon = (((ui32Date & 0x00000F00) >> 8) - 1);
  psTime->tm_mday = (ui32Date & 0x0000001F) >> 0;
  psTime->tm_wday = (ui32Date & 0x07000000) >> 24;
  psTime->tm_year = ((ui32Date & 0x007F0000) >> 16) + 100;
  psTime->tm_hour = (ui32Time & 0x001F0000) >> 16;
  if ((((*((volatile uint32_t *)(0x400FC300))) & 0x00000004) == 0) && (ui32Time & 0x00400000)) {
    psTime->tm_hour += 12;
  }
  return (0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<HibernateCalendarGet>:
  endbr64
  mov    %rdi,%rsi
  nopw   0x0(%rax,%rax,1)
L22:
  mov    0x400fc314,%eax
  test   %eax,%eax
  jns    L22
  nopl   0x0(%rax,%rax,1)
L26:
  mov    0x400fc310,%edx
  test   %edx,%edx
  jns    L26
  mov    0x400fc314,%ecx
  cmp    %eax,%ecx
  jne    L33
  mov    %edx,%ecx
  mov    %edx,%edi
  xor    %r8d,%r8d
  sar    $0x8,%ecx
  and    $0x3f,%edi
  and    $0x3f,%ecx
  movd   %edi,%xmm3
  movd   %ecx,%xmm0
  mov    %eax,%ecx
  sar    $0x8,%ecx
  punpckldq %xmm3,%xmm0
  and    $0xf,%ecx
  sub    $0x1,%ecx
  movd   %ecx,%xmm1
  mov    %eax,%ecx
  and    $0x1f,%ecx
  movd   %ecx,%xmm2
  mov    %eax,%ecx
  sar    $0x10,%eax
  and    $0x7f,%eax
  sar    $0x18,%ecx
  punpckldq %xmm2,%xmm1
  add    $0x64,%eax
  and    $0x7,%ecx
  punpcklqdq %xmm1,%xmm0
  movd   %eax,%xmm4
  mov    %edx,%eax
  movups %xmm0,(%rsi)
  movd   %ecx,%xmm0
  sar    $0x10,%eax
  punpckldq %xmm4,%xmm0
  and    $0x1f,%eax
  movq   %xmm0,0x10(%rsi)
  mov    %eax,0x18(%rsi)
  mov    0x400fc300,%ecx
  and    $0x4,%ecx
  jne    L58
  and    $0x400000,%edx
  mov    %edx,%r8d
  je     L58
  add    $0xc,%eax
  xor    %r8d,%r8d
  mov    %eax,0x18(%rsi)
L58:
  mov    %r8d,%eax
  ret
L33:
  mov    $0xffffffff,%r8d
  jmp    L58
```

assistant: ```c
int HibernateCalendarGet(struct tm *psTime) {
  uint32_t ui32Date, ui32Time;
  ;
  do {
    ui32Date = (*((volatile uint32_t *)(0x400FC314)));
  } while ((ui32Date & 0x80000000) == 0);
  do {
    ui32Time = (*((volatile uint32_t *)(0x400FC310)));
  } while ((ui32Time & 0x80000000) == 0);
  if (ui32Date != (*((volatile uint32_t *)(0x400FC314)))) {
    return (-1);
  }
  psTime->tm_min = (ui32Time & 0x00003F00) >> 8;
  psTime->tm_sec = (ui32Time & 0x0000003F) >> 0;
  psTime->tm_mon = (((ui32Date & 0x00000F00) >> 8) - 1);
  psTime->tm_mday = (ui32Date & 0x0000001F) >> 0;
  psTime->tm_wday = (ui32Date & 0x07000000) >> 24;
  psTime->tm_year = ((ui32Date & 0x007F0000) >> 16) + 100;
  psTime->tm_hour = (ui32Time & 0x001F0000) >> 16;
  if ((((*((volatile uint32_t *)(0x400FC300))) & 0x00000004) == 0) && (ui32Time & 0x00400000)) {
    psTime->tm_hour += 12;
  }
  return (0);
}
```
user: Translate the below assembly code into C programming language:

```asm
<tandem_adjust_ulaw>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    %r8d,-0x24(%rbp)
  mov    %r9,-0x30(%rbp)
  cmpl   $0xffff8001,-0x14(%rbp)
  jge    L130
  movl   $0x0,-0x14(%rbp)
L130:
  mov    -0x14(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <linear2ulaw@plt>
  mov    %al,-0x10(%rbp)
  movzbl -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <ulaw2linear@plt>
  sar    $0x2,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %ax,-0xe(%rbp)
  mov    -0x24(%rbp),%eax
  lea    -0x1(%rax),%ecx
  movswl -0xe(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    -0x1c(%rbp),%esi
  mov    %eax,%edi
  call   <quantize@plt>
  mov    %al,-0xf(%rbp)
  movsbl -0xf(%rbp),%eax
  cmp    %eax,-0x20(%rbp)
  jne    L32
  movzbl -0x10(%rbp),%eax
  jmp    L66
L32:
  mov    -0x20(%rbp),%eax
  xor    -0x24(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  movsbl -0xf(%rbp),%eax
  xor    -0x24(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L132
  movzbl -0x10(%rbp),%eax
  test   %al,%al
  jns    L159
  cmpb   $0xff,-0x10(%rbp)
  je     L166
  movzbl -0x10(%rbp),%eax
  add    $0x1,%eax
  jmp    L145
L166:
  mov    $0x7e,%eax
L145:
  mov    %eax,-0xc(%rbp)
  jmp    L54
L159:
  cmpb   $0x0,-0x10(%rbp)
  je     L135
  movzbl -0x10(%rbp),%eax
  sub    $0x1,%eax
  jmp    L10
L135:
  mov    $0x0,%eax
L10:
  mov    %eax,-0xc(%rbp)
  jmp    L54
L132:
  movzbl -0x10(%rbp),%eax
  test   %al,%al
  jns    L46
  cmpb   $0x80,-0x10(%rbp)
  je     L144
  movzbl -0x10(%rbp),%eax
  sub    $0x1,%eax
  jmp    L16
L144:
  mov    $0x80,%eax
L16:
  mov    %eax,-0xc(%rbp)
  jmp    L54
L46:
  cmpb   $0x7f,-0x10(%rbp)
  je     L52
  movzbl -0x10(%rbp),%eax
  add    $0x1,%eax
  jmp    L47
L52:
  mov    $0xfe,%eax
L47:
  mov    %eax,-0xc(%rbp)
L54:
  mov    -0xc(%rbp),%eax
L66:
  leave
  ret
```

assistant: ```c
int tandem_adjust_ulaw(int sr, int se, int y, int i, int sign, short *qtab) {
  unsigned char sp;
  short dx;
  char id;
  int sd;
  int im;
  int imx;
  if (sr <= -32768)
    sr = 0;
  sp = linear2ulaw(sr << 2);
  dx = (ulaw2linear(sp) >> 2) - se;
  id = quantize(dx, y, qtab, sign - 1);
  if (id == i) {
    return (sp);
  } else {
    im = i ^ sign;
    imx = id ^ sign;
    if (imx > im) {
      if (sp & 0x80)
        sd = (sp == 0xFF) ? 0x7E : sp + 1;
      else
        sd = (sp == 0) ? 0 : sp - 1;
    } else {
      if (sp & 0x80)
        sd = (sp == 0x80) ? 0x80 : sp - 1;
      else
        sd = (sp == 0x7F) ? 0xFE : sp + 1;
    }
    return (sd);
  }
}
```