user: Please show me the C implementation that matches the assembly code listed below:

```asm
<string_match>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rsi,%rsi
  je     L44
  cmpb   $0x0,(%rsi)
  mov    %rsi,%rbp
  jne    L123
L44:
  xor    %r12d,%r12d
L144:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L123:
  mov    %rdi,%r13
  lea    D4(%rip),%rsi
  mov    %rbp,%rdi
  mov    %edx,%ebx
  call   <strcmp@plt>
  mov    $0x1,%r12d
  test   %rax,%rax
  je     L144
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %rbp,%rdi
  movslq %eax,%r12
  call   <strlen@plt>
  cmpb   $0x2a,0x0(%rbp)
  movslq %eax,%rdx
  movzbl -0x1(%rbp,%rdx,1),%ecx
  je     L122
  cmp    $0x2a,%cl
  je     L125
  mov    %rbp,%rsi
  mov    %r13,%rdi
  test   %ebx,%ebx
  jne    L35
L48:
  call   <string_strcasecmp@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  sete   %r12b
  jmp    L144
  nopl   0x0(%rax)
L122:
  lea    -0x1(%rax),%esi
  cmp    $0x2a,%cl
  je     L50
  cmp    %esi,%r12d
  jl     L44
  mov    %r13,%rdi
  lea    0x1(%rbp),%rsi
  sub    %rdx,%rdi
  lea    0x1(%rdi,%r12,1),%rdi
  test   %ebx,%ebx
  je     L48
L35:
  call   <strcmp@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  sete   %r12b
  jmp    L144
L50:
  cmp    %esi,%r12d
  jl     L44
  lea    0x1(%rbp),%rdi
  lea    -0x2(%rax),%esi
  call   <string_strndup@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L44
  mov    %rax,%rsi
  mov    %r13,%rdi
  test   %ebx,%ebx
  jne    L164
  call   <string_strcasestr@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  setne  %r12b
L17:
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L144
  nopw   0x0(%rax,%rax,1)
L125:
  lea    -0x1(%rax),%edx
  cmp    %r12d,%edx
  jg     L44
  mov    %rbp,%rsi
  mov    %r13,%rdi
  test   %ebx,%ebx
  jne    L25
  call   <string_strncasecmp@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  sete   %r12b
  jmp    L144
L25:
  call   <strncmp@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  sete   %r12b
  jmp    L144
L164:
  call   <strstr@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  setne  %r12b
  jmp    L17
```

tool_calls: name: read_data
arguments: data_label: D4
type_guessed: string

tool: D4: *

assistant: ```c
int string_match(const char *string, const char *mask, int case_sensitive) {
  char last, *mask2;
  int len_string, len_mask, rc;
  if (!mask || !mask[0])
    return 0;
  if (strcmp(mask, "*") == 0)
    return 1;
  len_string = strlen(string);
  len_mask = strlen(mask);
  last = mask[len_mask - 1];
  if ((mask[0] == '*') && (last != '*')) {
    if (len_string < len_mask - 1)
      return 0;
    if ((case_sensitive && (strcmp(string + len_string - (len_mask - 1), mask + 1) == 0)) || (!case_sensitive && (string_strcasecmp(string + len_string - (len_mask - 1), mask + 1) == 0)))
      return 1;
    return 0;
  }
  if ((mask[0] != '*') && (last == '*')) {
    if (len_string < len_mask - 1)
      return 0;
    if ((case_sensitive && (strncmp(string, mask, len_mask - 1) == 0)) || (!case_sensitive && (string_strncasecmp(string, mask, len_mask - 1) == 0)))
      return 1;
    return 0;
  }
  if ((mask[0] == '*') && (last == '*')) {
    if (len_string < len_mask - 1)
      return 0;
    mask2 = string_strndup(mask + 1, len_mask - 2);
    if (!mask2)
      return 0;
    rc = ((case_sensitive && strstr(string, mask2)) || (!case_sensitive && string_strcasestr(string, mask2))) ? 1 : 0;
    free(mask2);
    return rc;
  }
  if ((case_sensitive && (strcmp(string, mask) == 0)) || (!case_sensitive && (string_strcasecmp(string, mask) == 0)))
    return 1;
  return 0;
}
```