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

```asm
<RandomFunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  sub    $0x6b,%eax
  mov    %al,-0x9(%rbp)
  movb   $0x0,-0xa(%rbp)
  jmp    L7
L3:
  movb   $0x0,-0xb(%rbp)
  jmp    L4
L20:
  movzbl -0xa(%rbp),%eax
  cltq
  movzbl -0x9(%rbp,%rax,1),%ecx
  movzbl -0xb(%rbp),%eax
  cltq
  movzbl -0x9(%rbp,%rax,1),%edx
  movzbl -0xa(%rbp),%eax
  or     %ecx,%edx
  cltq
  mov    %dl,-0x9(%rbp,%rax,1)
  addb   $0x2,-0xb(%rbp)
L4:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    %al,-0xb(%rbp)
  jb     L20
  movzbl -0xa(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0xa(%rbp)
L7:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    %al,-0xa(%rbp)
  jb     L3
  movzbl -0x9(%rbp),%eax
  sub    $0x43,%eax
  lea    0x0(,%rax,8),%edx
  mov    -0x20(%rbp),%rax
  mov    %dl,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L19
  call   <__stack_chk_fail@plt>
L19:
  leave
  ret
```

assistant: ```c
void RandomFunc(unsigned char input[1], unsigned char output[1]) {
  unsigned char state[1];
  unsigned char local2;
  unsigned char local1;
  {
    state[0UL] = (input[0UL] - 51238316UL) - (unsigned char)191;
    local1 = 0UL;
    while (local1 < input[1UL]) {
      local2 = 0UL;
      while (local2 < input[1UL]) {
        state[local1] |= state[local2];
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] + 707305405UL) << (unsigned char)3;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<RandomFunc>:
  endbr64
  movzbl (%rdi),%r8d
  movzbl 0x1(%rdi),%edx
  mov    $0x0,%ecx
  test   %dl,%dl
  je     L29
L14:
  mov    $0x0,%eax
L10:
  add    $0x2,%eax
  cmp    %al,%dl
  ja     L10
  add    $0x1,%ecx
  cmp    %cl,%dl
  jne    L14
L29:
  lea    -0x70(,%r8,8),%eax
  mov    %al,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned char input[1], unsigned char output[1]) {
  unsigned char state[1];
  unsigned char local2;
  unsigned char local1;
  {
    state[0UL] = (input[0UL] - 51238316UL) - (unsigned char)191;
    local1 = 0UL;
    while (local1 < input[1UL]) {
      local2 = 0UL;
      while (local2 < input[1UL]) {
        state[local1] |= state[local2];
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] + 707305405UL) << (unsigned char)3;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<RandomFunc>:
  endbr64
  movzbl 0x1(%rdi),%edx
  movzbl (%rdi),%r8d
  xor    %ecx,%ecx
  test   %dl,%dl
  je     L17
  nopw   0x0(%rax,%rax,1)
L14:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L2:
  add    $0x2,%eax
  cmp    %dl,%al
  jb     L2
  add    $0x1,%ecx
  cmp    %dl,%cl
  jne    L14
L17:
  lea    -0x70(,%r8,8),%eax
  mov    %al,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned char input[1], unsigned char output[1]) {
  unsigned char state[1];
  unsigned char local2;
  unsigned char local1;
  {
    state[0UL] = (input[0UL] - 51238316UL) - (unsigned char)191;
    local1 = 0UL;
    while (local1 < input[1UL]) {
      local2 = 0UL;
      while (local2 < input[1UL]) {
        state[local1] |= state[local2];
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] + 707305405UL) << (unsigned char)3;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<RandomFunc>:
  endbr64
  movzbl 0x1(%rdi),%edx
  movzbl (%rdi),%r8d
  xor    %ecx,%ecx
  test   %dl,%dl
  je     L23
  nopw   0x0(%rax,%rax,1)
L22:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L14:
  add    $0x2,%eax
  cmp    %dl,%al
  jb     L14
  add    $0x1,%ecx
  cmp    %dl,%cl
  jne    L22
L23:
  lea    -0x70(,%r8,8),%eax
  mov    %al,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned char input[1], unsigned char output[1]) {
  unsigned char state[1];
  unsigned char local2;
  unsigned char local1;
  {
    state[0UL] = (input[0UL] - 51238316UL) - (unsigned char)191;
    local1 = 0UL;
    while (local1 < input[1UL]) {
      local2 = 0UL;
      while (local2 < input[1UL]) {
        state[local1] |= state[local2];
        local2 += 2UL;
      }
      local1++;
    }
    output[0UL] = (state[0UL] + 707305405UL) << (unsigned char)3;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<get_strike>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  movss  %xmm0,-0x24(%rbp)
  movss  %xmm1,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movss  -0x24(%rbp),%xmm0
  movss  %xmm0,-0x14(%rbp)
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0x10(%rbp)
  movss  -0x28(%rbp),%xmm0
  movss  %xmm0,-0xc(%rbp)
  lea    -0x14(%rbp),%rax
  mov    $0x3,%esi
  mov    %rax,%rdi
  call   <to_unit_vector@plt>
  mov    -0x14(%rbp),%eax
  movd   %eax,%xmm0
  call   <acos@plt>
  movsd  D15(%rip),%xmm1
  mulsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,-0x1c(%rbp)
  movss  -0x1c(%rbp),%xmm0
  movss  D17(%rip),%xmm1
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x18(%rbp)
  movss  -0x18(%rbp),%xmm0
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D15
type: f64
name: retrieve_data
arguments: tag: D17
type: f32

tool: D15: 57.2957795131

tool: D17: 90

assistant: ```c
float get_strike(float nhat1, float nhat3) {
  float nproj[3];
  float surf_normal[3];
  float strike;
  float theta;
  nproj[0] = nhat1;
  nproj[1] = 0.0f;
  nproj[2] = nhat3;
  to_unit_vector(nproj, 3);
  theta = acos(nproj[0]) * 57.2957795131;
  strike = theta - 90.0;
  return strike;
}
```
user: Translate the below assembly code into C programming language:

```asm
<get_strike>:
  endbr64
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movss  %xmm0,0xc(%rsp)
  movl   $0x0,0x10(%rsp)
  movss  %xmm1,0x14(%rsp)
  lea    0xc(%rsp),%rdi
  mov    $0x3,%esi
  call   <to_unit_vector@plt>
  movss  0xc(%rsp),%xmm0
  call   <acos@plt>
  mulsd  D6(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  subss  D15(%rip),%xmm0
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x28,%rsp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D6
type: f64
name: disassemble_data
arguments: label: D15
type: f32

tool: D6: 57.2957795131

tool: D15: 90

assistant: ```c
float get_strike(float nhat1, float nhat3) {
  float nproj[3];
  float surf_normal[3];
  float strike;
  float theta;
  nproj[0] = nhat1;
  nproj[1] = 0.0f;
  nproj[2] = nhat3;
  to_unit_vector(nproj, 3);
  theta = acos(nproj[0]) * 57.2957795131;
  strike = theta - 90.0;
  return strike;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<get_strike>:
  endbr64
  sub    $0x28,%rsp
  mov    $0x3,%esi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdi
  movss  %xmm0,0xc(%rsp)
  movss  %xmm1,0x14(%rsp)
  movl   $0x0,0x10(%rsp)
  call   <to_unit_vector@plt>
  movss  0xc(%rsp),%xmm0
  call   <acos@plt>
  mulsd  D4(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  subss  D7(%rip),%xmm0
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x28,%rsp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D4
type_infered: f64
name: parse_data
arguments: label: D7
type_infered: f32

tool: D4: 57.2957795131

tool: D7: 90

assistant: ```c
float get_strike(float nhat1, float nhat3) {
  float nproj[3];
  float surf_normal[3];
  float strike;
  float theta;
  nproj[0] = nhat1;
  nproj[1] = 0.0f;
  nproj[2] = nhat3;
  to_unit_vector(nproj, 3);
  theta = acos(nproj[0]) * 57.2957795131;
  strike = theta - 90.0;
  return strike;
}
```
user: What is the c source code of the assembly code below:

```asm
<get_strike>:
  endbr64
  sub    $0x28,%rsp
  mov    $0x3,%esi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rdi
  movss  %xmm0,0xc(%rsp)
  movss  %xmm1,0x14(%rsp)
  movl   $0x0,0x10(%rsp)
  call   <to_unit_vector@plt>
  movss  0xc(%rsp),%xmm0
  call   <acos@plt>
  mulsd  D4(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  subss  D12(%rip),%xmm0
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x28,%rsp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D4
type: f64
name: parse_data
arguments: data_label: D12
type: f32

tool: D4: 57.2957795131

tool: D12: 90

assistant: ```c
float get_strike(float nhat1, float nhat3) {
  float nproj[3];
  float surf_normal[3];
  float strike;
  float theta;
  nproj[0] = nhat1;
  nproj[1] = 0.0f;
  nproj[2] = nhat3;
  to_unit_vector(nproj, 3);
  theta = acos(nproj[0]) * 57.2957795131;
  strike = theta - 90.0;
  return strike;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<ft_strlen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L8
  mov    $0x0,%eax
  jmp    L19
L14:
  addl   $0x1,-0x4(%rbp)
L8:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L14
  mov    -0x4(%rbp),%eax
L19:
  pop    %rbp
  ret
```

assistant: ```c
int ft_strlen(const char *string) {
  int size;
  size = 0;
  if (!string)
    return 0;
  while (string[size]) {
    size++;
  }
  return size;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<ft_strlen>:
  endbr64
  test   %rdi,%rdi
  je     L33
  cmpb   $0x0,(%rdi)
  je     L24
  mov    $0x1,%eax
L14:
  mov    %eax,%edx
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L14
L28:
  mov    %edx,%eax
  ret
L33:
  mov    $0x0,%edx
  jmp    L28
L24:
  mov    $0x0,%edx
  jmp    L28
```

assistant: ```c
int ft_strlen(const char *string) {
  int size;
  size = 0;
  if (!string)
    return 0;
  while (string[size]) {
    size++;
  }
  return size;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<ft_strlen>:
  endbr64
  test   %rdi,%rdi
  je     L26
  cmpb   $0x0,(%rdi)
  je     L26
  mov    $0x1,%eax
  nopl   0x0(%rax,%rax,1)
L20:
  mov    %eax,%r8d
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L20
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L26:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int ft_strlen(const char *string) {
  int size;
  size = 0;
  if (!string)
    return 0;
  while (string[size]) {
    size++;
  }
  return size;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<ft_strlen>:
  endbr64
  test   %rdi,%rdi
  je     L13
  cmpb   $0x0,(%rdi)
  je     L13
  mov    $0x1,%eax
  nopl   0x0(%rax,%rax,1)
L20:
  mov    %eax,%r8d
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L20
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L13:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int ft_strlen(const char *string) {
  int size;
  size = 0;
  if (!string)
    return 0;
  while (string[size]) {
    size++;
  }
  return size;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<fc8080_video_select>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %ecx,%eax
  mov    %esi,%ecx
  mov    %cl,-0x1c(%rbp)
  mov    %dl,-0x20(%rbp)
  mov    %al,-0x24(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movw   $0x0,-0xa(%rbp)
  cmpb   $0x0,-0x24(%rbp)
  jne    L11
  mov    -0x18(%rbp),%rax
  mov    $0x1c,%edx
  mov    $0xe00,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x0,%edx
  mov    $0xe00,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
L11:
  lea    -0xa(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    $0xe0a,%esi
  mov    %rax,%rdi
  call   <bbm_word_read@plt>
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%eax
  movzbl %al,%eax
  test   %eax,%eax
  je     L32
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%eax
  and    $0xff00,%eax
  test   %eax,%eax
  je     L32
  cmpb   $0x0,-0x24(%rbp)
  jne    L32
  mov    -0x18(%rbp),%rax
  mov    $0x0,%edx
  mov    $0xe02,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  movzbl -0x24(%rbp),%eax
  lea    0xe0a(%rax),%ecx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  movzwl -0xa(%rbp),%eax
  movzwl %ax,%eax
  movzbl %al,%edx
  movzbl -0x24(%rbp),%eax
  lea    0xe0a(%rax),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  mov    -0x18(%rbp),%rax
  mov    $0x1,%edx
  mov    $0xe02,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
L32:
  movzbl -0x20(%rbp),%edx
  movzbl -0x1c(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <fc8080_channel_select@plt>
  test   %rax,%rax
  je     L39
  mov    $0x1,%eax
  jmp    L49
L39:
  movzbl -0x1c(%rbp),%eax
  or     $0x40,%eax
  movzbl %al,%edx
  movzbl -0x24(%rbp),%eax
  lea    0xe0a(%rax),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  movzbl -0x1c(%rbp),%eax
  or     $0x40,%eax
  movzbl %al,%edx
  movzbl -0x20(%rbp),%eax
  lea    0x910(%rax),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bbm_write@plt>
  mov    $0x0,%eax
L49:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L27
  call   <__stack_chk_fail@plt>
L27:
  leave
  ret
```

assistant: ```c
int fc8080_video_select(void *handle, unsigned char subch_id, unsigned char buf_id, unsigned char cdi_id) {
  unsigned short fec_en = 0;
  if (cdi_id == 0) {
    bbm_write(handle, 0x0e00, 0x1c);
    bbm_write(handle, 0x0e00, 0x00);
  }
  bbm_word_read(handle, 0x0e0a, &fec_en);
  if ((fec_en & 0x00ff) && (fec_en & 0xff00) && cdi_id == 0) {
    bbm_write(handle, 0x0e02, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, fec_en & 0x00ff);
    bbm_write(handle, 0x0e02, 0x01);
  }
  if (fc8080_channel_select(handle, subch_id, buf_id) != 0)
    return 1;
  bbm_write(handle, 0x0e0a + cdi_id, 0x40 | subch_id);
  bbm_write(handle, 0x0910 + buf_id, 0x40 | subch_id);
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<fc8080_video_select>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r12d
  mov    %edx,%ebx
  mov    %ecx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movw   $0x0,0x6(%rsp)
  test   %cl,%cl
  je     L13
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  call   <bbm_word_read@plt>
L23:
  movzbl %bl,%ebx
  movzbl %r12b,%esi
  mov    %ebx,%edx
  mov    %rbp,%rdi
  call   <fc8080_channel_select@plt>
  mov    %rax,%rdx
  mov    $0x1,%eax
  test   %rdx,%rdx
  je     L64
L0:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L56
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L13:
  mov    $0x1c,%edx
  mov    $0xe00,%esi
  call   <bbm_write@plt>
  mov    $0x0,%edx
  mov    $0xe00,%esi
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  mov    %rbp,%rdi
  call   <bbm_word_read@plt>
  movzwl 0x6(%rsp),%eax
  test   %al,%al
  je     L23
  test   $0xff00,%ax
  je     L23
  mov    $0x0,%edx
  mov    $0xe02,%esi
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  mov    $0x0,%edx
  mov    $0xe0a,%esi
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  movzbl 0x6(%rsp),%edx
  mov    $0xe0a,%esi
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  mov    $0x1,%edx
  mov    $0xe02,%esi
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  jmp    L23
L64:
  or     $0x40,%r12d
  movzbl %r12b,%r12d
  movzbl %r13b,%esi
  add    $0xe0a,%esi
  mov    %r12d,%edx
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  lea    0x910(%rbx),%esi
  mov    %r12d,%edx
  mov    %rbp,%rdi
  call   <bbm_write@plt>
  mov    $0x0,%eax
  jmp    L0
L56:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fc8080_video_select(void *handle, unsigned char subch_id, unsigned char buf_id, unsigned char cdi_id) {
  unsigned short fec_en = 0;
  if (cdi_id == 0) {
    bbm_write(handle, 0x0e00, 0x1c);
    bbm_write(handle, 0x0e00, 0x00);
  }
  bbm_word_read(handle, 0x0e0a, &fec_en);
  if ((fec_en & 0x00ff) && (fec_en & 0xff00) && cdi_id == 0) {
    bbm_write(handle, 0x0e02, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, fec_en & 0x00ff);
    bbm_write(handle, 0x0e02, 0x01);
  }
  if (fc8080_channel_select(handle, subch_id, buf_id) != 0)
    return 1;
  bbm_write(handle, 0x0e0a + cdi_id, 0x40 | subch_id);
  bbm_write(handle, 0x0910 + buf_id, 0x40 | subch_id);
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<fc8080_video_select>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  xor    %eax,%eax
  mov    %ax,0x6(%rsp)
  test   %cl,%cl
  je     L47
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  call   <bbm_word_read@plt>
L9:
  movzbl %bl,%ebx
  movzbl %bpl,%esi
  mov    %r13,%rdi
  mov    %ebx,%edx
  call   <fc8080_channel_select@plt>
  mov    %rax,%r8
  mov    $0x1,%eax
  test   %r8,%r8
  jne    L2
  or     $0x40,%ebp
  movzbl %r12b,%esi
  mov    %r13,%rdi
  movzbl %bpl,%r14d
  add    $0xe0a,%esi
  mov    %r14d,%edx
  call   <bbm_write@plt>
  lea    0x910(%rbx),%esi
  mov    %r14d,%edx
  mov    %r13,%rdi
  call   <bbm_write@plt>
  xor    %eax,%eax
L2:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L15
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L47:
  mov    $0x1c,%edx
  mov    $0xe00,%esi
  call   <bbm_write@plt>
  xor    %edx,%edx
  mov    $0xe00,%esi
  mov    %r13,%rdi
  call   <bbm_write@plt>
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  mov    %r13,%rdi
  call   <bbm_word_read@plt>
  movzwl 0x6(%rsp),%eax
  test   %al,%al
  je     L9
  test   $0xff00,%ax
  je     L9
  xor    %edx,%edx
  mov    %r13,%rdi
  mov    $0xe02,%esi
  call   <bbm_write@plt>
  xor    %edx,%edx
  mov    %r13,%rdi
  mov    $0xe0a,%esi
  call   <bbm_write@plt>
  movzbl 0x6(%rsp),%edx
  mov    %r13,%rdi
  mov    $0xe0a,%esi
  call   <bbm_write@plt>
  mov    $0x1,%edx
  mov    $0xe02,%esi
  mov    %r13,%rdi
  call   <bbm_write@plt>
  jmp    L9
L15:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fc8080_video_select(void *handle, unsigned char subch_id, unsigned char buf_id, unsigned char cdi_id) {
  unsigned short fec_en = 0;
  if (cdi_id == 0) {
    bbm_write(handle, 0x0e00, 0x1c);
    bbm_write(handle, 0x0e00, 0x00);
  }
  bbm_word_read(handle, 0x0e0a, &fec_en);
  if ((fec_en & 0x00ff) && (fec_en & 0xff00) && cdi_id == 0) {
    bbm_write(handle, 0x0e02, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, fec_en & 0x00ff);
    bbm_write(handle, 0x0e02, 0x01);
  }
  if (fc8080_channel_select(handle, subch_id, buf_id) != 0)
    return 1;
  bbm_write(handle, 0x0e0a + cdi_id, 0x40 | subch_id);
  bbm_write(handle, 0x0910 + buf_id, 0x40 | subch_id);
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<fc8080_video_select>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  xor    %eax,%eax
  mov    %ax,0x6(%rsp)
  test   %cl,%cl
  je     L55
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  call   <bbm_word_read@plt>
L57:
  movzbl %bl,%ebx
  movzbl %bpl,%esi
  mov    %r13,%rdi
  mov    %ebx,%edx
  call   <fc8080_channel_select@plt>
  mov    %rax,%r8
  mov    $0x1,%eax
  test   %r8,%r8
  jne    L9
  or     $0x40,%ebp
  movzbl %r12b,%esi
  mov    %r13,%rdi
  movzbl %bpl,%r14d
  add    $0xe0a,%esi
  mov    %r14d,%edx
  call   <bbm_write@plt>
  lea    0x910(%rbx),%esi
  mov    %r14d,%edx
  mov    %r13,%rdi
  call   <bbm_write@plt>
  xor    %eax,%eax
L9:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L28
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L55:
  mov    $0x1c,%edx
  mov    $0xe00,%esi
  call   <bbm_write@plt>
  xor    %edx,%edx
  mov    $0xe00,%esi
  mov    %r13,%rdi
  call   <bbm_write@plt>
  lea    0x6(%rsp),%rdx
  mov    $0xe0a,%esi
  mov    %r13,%rdi
  call   <bbm_word_read@plt>
  movzwl 0x6(%rsp),%eax
  test   %al,%al
  je     L57
  test   $0xff00,%ax
  je     L57
  xor    %edx,%edx
  mov    %r13,%rdi
  mov    $0xe02,%esi
  call   <bbm_write@plt>
  xor    %edx,%edx
  mov    %r13,%rdi
  mov    $0xe0a,%esi
  call   <bbm_write@plt>
  movzbl 0x6(%rsp),%edx
  mov    %r13,%rdi
  mov    $0xe0a,%esi
  call   <bbm_write@plt>
  mov    $0x1,%edx
  mov    $0xe02,%esi
  mov    %r13,%rdi
  call   <bbm_write@plt>
  jmp    L57
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fc8080_video_select(void *handle, unsigned char subch_id, unsigned char buf_id, unsigned char cdi_id) {
  unsigned short fec_en = 0;
  if (cdi_id == 0) {
    bbm_write(handle, 0x0e00, 0x1c);
    bbm_write(handle, 0x0e00, 0x00);
  }
  bbm_word_read(handle, 0x0e0a, &fec_en);
  if ((fec_en & 0x00ff) && (fec_en & 0xff00) && cdi_id == 0) {
    bbm_write(handle, 0x0e02, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, 0x00);
    bbm_write(handle, 0x0e0a + cdi_id, fec_en & 0x00ff);
    bbm_write(handle, 0x0e02, 0x01);
  }
  if (fc8080_channel_select(handle, subch_id, buf_id) != 0)
    return 1;
  bbm_write(handle, 0x0e0a + cdi_id, 0x40 | subch_id);
  bbm_write(handle, 0x0910 + buf_id, 0x40 | subch_id);
  return 0;
}
```