user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<parse_http_proto_ws>:
  endbr64
  push   %r15
  lea    D4(%rip),%r15
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  lea    D25(%rip),%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x8,%rsp
L94:
  mov    %r12,%rdi
  call   <readline_client_ws@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L81
L122:
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L11
  mov    %r13,%rdi
  call   <strlen@plt>
  cltq
  lea    (%rbx,%rax,1),%rdi
  call   <strdup@plt>
  mov    %r12,%rdi
  mov    %rax,%rbp
  call   <readline_client_ws@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L122
L81:
  test   %rbp,%rbp
  je     L29
  test   %r14,%r14
  je     L32
  lea    D11(%rip),%r13
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %r13,%rsi
  mov    %r14,%rdi
  mov    %eax,%edx
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L50
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  mov    %rbp,%rsi
  call   <generate_upgrade_response_ws@plt>
  mov    %rbp,%rdi
  test   %rax,%rax
  js     L128
  call   <free@plt>
  mov    %r12,%rdi
  call   <upgrade_client_ws@plt>
  sar    $0x3f,%rax
  mov    %rax,%r12
L126:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L11:
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L94
  mov    %r15,%rdi
  call   <strlen@plt>
  cltq
  lea    (%rbx,%rax,1),%rdi
  call   <strdup@plt>
  mov    %rax,%r14
  jmp    L94
L29:
  test   %r14,%r14
  je     L32
L50:
  mov    %r14,%rdi
  call   <free@plt>
L32:
  mov    $0xffffffff,%r12d
  test   %rbp,%rbp
  je     L126
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L126
L128:
  call   <free@plt>
  mov    $0xffffffff,%r12d
  jmp    L126
```

tool_calls: name: retrieve_data
arguments: label: D4
type: string
name: retrieve_data
arguments: label: D25
type: string
name: retrieve_data
arguments: label: D11
type: string

tool: D4: Sec-WebSocket-Protocol: 

tool: D25: Sec-WebSocket-Key: 

tool: D11: katcp

assistant: ```c
int parse_http_proto_ws(struct ws_client *c) {
  char *line, *key, *proto;
  key = NULL;
  proto = NULL;
  while ((line = (char *)readline_client_ws(c)) != NULL) {
    if (strstr((const char *)line, "Sec-WebSocket-Key: ") != NULL) {
      key = strdup(line + strlen("Sec-WebSocket-Key: "));
    } else if (strstr((const char *)line, "Sec-WebSocket-Protocol: ") != NULL) {
      proto = strdup(line + strlen("Sec-WebSocket-Protocol: "));
    }
  }
  if (key != NULL && proto != NULL && strncmp(proto, "katcp", strlen("katcp")) == 0) {
    if (proto != NULL) {
      free(proto);
      proto = NULL;
    }
    if (generate_upgrade_response_ws(c, key) < 0) {
      if (key != NULL) {
        free(key);
        key = NULL;
      }
      return -1;
    }
    if (key != NULL) {
      free(key);
      key = NULL;
    }
    if (upgrade_client_ws(c) < 0) {
      return -1;
    }
  } else {
    if (proto != NULL) {
      free(proto);
      proto = NULL;
    }
    if (key != NULL) {
      free(key);
      key = NULL;
    }
    return -1;
  }
  if (proto != NULL) {
    free(proto);
    proto = NULL;
  }
  if (key != NULL) {
    free(key);
    key = NULL;
  }
  return 0;
}
```