ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Converte this assembly snippet into its equivalent C code:

```asm
<digit2char>:
  endbr64
  and    $0xf,%edi
  mov    $0x30,%eax
  sub    $0x1,%edi
  cmp    $0xe,%dil
  ja     L9
  movzbl %dil,%edi
  lea    D6(%rip),%rax
  movzbl (%rax,%rdi,1),%eax
L9:
  ret
```

assistant: ```c
char digit2char(unsigned char digit) {
  switch (digit & 0xf) {
  case 0x0:
    return '0';
  case 0x1:
    return '1';
  case 0x2:
    return '2';
  case 0x3:
    return '3';
  case 0x4:
    return '4';
  case 0x5:
    return '5';
  case 0x6:
    return '6';
  case 0x7:
    return '7';
  case 0x8:
    return '8';
  case 0x9:
    return '9';
  case 0xa:
    return 'A';
  case 0xb:
    return 'B';
  case 0xc:
    return 'C';
  case 0xd:
    return 'D';
  case 0xe:
    return '*';
  case 0xf:
    return '#';
  default:
    return 0;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<digit2char>:
  endbr64
  and    $0xf,%edi
  mov    $0x30,%eax
  sub    $0x1,%edi
  cmp    $0xe,%dil
  ja     L2
  movzbl %dil,%edi
  lea    D3(%rip),%rax
  movzbl (%rax,%rdi,1),%eax
L2:
  ret
```

assistant: ```c
char digit2char(unsigned char digit) {
  switch (digit & 0xf) {
  case 0x0:
    return '0';
  case 0x1:
    return '1';
  case 0x2:
    return '2';
  case 0x3:
    return '3';
  case 0x4:
    return '4';
  case 0x5:
    return '5';
  case 0x6:
    return '6';
  case 0x7:
    return '7';
  case 0x8:
    return '8';
  case 0x9:
    return '9';
  case 0xa:
    return 'A';
  case 0xb:
    return 'B';
  case 0xc:
    return 'C';
  case 0xd:
    return 'D';
  case 0xe:
    return '*';
  case 0xf:
    return '#';
  default:
    return 0;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<partition>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    -0x20(%rbp),%edx
  mov    -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <choosePivot@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swaparr@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  jmp    L28
L4:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jle    L20
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swaparr@plt>
  addl   $0x1,-0xc(%rbp)
L20:
  addl   $0x1,-0x10(%rbp)
L28:
  mov    -0x10(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jl     L4
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swaparr@plt>
  mov    -0xc(%rbp),%eax
  leave
  ret
```

assistant: ```c
int partition(int *arr, int low, int upp) {
  int i;
  int pivotIdx = choosePivot(arr, low, upp);
  int pivotVal = arr[pivotIdx];
  swaparr(&arr[pivotIdx], &arr[upp]);
  int storeIdx = low;
  for (i = low; i < upp; i++) {
    if (arr[i] < pivotVal) {
      swaparr(&arr[i], &arr[storeIdx]);
      storeIdx++;
    }
  }
  swaparr(&arr[storeIdx], &arr[upp]);
  return storeIdx;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<partition>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  mov    %esi,%ebp
  mov    %edx,%r12d
  call   <choosePivot@plt>
  cltq
  lea    0x0(%r13,%rax,4),%rdi
  mov    (%rdi),%r14d
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,4),%r15
  mov    %r15,%rsi
  call   <swaparr@plt>
  cmp    %r12d,%ebp
  jge    L5
  movslq %ebp,%rax
  lea    0x0(%r13,%rax,4),%rbx
  sub    $0x1,%r12d
  sub    %ebp,%r12d
  add    %rax,%r12
  lea    0x4(%r13,%r12,4),%r12
  jmp    L46
L4:
  add    $0x4,%rbx
  cmp    %r12,%rbx
  je     L5
L46:
  cmp    %r14d,(%rbx)
  jge    L4
  movslq %ebp,%rax
  lea    0x0(%r13,%rax,4),%rsi
  mov    %rbx,%rdi
  call   <swaparr@plt>
  add    $0x1,%ebp
  jmp    L4
L5:
  movslq %ebp,%rax
  lea    0x0(%r13,%rax,4),%rdi
  mov    %r15,%rsi
  call   <swaparr@plt>
  mov    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int partition(int *arr, int low, int upp) {
  int i;
  int pivotIdx = choosePivot(arr, low, upp);
  int pivotVal = arr[pivotIdx];
  swaparr(&arr[pivotIdx], &arr[upp]);
  int storeIdx = low;
  for (i = low; i < upp; i++) {
    if (arr[i] < pivotVal) {
      swaparr(&arr[i], &arr[storeIdx]);
      storeIdx++;
    }
  }
  swaparr(&arr[storeIdx], &arr[upp]);
  return storeIdx;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<partition>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x8,%rsp
  call   <choosePivot@plt>
  cltq
  lea    (%r14,%rax,4),%rdi
  movslq %ebp,%rax
  lea    (%r14,%rax,4),%r13
  mov    (%rdi),%r15d
  mov    %r13,%rsi
  call   <swaparr@plt>
  cmp    %ebp,%r12d
  jge    L4
  sub    $0x1,%ebp
  movslq %r12d,%rax
  sub    %r12d,%ebp
  lea    (%r14,%rax,4),%rbx
  add    %rax,%rbp
  lea    0x4(%r14,%rbp,4),%rbp
  jmp    L29
  nopl   0x0(%rax,%rax,1)
L41:
  add    $0x4,%rbx
  cmp    %rbp,%rbx
  je     L4
L29:
  cmp    %r15d,(%rbx)
  jge    L41
  movslq %r12d,%rax
  mov    %rbx,%rdi
  add    $0x4,%rbx
  add    $0x1,%r12d
  lea    (%r14,%rax,4),%rsi
  call   <swaparr@plt>
  cmp    %rbp,%rbx
  jne    L29
L4:
  movslq %r12d,%rax
  mov    %r13,%rsi
  lea    (%r14,%rax,4),%rdi
  call   <swaparr@plt>
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int partition(int *arr, int low, int upp) {
  int i;
  int pivotIdx = choosePivot(arr, low, upp);
  int pivotVal = arr[pivotIdx];
  swaparr(&arr[pivotIdx], &arr[upp]);
  int storeIdx = low;
  for (i = low; i < upp; i++) {
    if (arr[i] < pivotVal) {
      swaparr(&arr[i], &arr[storeIdx]);
      storeIdx++;
    }
  }
  swaparr(&arr[storeIdx], &arr[upp]);
  return storeIdx;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<partition>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x8,%rsp
  call   <choosePivot@plt>
  cltq
  lea    (%r14,%rax,4),%rdi
  movslq %ebp,%rax
  lea    (%r14,%rax,4),%r13
  mov    (%rdi),%r15d
  mov    %r13,%rsi
  call   <swaparr@plt>
  cmp    %ebp,%r12d
  jge    L35
  sub    $0x1,%ebp
  movslq %r12d,%rax
  sub    %r12d,%ebp
  lea    (%r14,%rax,4),%rbx
  add    %rax,%rbp
  lea    0x4(%r14,%rbp,4),%rbp
  jmp    L41
  nopl   0x0(%rax,%rax,1)
L19:
  add    $0x4,%rbx
  cmp    %rbp,%rbx
  je     L35
L41:
  cmp    %r15d,(%rbx)
  jge    L19
  movslq %r12d,%rax
  mov    %rbx,%rdi
  add    $0x4,%rbx
  add    $0x1,%r12d
  lea    (%r14,%rax,4),%rsi
  call   <swaparr@plt>
  cmp    %rbp,%rbx
  jne    L41
L35:
  movslq %r12d,%rax
  mov    %r13,%rsi
  lea    (%r14,%rax,4),%rdi
  call   <swaparr@plt>
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int partition(int *arr, int low, int upp) {
  int i;
  int pivotIdx = choosePivot(arr, low, upp);
  int pivotVal = arr[pivotIdx];
  swaparr(&arr[pivotIdx], &arr[upp]);
  int storeIdx = low;
  for (i = low; i < upp; i++) {
    if (arr[i] < pivotVal) {
      swaparr(&arr[i], &arr[storeIdx]);
      storeIdx++;
    }
  }
  swaparr(&arr[storeIdx], &arr[upp]);
  return storeIdx;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<usage>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D116(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D81(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D72(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D36(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D105(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xda5,%esi
  lea    D107(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D60(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D34(%rip),%rax
  mov    %rax,%rsi
  lea    D64(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D95(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D46
type_infered: string
name: unpack_data
arguments: data_tag: D116
type_infered: string
name: unpack_data
arguments: data_tag: D32
type_infered: string
name: unpack_data
arguments: data_tag: D81
type_infered: string
name: unpack_data
arguments: data_tag: D72
type_infered: string
name: unpack_data
arguments: data_tag: D36
type_infered: string
name: unpack_data
arguments: data_tag: D105
type_infered: string
name: unpack_data
arguments: data_tag: D107
type_infered: string
name: unpack_data
arguments: data_tag: D60
type_infered: string
name: unpack_data
arguments: data_tag: D34
type_infered: string
name: unpack_data
arguments: data_tag: D64
type_infered: string
name: unpack_data
arguments: data_tag: D95
type_infered: string

tool: D46: 
Port Knocking Backdoor - client


tool: D116: Usage:


tool: D32: %s [required] [optional]



tool: D81: [required]:

tool: D72: 	 -d <dest_ip>		destination ip

tool: D36: [optional]:

tool: D105: 	 -p <port>		port connect to

tool: D107: 				(default port: %d)


tool: D60: 	 -i <interface>		interface to use

tool: D34: lo

tool: D64: 				(default interface: %s)


tool: D95: 


assistant: ```c
void usage(char *name) {
  printf("\nPort Knocking Backdoor - client\n\n");
  printf("Usage:\n\n");
  printf("%s [required] [optional]\n\n", name);
  printf("[required]:\n");
  printf("\t -d <dest_ip>\t\tdestination ip\n");
  printf("\n");
  printf("[optional]:\n");
  printf("\t -p <port>\t\tport connect to\n");
  printf("\t\t\t\t(default port: %d)\n", 3493);
  printf("\t -i <interface>\t\tinterface to use\n");
  printf("\t\t\t\t(default interface: %s)\n", "lo");
  printf("\n\n");
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<usage>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  lea    D29(%rip),%rdi
  call   <puts@plt>
  lea    D64(%rip),%rdi
  call   <puts@plt>
  mov    %rbx,%rsi
  lea    D85(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D109(%rip),%rdi
  call   <puts@plt>
  lea    D91(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D68(%rip),%rdi
  call   <puts@plt>
  lea    D6(%rip),%rdi
  call   <puts@plt>
  mov    $0xda5,%esi
  lea    D83(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D27(%rip),%rdi
  call   <puts@plt>
  lea    D40(%rip),%rsi
  lea    D8(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D2(%rip),%rdi
  call   <puts@plt>
  pop    %rbx
  ret
```

tool_calls: name: unpack_data
arguments: label: D29
type: string
name: unpack_data
arguments: label: D64
type: string
name: unpack_data
arguments: label: D85
type: string
name: unpack_data
arguments: label: D109
type: string
name: unpack_data
arguments: label: D91
type: string
name: unpack_data
arguments: label: D68
type: string
name: unpack_data
arguments: label: D6
type: string
name: unpack_data
arguments: label: D83
type: string
name: unpack_data
arguments: label: D27
type: string
name: unpack_data
arguments: label: D40
type: string
name: unpack_data
arguments: label: D8
type: string
name: unpack_data
arguments: label: D2
type: string

tool: D29: 
Port Knocking Backdoor - client


tool: D64: Usage:


tool: D85: %s [required] [optional]



tool: D109: [required]:

tool: D91: 	 -d <dest_ip>		destination ip

tool: D68: [optional]:

tool: D6: 	 -p <port>		port connect to

tool: D83: 				(default port: %d)


tool: D27: 	 -i <interface>		interface to use

tool: D40: lo

tool: D8: 				(default interface: %s)


tool: D2: 


assistant: ```c
void usage(char *name) {
  printf("\nPort Knocking Backdoor - client\n\n");
  printf("Usage:\n\n");
  printf("%s [required] [optional]\n\n", name);
  printf("[required]:\n");
  printf("\t -d <dest_ip>\t\tdestination ip\n");
  printf("\n");
  printf("[optional]:\n");
  printf("\t -p <port>\t\tport connect to\n");
  printf("\t\t\t\t(default port: %d)\n", 3493);
  printf("\t -i <interface>\t\tinterface to use\n");
  printf("\t\t\t\t(default interface: %s)\n", "lo");
  printf("\n\n");
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<usage>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  lea    D29(%rip),%rdi
  call   <puts@plt>
  lea    D54(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rsi
  lea    D93(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D1(%rip),%rdi
  call   <puts@plt>
  lea    D73(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D105(%rip),%rdi
  call   <puts@plt>
  lea    D72(%rip),%rdi
  call   <puts@plt>
  mov    $0xda5,%esi
  lea    D26(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D65(%rip),%rdi
  call   <puts@plt>
  lea    D117(%rip),%rdi
  lea    D11(%rip),%rsi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D5(%rip),%rdi
  pop    %rbp
  jmp    1080 <puts@plt>
```

tool_calls: name: parse_data
arguments: label: D29
type_infered: string
name: parse_data
arguments: label: D54
type_infered: string
name: parse_data
arguments: label: D93
type_infered: string
name: parse_data
arguments: label: D1
type_infered: string
name: parse_data
arguments: label: D73
type_infered: string
name: parse_data
arguments: label: D105
type_infered: string
name: parse_data
arguments: label: D72
type_infered: string
name: parse_data
arguments: label: D26
type_infered: string
name: parse_data
arguments: label: D65
type_infered: string
name: parse_data
arguments: label: D117
type_infered: string
name: parse_data
arguments: label: D11
type_infered: string
name: parse_data
arguments: label: D5
type_infered: string

tool: D29: 
Port Knocking Backdoor - client


tool: D54: Usage:


tool: D93: %s [required] [optional]



tool: D1: [required]:

tool: D73: 	 -d <dest_ip>		destination ip

tool: D105: [optional]:

tool: D72: 	 -p <port>		port connect to

tool: D26: 				(default port: %d)


tool: D65: 	 -i <interface>		interface to use

tool: D117: 				(default interface: %s)


tool: D11: lo

tool: D5: 


assistant: ```c
void usage(char *name) {
  printf("\nPort Knocking Backdoor - client\n\n");
  printf("Usage:\n\n");
  printf("%s [required] [optional]\n\n", name);
  printf("[required]:\n");
  printf("\t -d <dest_ip>\t\tdestination ip\n");
  printf("\n");
  printf("[optional]:\n");
  printf("\t -p <port>\t\tport connect to\n");
  printf("\t\t\t\t(default port: %d)\n", 3493);
  printf("\t -i <interface>\t\tinterface to use\n");
  printf("\t\t\t\t(default interface: %s)\n", "lo");
  printf("\n\n");
}
```
user: What is the c source code of the assembly code below:

```asm
<usage>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  lea    D97(%rip),%rdi
  call   <puts@plt>
  lea    D52(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rsi
  lea    D46(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D67(%rip),%rdi
  call   <puts@plt>
  lea    D24(%rip),%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D119(%rip),%rdi
  call   <puts@plt>
  lea    D17(%rip),%rdi
  call   <puts@plt>
  mov    $0xda5,%esi
  lea    D50(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D43(%rip),%rdi
  call   <puts@plt>
  lea    D4(%rip),%rdi
  lea    D113(%rip),%rsi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D62(%rip),%rdi
  pop    %rbp
  jmp    1080 <puts@plt>
```

tool_calls: name: unpack_data
arguments: tag: D97
type_infered: string
name: unpack_data
arguments: tag: D52
type_infered: string
name: unpack_data
arguments: tag: D46
type_infered: string
name: unpack_data
arguments: tag: D67
type_infered: string
name: unpack_data
arguments: tag: D24
type_infered: string
name: unpack_data
arguments: tag: D119
type_infered: string
name: unpack_data
arguments: tag: D17
type_infered: string
name: unpack_data
arguments: tag: D50
type_infered: string
name: unpack_data
arguments: tag: D43
type_infered: string
name: unpack_data
arguments: tag: D4
type_infered: string
name: unpack_data
arguments: tag: D113
type_infered: string
name: unpack_data
arguments: tag: D62
type_infered: string

tool: D97: 
Port Knocking Backdoor - client


tool: D52: Usage:


tool: D46: %s [required] [optional]



tool: D67: [required]:

tool: D24: 	 -d <dest_ip>		destination ip

tool: D119: [optional]:

tool: D17: 	 -p <port>		port connect to

tool: D50: 				(default port: %d)


tool: D43: 	 -i <interface>		interface to use

tool: D4: 				(default interface: %s)


tool: D113: lo

tool: D62: 


assistant: ```c
void usage(char *name) {
  printf("\nPort Knocking Backdoor - client\n\n");
  printf("Usage:\n\n");
  printf("%s [required] [optional]\n\n", name);
  printf("[required]:\n");
  printf("\t -d <dest_ip>\t\tdestination ip\n");
  printf("\n");
  printf("[optional]:\n");
  printf("\t -p <port>\t\tport connect to\n");
  printf("\t\t\t\t(default port: %d)\n", 3493);
  printf("\t -i <interface>\t\tinterface to use\n");
  printf("\t\t\t\t(default interface: %s)\n", "lo");
  printf("\n\n");
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<hx4_x4djbx33a_128_ref>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8,-0x68(%rbp)
  mov    %r9,-0x70(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x50(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  movl   $0x1505,-0x20(%rbp)
  movl   $0x1505,-0x1c(%rbp)
  movl   $0x1505,-0x18(%rbp)
  movl   $0x1505,-0x14(%rbp)
  movl   $0x0,-0x38(%rbp)
  mov    -0x68(%rbp),%rdi
  mov    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rcx
  mov    -0x50(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  sub    $0x8,%rsp
  push   -0x70(%rbp)
  mov    %rdi,%r9
  mov    %rsi,%r8
  mov    %rax,%rsi
  mov    $0x10,%edi
  call   <hx4_check_params@plt>
  add    $0x10,%rsp
  mov    %eax,-0x34(%rbp)
  cmpl   $0x0,-0x34(%rbp)
  je     L23
  mov    -0x34(%rbp),%eax
  jmp    L31
L23:
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  jmp    L25
L20:
  mov    -0x38(%rbp),%eax
  cltq
  mov    -0x20(%rbp,%rax,4),%eax
  mov    %eax,%edx
  shl    $0x5,%edx
  add    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x38(%rbp),%eax
  cltq
  mov    %edx,-0x20(%rbp,%rax,4)
  addq   $0x4,-0x30(%rbp)
  mov    -0x38(%rbp),%eax
  add    $0x1,%eax
  cltd
  shr    $0x1e,%edx
  add    %edx,%eax
  and    $0x3,%eax
  sub    %edx,%eax
  mov    %eax,-0x38(%rbp)
L25:
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jb     L20
  mov    -0x58(%rbp),%rdx
  lea    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <hx4_xor_cookie_128@plt>
  lea    -0x20(%rbp),%rcx
  mov    -0x68(%rbp),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    $0x0,%eax
L31:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L29
  call   <__stack_chk_fail@plt>
L29:
  leave
  ret
```

assistant: ```c
int hx4_x4djbx33a_128_ref(const void *buffer, size_t buffer_size, const void *cookie, size_t cookie_sz, void *out_hash, size_t out_hash_size) {
  const uint8_t *p;
  const uint8_t *const buffer_end = (uint8_t *)buffer + buffer_size;
  uint32_t state[] = {5381, 5381, 5381, 5381};
  int state_i = 0;
  int rc;
  rc = hx4_check_params(sizeof(state), buffer, buffer_size, cookie, cookie_sz, out_hash, out_hash_size);
  if (rc != (0)) {
    return rc;
  }
  p = buffer;
  while (p < buffer_end) {
    state[state_i] = state[state_i] * 33 + *p;
    p++;
    state_i = (state_i + 1) % 4;
  }
  hx4_xor_cookie_128(state, cookie);
  memcpy(out_hash, state, sizeof(state));
  return (0);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<hx4_x4djbx33a_128_ref>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%r14
  mov    %rdx,%r13
  mov    %r8,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x20(%rsp)
  xor    %eax,%eax
  movl   $0x1505,0x8(%rsp)
  movl   $0x1505,0xc(%rsp)
  movl   $0x1505,0x10(%rsp)
  movl   $0x1505,0x14(%rsp)
  push   %r9
  mov    %r8,%r9
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rsi,%rdx
  mov    %rdi,%rsi
  mov    $0x10,%edi
  call   <hx4_check_params@plt>
  mov    %eax,%ebp
  add    $0x10,%rsp
  test   %eax,%eax
  jne    L20
  lea    (%rbx,%r14,4),%rsi
  cmp    %rsi,%rbx
  jae    L36
L17:
  movslq %eax,%rcx
  mov    (%rsp,%rcx,4),%edi
  mov    %edi,%edx
  shl    $0x5,%edx
  add    %edi,%edx
  add    (%rbx),%edx
  mov    %edx,(%rsp,%rcx,4)
  add    $0x4,%rbx
  add    $0x1,%eax
  cltd
  shr    $0x1e,%edx
  add    %edx,%eax
  and    $0x3,%eax
  sub    %edx,%eax
  cmp    %rbx,%rsi
  ja     L17
L36:
  mov    %rsp,%rbx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <hx4_xor_cookie_128@plt>
  mov    $0x10,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <memcpy@plt>
L20:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L21
  mov    %ebp,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L21:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int hx4_x4djbx33a_128_ref(const void *buffer, size_t buffer_size, const void *cookie, size_t cookie_sz, void *out_hash, size_t out_hash_size) {
  const uint8_t *p;
  const uint8_t *const buffer_end = (uint8_t *)buffer + buffer_size;
  uint32_t state[] = {5381, 5381, 5381, 5381};
  int state_i = 0;
  int rc;
  rc = hx4_check_params(sizeof(state), buffer, buffer_size, cookie, cookie_sz, out_hash, out_hash_size);
  if (rc != (0)) {
    return rc;
  }
  p = buffer;
  while (p < buffer_end) {
    state[state_i] = state[state_i] * 33 + *p;
    p++;
    state_i = (state_i + 1) % 4;
  }
  hx4_xor_cookie_128(state, cookie);
  memcpy(out_hash, state, sizeof(state));
  return (0);
}
```