user: 请从给定的汇编指令推导出C源代码:

```asm
<check_ipmask>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  lea    D12(%rip),%rsi
  sub    $0x38,%rsp
  mov    %edi,0xc(%rsp)
  lea    0x24(%rsp),%r9
  lea    0x20(%rsp),%rbp
  mov    %rbx,%rdi
  lea    0x1c(%rsp),%r14
  lea    0x18(%rsp),%r13
  sub    $0x8,%rsp
  mov    %rbp,%r8
  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
  mov    %r9,0x10(%rsp)
  call   <sscanf@plt>
  pop    %rdx
  pop    %rcx
  cmp    $0x4,%eax
  mov    (%rsp),%r9
  jne    L67
  mov    0x10(%rsp),%edi
  test   %edi,%edi
  jne    L16
L67:
  xor    %eax,%eax
L97:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L91
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L16:
  mov    0x1c(%rsp),%ecx
  xor    %eax,%eax
  mov    0x18(%rsp),%al
  add    %rbx,%rdi
  movzbl 0x20(%rsp),%edx
  mov    %rbp,%r8
  lea    D14(%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     L33
  mov    0x10(%rsp),%eax
  lea    0x14(%rsp),%rdx
  lea    D0(%rip),%rsi
  lea    (%rbx,%rax,1),%rdi
  xor    %eax,%eax
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L67
  mov    0x14(%rsp),%edx
  movl   $0x0,0x10(%rsp)
  test   %edx,%edx
  je     L29
  xor    %eax,%eax
  xor    %ebx,%ebx
  nopl   (%rax)
L40:
  shr    %ebx
  add    $0x1,%eax
  or     $0x80000000,%ebx
  cmp    %edx,%eax
  jne    L40
  mov    %eax,0x10(%rsp)
  jmp    L43
  nopl   (%rax)
L33:
  xor    %r15d,%r15d
  mov    0x18(%rsp),%r15b
  mov    0x1c(%rsp),%ecx
  movzbl 0x20(%rsp),%edx
  mov    %r15d,%eax
  mov    %cl,%ah
  shl    $0x10,%edx
  movzwl %ax,%edi
  movzbl 0x24(%rsp),%eax
  or     %edx,%edi
  shl    $0x18,%eax
  or     %eax,%edi
  call   <ntohl@plt>
  mov    %eax,%ebx
L43:
  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    L97
L29:
  xor    %ebx,%ebx
  jmp    L43
L91:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D12
data_type: string
name: retrieve_data
arguments: data_tag: D14
data_type: string
name: retrieve_data
arguments: data_tag: D0
data_type: string

tool: D12: %d.%d.%d.%d/%n

tool: D14: %d.%d.%d.%d

tool: D0: %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));
}
```