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

```asm
<check_ipmask>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  lea    D11(%rip),%rsi
  sub    $0x38,%rsp
  mov    %edi,0xc(%rsp)
  lea    0x24(%rsp),%rbp
  lea    0x20(%rsp),%r15
  mov    %rbx,%rdi
  lea    0x1c(%rsp),%r14
  lea    0x18(%rsp),%r13
  mov    %rbp,%r9
  mov    %r15,%r8
  sub    $0x8,%rsp
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x30(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x18(%rsp)
  lea    0x18(%rsp),%rax
  push   %rax
  xor    %eax,%eax
  call   <sscanf@plt>
  pop    %rdx
  pop    %rcx
  cmp    $0x4,%eax
  jne    L75
  mov    0x10(%rsp),%edi
  test   %edi,%edi
  jne    L7
L75:
  xor    %eax,%eax
L12:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L14
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  mov    0x1c(%rsp),%ecx
  xor    %eax,%eax
  mov    0x18(%rsp),%al
  add    %rbx,%rdi
  movzbl 0x20(%rsp),%edx
  mov    %rbp,%r9
  mov    %r15,%r8
  lea    D3(%rip),%rsi
  mov    %cl,%ah
  mov    %r14,%rcx
  movzwl %ax,%r12d
  movzbl 0x24(%rsp),%eax
  shl    $0x10,%edx
  or     %edx,%r12d
  mov    %r13,%rdx
  shl    $0x18,%eax
  or     %eax,%r12d
  xor    %eax,%eax
  call   <sscanf@plt>
  cmp    $0x4,%eax
  je     L56
  mov    0x10(%rsp),%eax
  lea    0x14(%rsp),%rdx
  lea    D28(%rip),%rsi
  lea    (%rbx,%rax,1),%rdi
  xor    %eax,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L75
  mov    0x14(%rsp),%edx
  movl   $0x0,0x10(%rsp)
  test   %edx,%edx
  je     L48
  xor    %eax,%eax
  xor    %ebx,%ebx
L84:
  shr    %ebx
  add    $0x1,%eax
  or     $0x80000000,%ebx
  cmp    %edx,%eax
  jne    L84
  mov    %eax,0x10(%rsp)
  jmp    L40
  nopl   (%rax)
L56:
  mov    0x1c(%rsp),%ecx
  xor    %eax,%eax
  mov    0x18(%rsp),%al
  movzbl 0x20(%rsp),%edx
  mov    %cl,%ah
  movzwl %ax,%edi
  movzbl 0x24(%rsp),%eax
  shl    $0x10,%edx
  or     %edx,%edi
  shl    $0x18,%eax
  or     %eax,%edi
  call   <ntohl@plt>
  mov    %eax,%ebx
L40:
  mov    0xc(%rsp),%edi
  call   <ntohl@plt>
  mov    %r12d,%edi
  mov    %eax,%ebp
  call   <ntohl@plt>
  xor    %eax,%ebp
  xor    %eax,%eax
  test   %ebx,%ebp
  sete   %al
  jmp    L12
L48:
  xor    %ebx,%ebx
  jmp    L40
L14:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D11
data_type: string
name: unpack_data
arguments: data_label: D3
data_type: string
name: unpack_data
arguments: data_label: D28
data_type: string

tool: D11: %d.%d.%d.%d/%n

tool: D3: %d.%d.%d.%d

tool: D28: %d

assistant: ```c
int check_ipmask(unsigned int ip, const unsigned char *str) {
  unsigned int mask = 0, i = 0, m, ip2, a0, a1, a2, a3;
  unsigned char *p = (unsigned char *)&ip2, *p2 = (unsigned char *)&mask;
  if (sscanf(str, "%d.%d.%d.%d/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0)
    return 0;
  p[0] = a0;
  p[1] = a1;
  p[2] = a2;
  p[3] = a3;
  if (sscanf(str + i, "%d.%d.%d.%d", &a0, &a1, &a2, &a3) == 4) {
    p2[0] = a0;
    p2[1] = a1;
    p2[2] = a2;
    p2[3] = a3;
    mask = ntohl(mask);
  } else if (sscanf(str + i, "%d", &m) == 1) {
    for (i = 0; i < m; i++)
      mask = (mask >> 1) | 0x80000000;
  } else
    return 0;
  return ((ntohl(ip) & mask) == (ntohl(ip2) & mask));
}
```