ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么:

```asm
<read_n_bytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L30
  mov    %edi,%r13d
  mov    %rsi,%rbp
  mov    %rdx,%r12
  test   %rdx,%rdx
  je     L30
  movq   $0x0,(%rsp)
  mov    %rsi,%rbx
  mov    %rsp,%r14
L16:
  mov    %rbp,%rsi
  sub    %rbx,%rsi
  add    %r12,%rsi
  mov    %r14,%rcx
  mov    %rbx,%rdx
  mov    %r13d,%edi
  call   <receive@plt>
  test   %rax,%rax
  jne    L42
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L27
  sub    %rax,%rbx
  jne    L16
L27:
  mov    %ebp,%eax
  sub    %ebx,%eax
L12:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L73
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L30:
  mov    $0xffffffff,%eax
  jmp    L12
L42:
  mov    $0xffffffff,%eax
  jmp    L12
L73:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int read_n_bytes(int fd, size_t n, char *buf) {
  if (!n || !buf)
    return -1;
  size_t rx = 0;
  size_t to_read = n;
  while (to_read > 0) {
    if (receive(fd, buf + (n - to_read), to_read, &rx) != 0) {
      return -1;
    } else if (rx == 0) {
      break;
    } else {
      to_read -= rx;
    }
  }
  return n - to_read;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<read_n_bytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L39
  mov    %rdx,%r12
  test   %rdx,%rdx
  je     L39
  mov    %edi,%r13d
  mov    %rsi,%rbp
  mov    %rsi,%rbx
  mov    %rsp,%r14
  movq   $0x0,(%rsp)
  nopl   0x0(%rax)
L60:
  mov    %rbp,%rsi
  mov    %r14,%rcx
  mov    %rbx,%rdx
  mov    %r13d,%edi
  sub    %rbx,%rsi
  add    %r12,%rsi
  call   <receive@plt>
  test   %rax,%rax
  jne    L39
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L61
  sub    %rax,%rbx
  jne    L60
  xor    %ebx,%ebx
L61:
  mov    %ebp,%eax
  sub    %ebx,%eax
L14:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L3
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L39:
  mov    $0xffffffff,%eax
  jmp    L14
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int read_n_bytes(int fd, size_t n, char *buf) {
  if (!n || !buf)
    return -1;
  size_t rx = 0;
  size_t to_read = n;
  while (to_read > 0) {
    if (receive(fd, buf + (n - to_read), to_read, &rx) != 0) {
      return -1;
    } else if (rx == 0) {
      break;
    } else {
      to_read -= rx;
    }
  }
  return n - to_read;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<read_n_bytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L35
  mov    %rdx,%r12
  test   %rdx,%rdx
  je     L35
  mov    %edi,%r13d
  mov    %rsi,%rbp
  mov    %rsi,%rbx
  mov    %rsp,%r14
  movq   $0x0,(%rsp)
  nopl   0x0(%rax)
L61:
  mov    %rbp,%rsi
  mov    %r14,%rcx
  mov    %rbx,%rdx
  mov    %r13d,%edi
  sub    %rbx,%rsi
  add    %r12,%rsi
  call   <receive@plt>
  test   %rax,%rax
  jne    L35
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L18
  sub    %rax,%rbx
  jne    L61
  xor    %ebx,%ebx
L18:
  mov    %ebp,%eax
  sub    %ebx,%eax
L24:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L62
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L35:
  mov    $0xffffffff,%eax
  jmp    L24
L62:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int read_n_bytes(int fd, size_t n, char *buf) {
  if (!n || !buf)
    return -1;
  size_t rx = 0;
  size_t to_read = n;
  while (to_read > 0) {
    if (receive(fd, buf + (n - to_read), to_read, &rx) != 0) {
      return -1;
    } else if (rx == 0) {
      break;
    } else {
      to_read -= rx;
    }
  }
  return n - to_read;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<_get_next_pwr_of_two>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0x1,-0x8(%rbp)
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L16
L13:
  mov    -0x8(%rbp),%eax
  mov    -0x4(%rbp),%edx
  mov    %eax,%ecx
  shr    %cl,%edx
  mov    %edx,%eax
  or     %eax,-0x4(%rbp)
  shll   -0x8(%rbp)
L16:
  cmpl   $0x3,-0x8(%rbp)
  jbe    L13
  mov    -0x4(%rbp),%eax
  add    $0x1,%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned int _get_next_pwr_of_two(unsigned int number) {
  unsigned int shift = 1, next = number - 1;
  for (; shift < sizeof(next); shift *= 2)
    next = next | next >> shift;
  return next + 1;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<_get_next_pwr_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  shr    %eax
  or     %eax,%edi
  mov    %edi,%eax
  shr    $0x2,%eax
  or     %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
unsigned int _get_next_pwr_of_two(unsigned int number) {
  unsigned int shift = 1, next = number - 1;
  for (; shift < sizeof(next); shift *= 2)
    next = next | next >> shift;
  return next + 1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<_get_next_pwr_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  shr    %eax
  or     %eax,%edi
  mov    %edi,%eax
  shr    $0x2,%eax
  or     %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
unsigned int _get_next_pwr_of_two(unsigned int number) {
  unsigned int shift = 1, next = number - 1;
  for (; shift < sizeof(next); shift *= 2)
    next = next | next >> shift;
  return next + 1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<_get_next_pwr_of_two>:
  endbr64
  sub    $0x1,%edi
  mov    %edi,%eax
  shr    %eax
  or     %eax,%edi
  mov    %edi,%eax
  shr    $0x2,%eax
  or     %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
unsigned int _get_next_pwr_of_two(unsigned int number) {
  unsigned int shift = 1, next = number - 1;
  for (; shift < sizeof(next); shift *= 2)
    next = next | next >> shift;
  return next + 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x5,-0x4(%rbp)
L152:
  cmpl   $0x0,-0xc(%rbp)
  je     L32
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0xc(%rbp)
  jge    L23
  jmp    L126
L32:
  nop
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jge    L122
  jmp    L141
L126:
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jge    L31
  cmpl   $0x0,-0x8(%rbp)
  je     L38
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x8(%rbp)
  jne    L35
  jmp    L38
L23:
  nop
  mov    -0xc(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  je     L5
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jge    L29
  jmp    L141
L38:
  nop
L141:
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x8(%rbp)
  jmp    L152
L35:
  nop
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x8(%rbp)
  jmp    L152
L122:
  nop
  jmp    L34
L31:
  nop
  jmp    L34
L29:
  nop
L34:
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L152
L5:
  nop
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D26
type_guessed: string
name: read_data
arguments: data_label: D6
type_guessed: string
name: read_data
arguments: data_label: D24
type_guessed: string

tool: D26: *

tool: D6:  

tool: D24: 


assistant: ```c
int main(int argc, char *argv[]) {
  int line = 0;
  int count = 0;
  int width = 5;
start:
  if (line == 0)
    goto drawTopLine;
  else if (line < width - 1)
    goto drawMiddleLine;
  else
    goto drawBottomLine;
drawTopLine:
  if (count < width)
    goto star;
  else
    goto newline;
drawMiddleLine:
  if (count < width) {
    if (count == 0 || count == width - 1)
      goto star;
    else
      goto space;
  } else
    goto newline;
drawBottomLine:
  if (line == width)
    goto end;
  if (count < width)
    goto star;
  else
    goto newline;
star:
  printf("*");
  count++;
  goto start;
space:
  printf(" ");
  count++;
  goto start;
newline:
  printf("\n");
  line++;
  count = 0;
  goto start;
end:
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    D22(%rip),%r13
  lea    D20(%rip),%r12
  lea    D21(%rip),%r14
  jmp    L80
L41:
  cmp    $0x4,%ebp
  jg     L83
L38:
  mov    %r12,%rdi
  call   <printf@plt>
  add    $0x1,%ebp
L80:
  test   %ebx,%ebx
  je     L41
  cmp    $0x3,%ebx
  jle    L66
  cmp    $0x5,%ebx
  je     L28
  cmp    $0x4,%ebp
  jle    L38
L83:
  mov    %r13,%rdi
  call   <printf@plt>
  add    $0x1,%ebx
  mov    $0x0,%ebp
  jmp    L80
L66:
  cmp    $0x4,%ebp
  jg     L83
  test   $0xfffffffb,%ebp
  je     L38
  mov    %r14,%rdi
  call   <printf@plt>
  add    $0x1,%ebp
  jmp    L80
L28:
  mov    $0x0,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

tool_calls: name: parse_data
arguments: tag: D22
type: string
name: parse_data
arguments: tag: D20
type: string
name: parse_data
arguments: tag: D21
type: string

tool: D22: 


tool: D20: *

tool: D21:  

assistant: ```c
int main(int argc, char *argv[]) {
  int line = 0;
  int count = 0;
  int width = 5;
start:
  if (line == 0)
    goto drawTopLine;
  else if (line < width - 1)
    goto drawMiddleLine;
  else
    goto drawBottomLine;
drawTopLine:
  if (count < width)
    goto star;
  else
    goto newline;
drawMiddleLine:
  if (count < width) {
    if (count == 0 || count == width - 1)
      goto star;
    else
      goto space;
  } else
    goto newline;
drawBottomLine:
  if (line == width)
    goto end;
  if (count < width)
    goto star;
  else
    goto newline;
star:
  printf("*");
  count++;
  goto start;
space:
  printf(" ");
  count++;
  goto start;
newline:
  printf("\n");
  line++;
  count = 0;
  goto start;
end:
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r14
  lea    D6(%rip),%r14
  push   %r13
  lea    D14(%rip),%r13
  push   %r12
  lea    D18(%rip),%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  xor    %ebx,%ebx
  nopl   (%rax)
L121:
  test   %ebp,%ebp
  je     L45
  cmp    $0x3,%ebp
  jle    L2
  cmp    $0x5,%ebp
  je     L10
  cmp    $0x5,%ebx
  jne    L14
  mov    %r13,%rdi
  add    $0x1,%ebp
  call   <printf@plt>
  cmp    $0x5,%ebp
  jne    L119
L10:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L77:
  mov    %r12,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
L45:
  cmp    $0x5,%ebx
  jne    L77
  mov    $0x1,%ebp
L60:
  mov    %r13,%rdi
  call   <printf@plt>
L119:
  mov    $0x1,%ebx
L105:
  mov    %r12,%rdi
  call   <printf@plt>
  jmp    L121
  nopl   0x0(%rax)
L2:
  cmp    $0x5,%ebx
  je     L62
  test   %ebx,%ebx
  je     L119
  cmp    $0x4,%ebx
  je     L82
  mov    %r14,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  jmp    L121
  xchg   %ax,%ax
L14:
  add    $0x1,%ebx
  jmp    L105
  nopl   (%rax)
L82:
  mov    $0x5,%ebx
  jmp    L105
  nop
L62:
  add    $0x1,%ebp
  jmp    L60
```

tool_calls: name: parse_data
arguments: data_label: D6
data_type: string
name: parse_data
arguments: data_label: D14
data_type: string
name: parse_data
arguments: data_label: D18
data_type: string

tool: D6:  

tool: D14: 


tool: D18: *

assistant: ```c
int main(int argc, char *argv[]) {
  int line = 0;
  int count = 0;
  int width = 5;
start:
  if (line == 0)
    goto drawTopLine;
  else if (line < width - 1)
    goto drawMiddleLine;
  else
    goto drawBottomLine;
drawTopLine:
  if (count < width)
    goto star;
  else
    goto newline;
drawMiddleLine:
  if (count < width) {
    if (count == 0 || count == width - 1)
      goto star;
    else
      goto space;
  } else
    goto newline;
drawBottomLine:
  if (line == width)
    goto end;
  if (count < width)
    goto star;
  else
    goto newline;
star:
  printf("*");
  count++;
  goto start;
space:
  printf(" ");
  count++;
  goto start;
newline:
  printf("\n");
  line++;
  count = 0;
  goto start;
end:
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<main>:
  endbr64
  push   %r14
  lea    D17(%rip),%r14
  push   %r13
  lea    D19(%rip),%r13
  push   %r12
  lea    D6(%rip),%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  xor    %ebx,%ebx
L130:
  test   %ebp,%ebp
  je     L102
L87:
  cmp    $0x3,%ebp
  jle    L111
L43:
  cmp    $0x5,%ebp
  je     L86
  cmp    $0x5,%ebx
  jne    L55
  mov    %r13,%rdi
  add    $0x1,%ebp
  call   <printf@plt>
  cmp    $0x5,%ebp
  jne    L73
L86:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L73:
  mov    %r12,%rdi
  mov    $0x1,%ebx
  call   <printf@plt>
L55:
  mov    %r12,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  test   %ebp,%ebp
  jne    L87
L102:
  cmp    $0x5,%ebx
  jne    L132
  mov    %r13,%rdi
  mov    $0x1,%ebx
  mov    $0x1,%ebp
  call   <printf@plt>
  mov    %r12,%rdi
  call   <printf@plt>
  jmp    L115
L111:
  cmp    $0x5,%ebx
  je     L82
  test   %ebx,%ebx
  je     L152
  cmp    $0x4,%ebx
  jne    L115
  mov    %r12,%rdi
  call   <printf@plt>
L82:
  add    $0x1,%ebp
L29:
  mov    %r13,%rdi
  mov    $0x1,%ebx
  call   <printf@plt>
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    $0x3,%ebp
  jg     L43
L143:
  mov    $0x1,%ebx
L115:
  mov    %r14,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  jmp    L130
  nopl   0x0(%rax)
L132:
  mov    %r12,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  cmp    $0x5,%ebx
  jne    L132
  mov    $0x1,%ebp
  jmp    L29
L152:
  mov    %r12,%rdi
  call   <printf@plt>
  jmp    L143
```

tool_calls: name: parse_data
arguments: label: D17
type_guessed: string
name: parse_data
arguments: label: D19
type_guessed: string
name: parse_data
arguments: label: D6
type_guessed: string

tool: D17:  

tool: D19: 


tool: D6: *

assistant: ```c
int main(int argc, char *argv[]) {
  int line = 0;
  int count = 0;
  int width = 5;
start:
  if (line == 0)
    goto drawTopLine;
  else if (line < width - 1)
    goto drawMiddleLine;
  else
    goto drawBottomLine;
drawTopLine:
  if (count < width)
    goto star;
  else
    goto newline;
drawMiddleLine:
  if (count < width) {
    if (count == 0 || count == width - 1)
      goto star;
    else
      goto space;
  } else
    goto newline;
drawBottomLine:
  if (line == width)
    goto end;
  if (count < width)
    goto star;
  else
    goto newline;
star:
  printf("*");
  count++;
  goto start;
space:
  printf(" ");
  count++;
  goto start;
newline:
  printf("\n");
  line++;
  count = 0;
  goto start;
end:
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<spi_send_only>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    $0xd4035010,%eax
  mov    %rax,-0x18(%rbp)
  mov    $0xd4035008,%eax
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %eax,-0x24(%rbp)
  jmp    L12
L28:
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x18(%rbp),%rax
  mov    %rdx,(%rax)
  subl   $0x1,-0x24(%rbp)
L12:
  cmpl   $0x0,-0x24(%rbp)
  jne    L28
  mov    -0x38(%rbp),%rax
  mov    %eax,-0x24(%rbp)
  jmp    L6
L33:
  nop
L45:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  and    $0x8,%eax
  test   %rax,%rax
  je     L45
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  subl   $0x1,-0x24(%rbp)
L6:
  cmpl   $0x0,-0x24(%rbp)
  jne    L33
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void spi_send_only(long len, long adr) {
  unsigned char *p = (char *)adr;
  unsigned long regval;
  volatile unsigned long *fifo = (volatile unsigned long *)0xd4035010;
  volatile unsigned long *stat = (volatile unsigned long *)0xd4035008;
  int i;
  for (i = len; i; i--)
    *fifo = (unsigned long)*p++;
  for (i = len; i; i--) {
    while ((*stat & 8) == 0)
      ;
    regval = *fifo;
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<spi_send_only>:
  endbr64
  mov    %rsi,%rax
  mov    %edi,%ecx
  test   %edi,%edi
  je     L19
  lea    -0x1(%rdi),%edx
  lea    0x1(%rsi,%rdx,1),%rdi
  mov    $0xd4035010,%esi
L35:
  mov    %rax,%rdx
  add    $0x1,%rax
  movzbl (%rdx),%edx
  mov    %rdx,(%rsi)
  cmp    %rdi,%rax
  jne    L35
  mov    $0xd4035008,%edx
  mov    $0xd4035010,%esi
L27:
  mov    (%rdx),%rax
  test   $0x8,%al
  je     L27
  mov    (%rsi),%rax
  sub    $0x1,%ecx
  jne    L27
L19:
  ret
```

assistant: ```c
void spi_send_only(long len, long adr) {
  unsigned char *p = (char *)adr;
  unsigned long regval;
  volatile unsigned long *fifo = (volatile unsigned long *)0xd4035010;
  volatile unsigned long *stat = (volatile unsigned long *)0xd4035008;
  int i;
  for (i = len; i; i--)
    *fifo = (unsigned long)*p++;
  for (i = len; i; i--) {
    while ((*stat & 8) == 0)
      ;
    regval = *fifo;
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<spi_send_only>:
  endbr64
  mov    %edi,%ecx
  test   %edi,%edi
  je     L26
  sub    $0x1,%edi
  lea    0x1(%rsi),%rax
  mov    $0xd4035010,%r8d
  add    %rax,%rdi
  jmp    L17
  nopl   0x0(%rax)
L45:
  add    $0x1,%rax
L17:
  mov    %rsi,%rdx
  mov    %rax,%rsi
  movzbl (%rdx),%edx
  mov    %rdx,(%r8)
  cmp    %rdi,%rax
  jne    L45
  mov    $0xd4035008,%edx
  mov    $0xd4035010,%esi
  nop
L35:
  mov    (%rdx),%rax
  test   $0x8,%al
  je     L35
  mov    (%rsi),%rax
  sub    $0x1,%ecx
  jne    L35
L26:
  ret
```

assistant: ```c
void spi_send_only(long len, long adr) {
  unsigned char *p = (char *)adr;
  unsigned long regval;
  volatile unsigned long *fifo = (volatile unsigned long *)0xd4035010;
  volatile unsigned long *stat = (volatile unsigned long *)0xd4035008;
  int i;
  for (i = len; i; i--)
    *fifo = (unsigned long)*p++;
  for (i = len; i; i--) {
    while ((*stat & 8) == 0)
      ;
    regval = *fifo;
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<spi_send_only>:
  endbr64
  mov    %edi,%ecx
  test   %edi,%edi
  je     L0
  sub    $0x1,%edi
  lea    0x1(%rsi),%rax
  mov    $0xd4035010,%r8d
  add    %rax,%rdi
  jmp    L29
  nopl   0x0(%rax)
L6:
  add    $0x1,%rax
L29:
  mov    %rsi,%rdx
  mov    %rax,%rsi
  movzbl (%rdx),%edx
  mov    %rdx,(%r8)
  cmp    %rdi,%rax
  jne    L6
  mov    $0xd4035008,%edx
  mov    $0xd4035010,%esi
  nop
L36:
  mov    (%rdx),%rax
  test   $0x8,%al
  je     L36
  mov    (%rsi),%rax
  sub    $0x1,%ecx
  jne    L36
L0:
  ret
```

assistant: ```c
void spi_send_only(long len, long adr) {
  unsigned char *p = (char *)adr;
  unsigned long regval;
  volatile unsigned long *fifo = (volatile unsigned long *)0xd4035010;
  volatile unsigned long *stat = (volatile unsigned long *)0xd4035008;
  int i;
  for (i = len; i; i--)
    *fifo = (unsigned long)*p++;
  for (i = len; i; i--) {
    while ((*stat & 8) == 0)
      ;
    regval = *fifo;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<zaxisTypeToGrib1ltype>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0xffffffff,-0x4(%rbp)
  cmpl   $0x18,-0x14(%rbp)
  ja     L164
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  lea    D14(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D14(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  movl   $0x1,-0x4(%rbp)
  jmp    L164
  movl   $0x66,-0x4(%rbp)
  jmp    L164
  movl   $0x69,-0x4(%rbp)
  jmp    L164
  movl   $0x67,-0x4(%rbp)
  jmp    L164
  movl   $0x6b,-0x4(%rbp)
  jmp    L164
  movl   $0xa0,-0x4(%rbp)
  jmp    L164
  movl   $0x71,-0x4(%rbp)
  jmp    L164
  movl   $0x2,-0x4(%rbp)
  jmp    L164
  movl   $0x3,-0x4(%rbp)
  jmp    L164
  movl   $0x4,-0x4(%rbp)
  jmp    L164
  movl   $0x8,-0x4(%rbp)
  jmp    L164
  movl   $0x9,-0x4(%rbp)
  jmp    L164
  movl   $0xa2,-0x4(%rbp)
  jmp    L164
  movl   $0xa3,-0x4(%rbp)
  jmp    L164
  movl   $0xa4,-0x4(%rbp)
  jmp    L164
  movl   $0xa5,-0x4(%rbp)
  jmp    L164
  movl   $0xa6,-0x4(%rbp)
  jmp    L164
  movl   $0xa,-0x4(%rbp)
  nop
L164:
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int zaxisTypeToGrib1ltype(int zaxistype) {
  int grib_ltype = -1;
  switch (zaxistype) {
  case 0: {
    grib_ltype = 1;
    break;
  }
  case 12: {
    grib_ltype = 102;
    break;
  }
  case 5: {
    grib_ltype = 105;
    break;
  }
  case 10: {
    grib_ltype = 103;
    break;
  }
  case 11: {
    grib_ltype = 107;
    break;
  }
  case 6: {
    grib_ltype = 160;
    break;
  }
  case 8: {
    grib_ltype = 113;
    break;
  }
  case 16: {
    grib_ltype = 2;
    break;
  }
  case 17: {
    grib_ltype = 3;
    break;
  }
  case 18: {
    grib_ltype = 4;
    break;
  }
  case 13: {
    grib_ltype = 8;
    break;
  }
  case 14: {
    grib_ltype = 9;
    break;
  }
  case 20: {
    grib_ltype = 162;
    break;
  }
  case 21: {
    grib_ltype = 163;
    break;
  }
  case 22: {
    grib_ltype = 164;
    break;
  }
  case 23: {
    grib_ltype = 165;
    break;
  }
  case 24: {
    grib_ltype = 166;
    break;
  }
  case 15: {
    grib_ltype = 10;
    break;
  }
  }
  return (grib_ltype);
}
```
user: Translate the below assembly code into C programming language:

```asm
<zaxisTypeToGrib1ltype>:
  endbr64
  cmp    $0x18,%edi
  ja     L8
  mov    %edi,%edi
  lea    D0(%rip),%rdx
  movslq (%rdx,%rdi,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  mov    $0x1,%eax
  ret
  mov    $0x66,%eax
  ret
  mov    $0x69,%eax
  ret
  mov    $0x67,%eax
  ret
  mov    $0x6b,%eax
  ret
  mov    $0xa0,%eax
  ret
  mov    $0x71,%eax
  ret
  mov    $0x2,%eax
  ret
  mov    $0x3,%eax
  ret
  mov    $0x4,%eax
  ret
  mov    $0x8,%eax
  ret
  mov    $0x9,%eax
  ret
  mov    $0xa2,%eax
  ret
  mov    $0xa3,%eax
  ret
  mov    $0xa4,%eax
  ret
  mov    $0xa5,%eax
  ret
  mov    $0xa6,%eax
  ret
  mov    $0xa,%eax
  ret
L8:
  mov    $0xffffffff,%eax
  ret
```

assistant: ```c
int zaxisTypeToGrib1ltype(int zaxistype) {
  int grib_ltype = -1;
  switch (zaxistype) {
  case 0: {
    grib_ltype = 1;
    break;
  }
  case 12: {
    grib_ltype = 102;
    break;
  }
  case 5: {
    grib_ltype = 105;
    break;
  }
  case 10: {
    grib_ltype = 103;
    break;
  }
  case 11: {
    grib_ltype = 107;
    break;
  }
  case 6: {
    grib_ltype = 160;
    break;
  }
  case 8: {
    grib_ltype = 113;
    break;
  }
  case 16: {
    grib_ltype = 2;
    break;
  }
  case 17: {
    grib_ltype = 3;
    break;
  }
  case 18: {
    grib_ltype = 4;
    break;
  }
  case 13: {
    grib_ltype = 8;
    break;
  }
  case 14: {
    grib_ltype = 9;
    break;
  }
  case 20: {
    grib_ltype = 162;
    break;
  }
  case 21: {
    grib_ltype = 163;
    break;
  }
  case 22: {
    grib_ltype = 164;
    break;
  }
  case 23: {
    grib_ltype = 165;
    break;
  }
  case 24: {
    grib_ltype = 166;
    break;
  }
  case 15: {
    grib_ltype = 10;
    break;
  }
  }
  return (grib_ltype);
}
```