ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below:

```asm
<set_CCA_mode>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x2,%di
  je     L37
  cmp    $0x3,%di
  je     L55
  cmp    $0x1,%di
  je     L53
L48:
  add    $0x8,%rsp
  ret
L53:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xdf,%esi
  or     $0x80,%sil
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x60,%esi
  mov    $0x3f,%edi
  call   <write_ZIGBEE_short@plt>
  jmp    L48
L37:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0x7f,%esi
  or     $0x40,%esi
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  jmp    L48
L55:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  or     $0xc0,%al
  movswl %ax,%esi
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x60,%esi
  mov    $0x3f,%edi
  call   <write_ZIGBEE_short@plt>
  jmp    L48
```

assistant: ```c
void set_CCA_mode(short int CCA_mode) {
  short int temp = 0;
  switch (CCA_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x80;
    temp = temp & 0xDF;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x40;
    temp = temp & 0x7F;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0xC0;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<set_CCA_mode>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x2,%di
  je     L30
  cmp    $0x3,%di
  je     L2
  cmp    $0x1,%di
  je     L6
  add    $0x8,%rsp
  ret
  nopl   0x0(%rax,%rax,1)
L30:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  mov    %eax,%esi
  and    $0x7f,%esi
  or     $0x40,%esi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  add    $0x8,%rsp
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  jmp    1070 <write_ZIGBEE_short@plt>
  nopw   0x0(%rax,%rax,1)
L6:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xdf,%esi
  or     $0x80,%sil
L21:
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x60,%esi
  mov    $0x3f,%edi
  add    $0x8,%rsp
  jmp    1070 <write_ZIGBEE_short@plt>
  nopl   0x0(%rax,%rax,1)
L2:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  or     $0xc0,%al
  movswl %ax,%esi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  jmp    L21
```

assistant: ```c
void set_CCA_mode(short int CCA_mode) {
  short int temp = 0;
  switch (CCA_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x80;
    temp = temp & 0xDF;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x40;
    temp = temp & 0x7F;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0xC0;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<set_CCA_mode>:
  endbr64
  sub    $0x8,%rsp
  cmp    $0x2,%di
  je     L8
  cmp    $0x3,%di
  je     L18
  cmp    $0x1,%di
  je     L4
  add    $0x8,%rsp
  ret
  nopl   0x0(%rax,%rax,1)
L8:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  mov    %eax,%esi
  and    $0x7f,%esi
  or     $0x40,%esi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  add    $0x8,%rsp
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  jmp    1070 <write_ZIGBEE_short@plt>
  nopw   0x0(%rax,%rax,1)
L4:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xdf,%esi
  or     $0x80,%sil
L35:
  mov    $0x3a,%edi
  call   <write_ZIGBEE_short@plt>
  mov    $0x60,%esi
  mov    $0x3f,%edi
  add    $0x8,%rsp
  jmp    1070 <write_ZIGBEE_short@plt>
  nopl   0x0(%rax,%rax,1)
L18:
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  or     $0xc0,%al
  movswl %ax,%esi
  call   <write_ZIGBEE_short@plt>
  mov    $0x3a,%edi
  call   <read_ZIGBEE_short@plt>
  mov    %eax,%esi
  and    $0xfb,%esi
  or     $0x38,%esi
  jmp    L35
```

assistant: ```c
void set_CCA_mode(short int CCA_mode) {
  short int temp = 0;
  switch (CCA_mode) {
  case 1: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x80;
    temp = temp & 0xDF;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  case 2: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x40;
    temp = temp & 0x7F;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
  } break;
  case 3: {
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0xC0;
    write_ZIGBEE_short(0x3A, temp);
    temp = read_ZIGBEE_short(0x3A);
    temp = temp | 0x38;
    temp = temp & 0xFB;
    write_ZIGBEE_short(0x3A, temp);
    write_ZIGBEE_short(0x3F, 0x60);
  } break;
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<sock_close>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0xa(%rbp),%rax
  mov    $0x2,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
L38:
  lea    -0xa(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  test   %rax,%rax
  jle    L25
  lea    -0xa(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  test   %rax,%rax
  jle    L40
  jmp    L38
L25:
  nop
  jmp    L46
L40:
  nop
L46:
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <shutdown@plt>
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L35
  call   <__stack_chk_fail@plt>
L35:
  leave
  ret
```

assistant: ```c
int sock_close(int sockfd) {
  char tmp[2];
  memset(tmp, '\0', sizeof(tmp));
  while (1) {
    if (read(sockfd, tmp, 1) <= 0)
      break;
    if (write(sockfd, tmp, 1) <= 0)
      break;
  }
  shutdown(sockfd, SHUT_RDWR);
  close(sockfd);
  return (0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<sock_close>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rdi
  mov    $0x2,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  lea    0x6(%rsp),%rbp
L5:
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <read@plt>
  test   %rax,%rax
  jle    L0
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <write@plt>
  test   %rax,%rax
  jg     L5
L0:
  mov    D4(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <shutdown@plt>
  mov    %ebx,%edi
  call   <close@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L26
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L26:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sock_close(int sockfd) {
  char tmp[2];
  memset(tmp, '\0', sizeof(tmp));
  while (1) {
    if (read(sockfd, tmp, 1) <= 0)
      break;
    if (write(sockfd, tmp, 1) <= 0)
      break;
  }
  shutdown(sockfd, SHUT_RDWR);
  close(sockfd);
  return (0);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<sock_close>:
  endbr64
  push   %rbp
  mov    $0x2,%edx
  mov    %edi,%ebp
  xor    %esi,%esi
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rbx
  mov    %rbx,%rdi
  call   <memset@plt>
  jmp    L36
  nopw   0x0(%rax,%rax,1)
L10:
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <write@plt>
  test   %rax,%rax
  jle    L9
L36:
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <read@plt>
  test   %rax,%rax
  jg     L10
L9:
  mov    D3(%rip),%rax
  mov    %ebp,%edi
  mov    (%rax),%esi
  call   <shutdown@plt>
  mov    %ebp,%edi
  call   <close@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sock_close(int sockfd) {
  char tmp[2];
  memset(tmp, '\0', sizeof(tmp));
  while (1) {
    if (read(sockfd, tmp, 1) <= 0)
      break;
    if (write(sockfd, tmp, 1) <= 0)
      break;
  }
  shutdown(sockfd, SHUT_RDWR);
  close(sockfd);
  return (0);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<sock_close>:
  endbr64
  push   %rbp
  mov    $0x2,%edx
  mov    %edi,%ebp
  xor    %esi,%esi
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rbx
  mov    %rbx,%rdi
  call   <memset@plt>
  jmp    L38
  nopw   0x0(%rax,%rax,1)
L31:
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <write@plt>
  test   %rax,%rax
  jle    L27
L38:
  mov    $0x1,%edx
  mov    %rbx,%rsi
  mov    %ebp,%edi
  call   <read@plt>
  test   %rax,%rax
  jg     L31
L27:
  mov    D3(%rip),%rax
  mov    %ebp,%edi
  mov    (%rax),%esi
  call   <shutdown@plt>
  mov    %ebp,%edi
  call   <close@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L36
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L36:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int sock_close(int sockfd) {
  char tmp[2];
  memset(tmp, '\0', sizeof(tmp));
  while (1) {
    if (read(sockfd, tmp, 1) <= 0)
      break;
    if (write(sockfd, tmp, 1) <= 0)
      break;
  }
  shutdown(sockfd, SHUT_RDWR);
  close(sockfd);
  return (0);
}
```
user: What is the c source code of the assembly code below?

```asm
<_capture_size>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x18(%rbp),%eax
  imul   %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int _capture_size(int w, int h) {
  int size = 0;
  size = h * (w + 1);
  return size;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<_capture_size>:
  endbr64
  lea    0x1(%rdi),%eax
  imul   %esi,%eax
  ret
```

assistant: ```c
int _capture_size(int w, int h) {
  int size = 0;
  size = h * (w + 1);
  return size;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<_capture_size>:
  endbr64
  lea    0x1(%rdi),%eax
  imul   %esi,%eax
  ret
```

assistant: ```c
int _capture_size(int w, int h) {
  int size = 0;
  size = h * (w + 1);
  return size;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<price_offset>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  cmpl   $0x100,-0x28(%rbp)
  jg     L55
  mov    $0x8,%eax
  jmp    L52
L55:
  mov    $0x8,%ebx
  mov    $0x100,%r12d
  cmpl   $0x61a80,-0x28(%rbp)
  jg     L73
  mov    $0x3c,%eax
  jmp    L72
L73:
  mov    $0x32,%eax
L72:
  mov    %eax,-0x14(%rbp)
L62:
  add    %r12d,%r12d
  mov    -0x28(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,%r12d
  jge    L78
  mov    %r12d,%eax
  and    $0x5ffc00,%eax
  test   %eax,%eax
  je     L83
  mov    -0x14(%rbp),%edx
  mov    %edx,%eax
  shl    $0x3,%eax
  add    %edx,%eax
  sar    $0x3,%eax
  mov    %eax,-0x14(%rbp)
L83:
  mov    -0x24(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L63
  mov    %ebx,%eax
  jmp    L52
L63:
  mov    -0x14(%rbp),%eax
  add    %eax,-0x24(%rbp)
  mov    -0x14(%rbp),%eax
  add    %eax,-0x28(%rbp)
  shll   -0x14(%rbp)
  add    $0x1,%ebx
  jmp    L62
L78:
  nop
  mov    %r12d,%eax
  sub    -0x28(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jl     L65
  add    $0x1,%ebx
L65:
  mov    %ebx,%eax
L52:
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

assistant: ```c
int price_offset(int num, int total) {
  if (total <= 256)
    return 8;
  register int res = 8;
  register int x = 256;
  int top = ((total <= 400000) ? 60 : 50);
  while (1) {
    x += x;
    if (x >= total + top)
      break;
    if (x & 0x002FFe00 * 2)
      top = ((9 * top) >> 3);
    if (num < top) {
      return res;
    }
    num += top;
    total += top;
    top += top;
    res++;
  }
  if (num >= x - total) {
    res++;
  }
  return res;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<price_offset>:
  endbr64
  mov    $0x8,%ecx
  cmp    $0x100,%esi
  jle    L21
  cmp    $0x61a80,%esi
  jg     L23
  cmp    $0x1c4,%esi
  jle    L20
  mov    $0x3c,%eax
  jmp    L87
L23:
  mov    $0x32,%eax
L87:
  mov    $0x200,%edx
  mov    $0x8,%ecx
  jmp    L16
L75:
  cmp    %edi,%eax
  jg     L21
  add    %eax,%edi
  add    %eax,%esi
  add    %eax,%eax
  add    $0x1,%ecx
  add    %edx,%edx
  lea    (%rsi,%rax,1),%r8d
  cmp    %edx,%r8d
  jle    L78
L16:
  test   $0x5ffc00,%edx
  je     L75
  lea    (%rax,%rax,8),%eax
  sar    $0x3,%eax
  jmp    L75
L20:
  mov    $0x200,%edx
  mov    $0x8,%ecx
L78:
  sub    %esi,%edx
  cmp    %edi,%edx
  setle  %al
  movzbl %al,%eax
  add    %eax,%ecx
L21:
  mov    %ecx,%eax
  ret
```

assistant: ```c
int price_offset(int num, int total) {
  if (total <= 256)
    return 8;
  register int res = 8;
  register int x = 256;
  int top = ((total <= 400000) ? 60 : 50);
  while (1) {
    x += x;
    if (x >= total + top)
      break;
    if (x & 0x002FFe00 * 2)
      top = ((9 * top) >> 3);
    if (num < top) {
      return res;
    }
    num += top;
    total += top;
    top += top;
    res++;
  }
  if (num >= x - total) {
    res++;
  }
  return res;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<price_offset>:
  endbr64
  mov    $0x8,%r8d
  cmp    $0x100,%esi
  jle    L26
  cmp    $0x61a80,%esi
  jle    L71
  mov    $0x32,%eax
L74:
  mov    $0x200,%edx
  mov    $0x8,%r8d
L15:
  cmp    %eax,%edi
  jl     L26
L34:
  add    %eax,%esi
  lea    (%rax,%rax,1),%ecx
  add    %edx,%edx
  add    %eax,%edi
  lea    (%rsi,%rcx,1),%r9d
  add    $0x1,%r8d
  cmp    %edx,%r9d
  jle    L43
  test   $0x5ffc00,%edx
  je     L21
  lea    (%rax,%rax,8),%eax
  add    %eax,%eax
  sar    $0x3,%eax
  cmp    %eax,%edi
  jge    L34
L26:
  mov    %r8d,%eax
  ret
  nopl   0x0(%rax)
L71:
  cmp    $0x1c4,%esi
  jle    L51
  mov    $0x3c,%eax
  jmp    L74
  nop
L21:
  mov    %ecx,%eax
  jmp    L15
L51:
  mov    $0x200,%edx
L43:
  sub    %esi,%edx
  xor    %eax,%eax
  cmp    %edi,%edx
  setle  %al
  add    %eax,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int price_offset(int num, int total) {
  if (total <= 256)
    return 8;
  register int res = 8;
  register int x = 256;
  int top = ((total <= 400000) ? 60 : 50);
  while (1) {
    x += x;
    if (x >= total + top)
      break;
    if (x & 0x002FFe00 * 2)
      top = ((9 * top) >> 3);
    if (num < top) {
      return res;
    }
    num += top;
    total += top;
    top += top;
    res++;
  }
  if (num >= x - total) {
    res++;
  }
  return res;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<price_offset>:
  endbr64
  mov    $0x8,%r8d
  cmp    $0x100,%esi
  jle    L6
  cmp    $0x61a80,%esi
  jle    L67
  mov    $0x32,%eax
L55:
  mov    $0x200,%edx
  mov    $0x8,%r8d
L36:
  cmp    %eax,%edi
  jl     L6
L33:
  add    %eax,%esi
  lea    (%rax,%rax,1),%ecx
  add    %edx,%edx
  add    %eax,%edi
  lea    (%rsi,%rcx,1),%r9d
  add    $0x1,%r8d
  cmp    %edx,%r9d
  jle    L75
  test   $0x5ffc00,%edx
  je     L53
  lea    (%rax,%rax,8),%eax
  add    %eax,%eax
  sar    $0x3,%eax
  cmp    %eax,%edi
  jge    L33
L6:
  mov    %r8d,%eax
  ret
  nopl   0x0(%rax)
L67:
  cmp    $0x1c4,%esi
  jle    L29
  mov    $0x3c,%eax
  jmp    L55
  nop
L53:
  mov    %ecx,%eax
  jmp    L36
L29:
  mov    $0x200,%edx
L75:
  sub    %esi,%edx
  xor    %eax,%eax
  cmp    %edi,%edx
  setle  %al
  add    %eax,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int price_offset(int num, int total) {
  if (total <= 256)
    return 8;
  register int res = 8;
  register int x = 256;
  int top = ((total <= 400000) ? 60 : 50);
  while (1) {
    x += x;
    if (x >= total + top)
      break;
    if (x & 0x002FFe00 * 2)
      top = ((9 * top) >> 3);
    if (num < top) {
      return res;
    }
    num += top;
    total += top;
    top += top;
    res++;
  }
  if (num >= x - total) {
    res++;
  }
  return res;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<argb2yuv420sp>:
  endbr64
  test   %ecx,%ecx
  jle    L66
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%r10
  mov    %edx,%r12d
  mov    %ecx,%r13d
  lea    -0x1(%rdx),%r11d
  lea    0x1(%r11),%rbp
  lea    0x0(,%rbp,4),%rax
  mov    %rax,-0x8(%rsp)
  mov    $0x0,%ebx
  mov    $0x0,%r14d
  jmp    L80
L76:
  test   %r12d,%r12d
  jle    L1
  lea    0x1(%r9),%rsi
  mov    %rdi,%rdx
  mov    %r14,%rcx
  jmp    L62
L10:
  movzbl 0x2(%rdx),%r15d
  sub    %eax,%r15d
  imul   $0x2c9,%r15d,%r15d
  movslq %r15d,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sar    $0x1f,%r15d
  sub    %r15d,%eax
  add    $0xffffff80,%eax
L39:
  mov    %al,-0x1(%rsi)
  movzbl 0x3(%rdx),%eax
  mov    %al,(%r10,%rcx,1)
  add    $0x4,%rdx
  lea    0x1(%rcx),%rax
  add    $0x1,%rsi
  cmp    %r11,%rcx
  je     L110
  mov    %rax,%rcx
L62:
  movzbl 0x2(%rdx),%eax
  imul   $0x12b,%eax,%eax
  movzbl 0x1(%rdx),%r15d
  imul   $0x24b,%r15d,%r15d
  add    %r15d,%eax
  movzbl (%rdx),%r15d
  imul   $0x72,%r15d,%r15d
  add    %r15d,%eax
  cltq
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  mov    %al,(%r8,%rcx,1)
  test   $0x1,%cl
  jne    L10
  movzbl (%rdx),%r15d
  sub    %eax,%r15d
  imul   $0x234,%r15d,%r15d
  movslq %r15d,%rax
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sar    $0x1f,%r15d
  sub    %r15d,%eax
  add    $0xffffff80,%eax
  jmp    L39
L110:
  add    %rbp,%r9
  add    %rbp,%r10
  add    -0x8(%rsp),%rdi
  add    %rbp,%r8
L1:
  add    $0x1,%ebx
  cmp    %r13d,%ebx
  je     L99
L80:
  test   $0x1,%bl
  je     L76
  mov    $0x0,%edx
  test   %r12d,%r12d
  jle    L1
L46:
  movzbl 0x2(%rdi,%rdx,4),%eax
  imul   $0x12b,%eax,%eax
  movzbl 0x1(%rdi,%rdx,4),%ecx
  imul   $0x24b,%ecx,%ecx
  add    %ecx,%eax
  movzbl (%rdi,%rdx,4),%ecx
  imul   $0x72,%ecx,%ecx
  add    %ecx,%eax
  cltq
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  mov    %al,(%r8,%rdx,1)
  movzbl 0x3(%rdi,%rdx,4),%eax
  mov    %al,(%r10,%rdx,1)
  mov    %rdx,%rax
  add    $0x1,%rdx
  cmp    %rax,%r11
  jne    L46
  add    %rbp,%r10
  add    -0x8(%rsp),%rdi
  add    %rbp,%r8
  jmp    L1
L99:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L66:
  ret
```

assistant: ```c
void argb2yuv420sp(unsigned char *src_p, unsigned char *alph, unsigned int width, unsigned int height, unsigned char *dest_y, unsigned char *dest_c) {
  int i, j;
  for (i = 0; i < (int)height; i++) {
    if ((i & 1) == 0) {
      for (j = 0; j < (int)width; j++) {
        *dest_y = (299 * src_p[2] + 587 * src_p[1] + 114 * src_p[0]) / 1000;
        if ((j & 1) == 0) {
          *dest_c++ = 128 + (564 * (src_p[0] - *dest_y) / 1000);
        } else {
          *dest_c++ = 128 + (713 * (src_p[2] - *dest_y) / 1000);
        }
        *alph++ = src_p[3];
        src_p += 4;
        dest_y++;
      }
    } else {
      for (j = 0; j < (int)width; j++) {
        *dest_y = (299 * src_p[2] + 587 * src_p[1] + 114 * src_p[0]) / 1000;
        *alph++ = src_p[3];
        src_p += 4;
        dest_y++;
      }
    }
  }
  return;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<argb2yuv420sp>:
  endbr64
  test   %ecx,%ecx
  jle    L68
  push   %r15
  xor    %r10d,%r10d
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %ecx,%ebp
  lea    -0x1(%rdx),%ecx
  lea    0x1(%rcx),%r11
  push   %rbx
  mov    %edx,%ebx
  lea    0x0(,%r11,4),%r12
  nopl   0x0(%rax)
L29:
  test   $0x1,%r10b
  je     L107
  xor    %edx,%edx
  test   %ebx,%ebx
  jle    L75
  nopl   0x0(%rax)
L33:
  movzbl 0x2(%rdi,%rdx,4),%eax
  movzbl 0x1(%rdi,%rdx,4),%r13d
  imul   $0x12b,%eax,%eax
  imul   $0x24b,%r13d,%r13d
  add    %r13d,%eax
  movzbl (%rdi,%rdx,4),%r13d
  imul   $0x72,%r13d,%r13d
  add    %r13d,%eax
  imul   $0x10624dd3,%rax,%rax
  shr    $0x26,%rax
  mov    %al,(%r8,%rdx,1)
  movzbl 0x3(%rdi,%rdx,4),%eax
  mov    %al,(%rsi,%rdx,1)
  mov    %rdx,%rax
  add    $0x1,%rdx
  cmp    %rax,%rcx
  jne    L33
  add    %r11,%rsi
  add    %r12,%rdi
  add    %r11,%r8
L75:
  add    $0x1,%r10d
  cmp    %r10d,%ebp
  jne    L29
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L107:
  test   %ebx,%ebx
  jle    L75
  lea    0x1(%r9),%r14
  mov    %rdi,%rdx
  xor    %r13d,%r13d
  jmp    L109
L1:
  movzbl (%rdx),%r15d
  sub    %eax,%r15d
  imul   $0x234,%r15d,%r15d
L74:
  movslq %r15d,%rax
  sar    $0x1f,%r15d
  add    $0x4,%rdx
  add    $0x1,%r14
  imul   $0x10624dd3,%rax,%rax
  sar    $0x26,%rax
  sub    %r15d,%eax
  add    $0xffffff80,%eax
  mov    %al,-0x2(%r14)
  movzbl -0x1(%rdx),%eax
  mov    %al,(%rsi,%r13,1)
  lea    0x1(%r13),%rax
  cmp    %rcx,%r13
  je     L48
  mov    %rax,%r13
L109:
  movzbl 0x2(%rdx),%eax
  movzbl 0x1(%rdx),%r15d
  imul   $0x12b,%eax,%eax
  imul   $0x24b,%r15d,%r15d
  add    %r15d,%eax
  movzbl (%rdx),%r15d
  imul   $0x72,%r15d,%r15d
  add    %r15d,%eax
  imul   $0x10624dd3,%rax,%rax
  shr    $0x26,%rax
  mov    %al,(%r8,%r13,1)
  test   $0x1,%r13b
  je     L1
  movzbl 0x2(%rdx),%r15d
  sub    %eax,%r15d
  imul   $0x2c9,%r15d,%r15d
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L48:
  add    %r11,%r9
  add    %r11,%rsi
  add    %r12,%rdi
  add    %r11,%r8
  jmp    L75
L68:
  ret
```

assistant: ```c
void argb2yuv420sp(unsigned char *src_p, unsigned char *alph, unsigned int width, unsigned int height, unsigned char *dest_y, unsigned char *dest_c) {
  int i, j;
  for (i = 0; i < (int)height; i++) {
    if ((i & 1) == 0) {
      for (j = 0; j < (int)width; j++) {
        *dest_y = (299 * src_p[2] + 587 * src_p[1] + 114 * src_p[0]) / 1000;
        if ((j & 1) == 0) {
          *dest_c++ = 128 + (564 * (src_p[0] - *dest_y) / 1000);
        } else {
          *dest_c++ = 128 + (713 * (src_p[2] - *dest_y) / 1000);
        }
        *alph++ = src_p[3];
        src_p += 4;
        dest_y++;
      }
    } else {
      for (j = 0; j < (int)width; j++) {
        *dest_y = (299 * src_p[2] + 587 * src_p[1] + 114 * src_p[0]) / 1000;
        *alph++ = src_p[3];
        src_p += 4;
        dest_y++;
      }
    }
  }
  return;
}
```