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

```asm
<process_pattern_4_hex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %rcx,-0x30(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <validate_hex_pattern@plt>
  test   %rax,%rax
  jns    L95
  mov    $0xffffffff,%eax
  jmp    L17
L95:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  mov    $0x2,%edx
  lea    D7(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L34
  mov    -0x18(%rbp),%rax
  mov    $0x2,%edx
  lea    D1(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L66
L34:
  mov    -0x18(%rbp),%rax
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %eax,-0x4(%rbp)
  subl   $0x2,-0x8(%rbp)
  jmp    L60
L66:
  mov    -0x18(%rbp),%rax
  mov    $0x10,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <strtol@plt>
  mov    %eax,-0x4(%rbp)
L60:
  cmpl   $0x2,-0x8(%rbp)
  jg     L33
  cmpl   $0x0,-0x8(%rbp)
  jg     L104
  jmp    L40
L33:
  mov    -0x8(%rbp),%eax
  sub    $0x3,%eax
  cmp    $0x1,%eax
  ja     L40
  jmp    L110
L104:
  mov    -0x20(%rbp),%rax
  movl   $0x1,(%rax)
  mov    -0x4(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L44
L110:
  mov    -0x20(%rbp),%rax
  movl   $0x2,(%rax)
  mov    -0x4(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  shr    $0x8,%eax
  movzbl %al,%edx
  mov    -0x4(%rbp),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  or     %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L44
L40:
  mov    -0x20(%rbp),%rax
  movl   $0x4,(%rax)
  mov    -0x4(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  shr    $0x8,%eax
  and    $0xff00,%eax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  shr    $0x18,%eax
  or     %eax,%edx
  mov    -0x4(%rbp),%eax
  shl    $0x8,%eax
  and    $0xff0000,%eax
  or     %eax,%edx
  mov    -0x4(%rbp),%eax
  shl    $0x18,%eax
  or     %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,(%rax)
  nop
L44:
  mov    -0x8(%rbp),%edx
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x8(%rbp),%eax
L17:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D7
type: string
name: unpack_data
arguments: tag: D1
type: string
name: unpack_data
arguments: tag: D13
type: string

tool: D7: 0x

tool: D1: 0X

tool: D13:  Hex pattern: '0x%x' width '%d'


assistant: ```c
int process_pattern_4_hex(char *pattern, int *ilen, unsigned int *pat_le, unsigned int *pat_be) {
  int len;
  int pat;
  if (validate_hex_pattern(pattern) < 0)
    return -1;
  len = (int)strlen(pattern);
  if ((strncmp(pattern, "0x", 2) == 0) || (strncmp(pattern, "0X", 2) == 0)) {
    pat = (int)strtol(pattern, NULL, 0);
    len -= 2;
  } else {
    pat = (int)strtol(pattern, NULL, 16);
  }
  switch (len) {
  case 1:
  case 2:
    *ilen = 1;
    *pat_le = (unsigned int)pat;
    *pat_be = (unsigned int)pat;
    break;
  case 3:
  case 4:
    *ilen = 2;
    *pat_le = (unsigned int)pat;
    *pat_be = (((((unsigned int)pat) & 0xFF00) >> 8) | ((((unsigned int)pat) & 0x00FF) << 8));
    break;
  default:
    *ilen = 4;
    *pat_le = (unsigned int)pat;
    *pat_be = (((((unsigned int)pat) & 0x00FF0000) >> 8) | ((((unsigned int)pat) & 0xFF000000) >> 24) | ((((unsigned int)pat) & 0x0000FF00) << 8) | ((((unsigned int)pat) & 0x000000FF) << 24));
    break;
  }
  printf(" Hex pattern: \'0x%x\' width \'%d\'\n", pat, len);
  return len;
}
```