user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<process_bw>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %esi,%r13d
  mov    %rdx,%r14
  mov    %rcx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L6
  mov    %rdi,%rbx
  call   <strlen@plt>
  test   %eax,%eax
  jne    L85
L6:
  test   %r13d,%r13d
  jne    L105
  lea    D114(%rip),%rcx
  mov    %r14,%rdx
  lea    D46(%rip),%rsi
  lea    D39(%rip),%rdi
  call   <camserv_log@plt>
  movb   $0xff,(%r12)
  mov    $0xffffff,%ebp
  jmp    L81
L85:
  lea    D8(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L79
  mov    %rbx,%rdi
  call   <valid_bw_color@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  jne    L106
  test   %r13d,%r13d
  jne    L18
  lea    D114(%rip),%rcx
  mov    %r14,%rdx
  lea    D122(%rip),%rsi
  lea    D39(%rip),%rdi
  call   <camserv_log@plt>
  mov    $0xffffffff,%eax
  mov    $0xffffff,%ebp
  jmp    L13
L106:
  lea    0x4(%rsp),%rdx
  lea    D107(%rip),%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x4(%rsp),%ebp
  mov    %ebp,%eax
  shl    $0x10,%ebp
  and    $0xff0000,%ebp
  jmp    L13
L79:
  mov    $0xff000000,%ebp
  jmp    L81
L105:
  lea    D76(%rip),%rcx
  mov    %r14,%rdx
  lea    D46(%rip),%rsi
  lea    D39(%rip),%rdi
  call   <camserv_log@plt>
  movb   $0x0,(%r12)
  mov    $0x0,%ebp
L81:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L103
  mov    %ebp,%eax
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L18:
  lea    D76(%rip),%rcx
  mov    %r14,%rdx
  lea    D122(%rip),%rsi
  lea    D39(%rip),%rdi
  call   <camserv_log@plt>
  mov    $0x0,%eax
L13:
  mov    %al,(%r12)
  jmp    L81
L103:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D114
data_type: string
name: read_data
arguments: data_tag: D46
data_type: string
name: read_data
arguments: data_tag: D39
data_type: string
name: read_data
arguments: data_tag: D8
data_type: string
name: read_data
arguments: data_tag: D122
data_type: string
name: read_data
arguments: data_tag: D107
data_type: string
name: read_data
arguments: data_tag: D76
data_type: string

tool: D114: fg

tool: D46: Invalid [%s]:%s value given.  Using default

tool: D39: textfilter

tool: D8: transparent

tool: D122: Invalid [%s]:%s color given.  Format should be: #CC, or 'transparent'

tool: D107: %*c%2x

tool: D76: bg

assistant: ```c
int process_bw(const char *strcolour, int is_bg, char *secname, unsigned char *resval) {
  if (!strcolour || !strlen(strcolour)) {
    camserv_log("textfilter",
                "Invalid [%s]:%s value given.  "
                "Using default",
                secname, is_bg ? "bg" : "fg");
    if (is_bg) {
      *resval = (0x00ff0000 & 0x00000000) >> 16;
      return 0x00000000;
    } else {
      *resval = (0x00ff0000 & 0x00ffffff) >> 16;
      return 0x00ffffff;
    }
  }
  if (!strcmp(strcolour, "transparent"))
    return 0xff000000;
  else {
    int bwval;
    if (!valid_bw_color(strcolour)) {
      camserv_log("textfilter",
                  "Invalid [%s]:%s color given.  "
                  "Format should be: #CC, or 'transparent'",
                  secname, is_bg ? "bg" : "fg");
      if (is_bg) {
        *resval = (0x00ff0000 & 0x00000000) >> 16;
        return 0x00000000;
      } else {
        *resval = (0x00ff0000 & 0x00ffffff) >> 16;
        return 0x00ffffff;
      }
    }
    sscanf(strcolour, "%*c%2x", &bwval);
    *resval = bwval;
    return (*resval << 16);
  }
}
```