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

```asm
<get_coretype>:
  endbr64
  push   %r13
  xor    %eax,%eax
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <have_cpuid@plt>
  test   %eax,%eax
  jne    L308
L397:
  mov    $0x1,%eax
L326:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L308:
  mov    $0x4,%edi
  call   <get_cputype@plt>
  mov    $0x1,%edi
  mov    %eax,%ebx
  call   <get_cputype@plt>
  mov    $0x5,%edi
  mov    %eax,%r12d
  call   <get_cputype@plt>
  mov    $0x2,%edi
  mov    %eax,%ebp
  call   <get_cputype@plt>
  mov    %eax,%r13d
  xor    %eax,%eax
  call   <get_vendor@plt>
  cmp    $0x1,%eax
  je     L20
  cmp    $0x3,%eax
  je     L249
  cmp    $0x6,%eax
  jne    L362
  cmp    $0x6,%ebx
  mov    $0x13,%eax
  mov    $0xc,%edx
  cmovne %edx,%eax
  jmp    L326
  cmp    $0x5,%ebp
  je     L367
L362:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L20:
  cmp    $0x6,%ebx
  je     L412
  jg     L21
  cmp    $0x4,%ebx
  je     L326
  xor    %eax,%eax
  cmp    $0x5,%ebx
  sete   %al
  add    $0x8,%rsp
  pop    %rbx
  add    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L21:
  cmp    $0xf,%ebx
  jne    L362
  xor    %eax,%eax
  cmp    $0x2,%ebp
  setg   %al
  add    $0x6,%eax
  jmp    L326
  nopl   (%rax)
L249:
  cmp    $0x5,%ebx
  jle    L397
  mov    $0x9,%eax
  cmp    $0xe,%ebx
  jle    L326
  xor    %eax,%eax
  cmp    $0xf,%ebx
  jne    L326
  mov    $0xa,%eax
  test   $0xfffffffd,%r12d
  je     L326
  cmp    $0x5,%r12d
  je     L154
  mov    $0xb,%eax
  cmp    $0x6,%r12d
  jne    L326
  cmp    $0x1,%ebp
  je     L319
  cmp    $0x2,%ebp
  jne    L362
  xor    %eax,%eax
  call   <support_avx@plt>
  mov    %eax,%r8d
  mov    $0x17,%eax
  test   %r8d,%r8d
  jne    L326
L346:
  mov    $0xb,%eax
  jmp    L326
  nopl   0x0(%rax)
L412:
  cmp    $0x4,%r13d
  ja     L362
  lea    D8(%rip),%rdx
  mov    %r13d,%eax
  movslq (%rdx,%rax,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  sub    $0xa,%ebp
  and    $0xfffffffd,%ebp
  jne    L362
L367:
  xor    %eax,%eax
  call   <support_avx@plt>
  cmp    $0x1,%eax
  sbb    %eax,%eax
  and    $0xfffffffd,%eax
  add    $0x14,%eax
  jmp    L326
  cmp    $0xf,%ebp
  ja     L362
  mov    $0x1,%edx
  mov    %ebp,%ecx
  mov    $0x11,%eax
  shl    %cl,%rdx
  test   $0xd020,%edx
  jne    L326
  xor    %eax,%eax
  and    $0x24,%dh
  je     L326
  jmp    L367
  sub    $0x6,%ebp
  cmp    $0x9,%ebp
  ja     L362
  lea    D1(%rip),%rdx
  movslq (%rdx,%rbp,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  cmp    $0xf,%ebp
  ja     L362
  lea    D22(%rip),%rdx
  movslq (%rdx,%rbp,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  mov    $0x3,%eax
  jmp    L326
  mov    $0x11,%eax
  jmp    L326
  mov    $0x8,%eax
  jmp    L326
  mov    $0x5,%eax
  jmp    L326
  mov    $0xe,%eax
  jmp    L326
  mov    $0x10,%eax
  jmp    L326
  mov    $0x12,%eax
  jmp    L326
  mov    $0xf,%eax
  jmp    L326
  mov    $0x4,%eax
  jmp    L326
L319:
  xor    %eax,%eax
  call   <support_avx@plt>
  mov    %eax,%r8d
  mov    $0x16,%eax
  test   %r8d,%r8d
  jne    L326
  jmp    L346
L154:
  mov    $0x15,%eax
  jmp    L326
```

assistant: ```c
int get_coretype(void) {
  int family, exfamily, model, exmodel, vendor;
  if (!have_cpuid())
    return 1;
  family = get_cputype(4);
  exfamily = get_cputype(1);
  model = get_cputype(5);
  exmodel = get_cputype(2);
  vendor = get_vendor();
  if (vendor == 1) {
    switch (family) {
    case 4:
      return 1;
    case 5:
      return 2;
    case 6:
      switch (exmodel) {
      case 0:
        switch (model) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
          return 3;
        case 7:
          return 4;
        case 8:
        case 10:
        case 11:
          return 5;
        case 9:
        case 13:
        case 14:
          return 8;
        case 15:
          return 14;
        }
        break;
      case 1:
        switch (model) {
        case 6:
          return 14;
        case 7:
          return 15;
        case 10:
        case 11:
        case 14:
        case 15:
          return 17;
        case 12:
          return 18;
        case 13:
          return 16;
        }
        break;
      case 2:
        switch (model) {
        case 5:
          return 17;
        case 10:
          if (support_avx())
            return 20;
          else
            return 17;
        case 12:
          return 17;
        case 13:
          if (support_avx())
            return 20;
          else
            return 17;
        case 14:
        case 15:
          return 17;
        }
        break;
      case 3:
        switch (model) {
        case 10:
          if (support_avx())
            return 20;
          else
            return 17;
        case 12:
          if (support_avx())
            return 20;
          else
            return 17;
        }
        break;
      case 4:
        switch (model) {
        case 5:
          if (support_avx())
            return 20;
          else
            return 17;
        }
        break;
      }
      break;
    case 15:
      if (model <= 0x2)
        return 6;
      else
        return 7;
    }
  }
  if (vendor == 3) {
    if (family <= 0x5)
      return 1;
    if (family <= 0xe)
      return 9;
    if (family == 0xf) {
      if ((exfamily == 0) || (exfamily == 2))
        return 10;
      else if (exfamily == 5)
        return 21;
      else if (exfamily == 6) {
        switch (model) {
        case 1:
          if (support_avx())
            return 22;
          else
            return 11;
        case 2:
          if (support_avx())
            return 23;
          else
            return 11;
        }
      } else
        return 11;
    }
  }
  if (vendor == 6) {
    switch (family) {
    case 0x6:
      return 19;
      break;
    }
    return 12;
  }
  return 0;
}
```