#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int get_cputype(int);
int get_vendor();
int /*<<< orphan*/ have_cpuid();
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 15:
      if (model <= 0x2)
        return 6;
      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
        return 11;
    }
  }
  if (vendor == 6) {
    switch (family) {
    case 0x6:
      return 19;
      break;
    }
    return 12;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_coretype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    $0x0,%al
call   1050 <have_cpuid@plt>
cmp    $0x0,%eax
jne    1154 <get_coretype+0x24>
movl   $0x1,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
mov    $0x4,%edi
call   1030 <get_cputype@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%edi
call   1030 <get_cputype@plt>
mov    %eax,-0xc(%rbp)
mov    $0x5,%edi
call   1030 <get_cputype@plt>
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
call   1030 <get_cputype@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <get_vendor@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    12fd <get_coretype+0x1cd>
mov    -0x8(%rbp),%eax
add    $0xfffffffc,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xb,%eax
ja     12f8 <get_coretype+0x1c8>
mov    -0x20(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x2,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     1201 <get_coretype+0xd1>
jmp    11f0 <get_coretype+0xc0>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
je     1267 <get_coretype+0x137>
jmp    12d1 <get_coretype+0x1a1>
mov    -0x10(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0xf,%rax
ja     1262 <get_coretype+0x132>
mov    -0x30(%rbp),%rax
lea    0xe3b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x4,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x5,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x8,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0xe,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
jmp    12d1 <get_coretype+0x1a1>
mov    -0x10(%rbp),%eax
add    $0xfffffffa,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x9,%eax
ja     12cc <get_coretype+0x19c>
mov    -0x38(%rbp),%rax
lea    0xda9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xe,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0xf,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x11,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x12,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x10,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
jmp    12d1 <get_coretype+0x1a1>
jmp    12d6 <get_coretype+0x1a6>
cmpl   $0x2,-0x10(%rbp)
jg     12ec <get_coretype+0x1bc>
movl   $0x6,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x7,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
jmp    12fd <get_coretype+0x1cd>
cmpl   $0x3,-0x18(%rbp)
jne    136e <get_coretype+0x23e>
cmpl   $0x5,-0x8(%rbp)
jg     131d <get_coretype+0x1ed>
movl   $0x1,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
cmpl   $0xe,-0x8(%rbp)
jg     1333 <get_coretype+0x203>
movl   $0x9,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
cmpl   $0xf,-0x8(%rbp)
jne    1369 <get_coretype+0x239>
cmpl   $0x0,-0xc(%rbp)
je     1351 <get_coretype+0x221>
cmpl   $0x2,-0xc(%rbp)
jne    135d <get_coretype+0x22d>
movl   $0xa,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0xb,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
jmp    136e <get_coretype+0x23e>
cmpl   $0x6,-0x18(%rbp)
jne    13a1 <get_coretype+0x271>
mov    -0x8(%rbp),%eax
sub    $0x6,%eax
jne    1395 <get_coretype+0x265>
jmp    1389 <get_coretype+0x259>
movl   $0x13,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0xc,-0x4(%rbp)
jmp    13a8 <get_coretype+0x278>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_coretype>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <have_cpuid@plt>
test   %eax,%eax
je     11bf <get_coretype+0x8f>
mov    $0x4,%edi
call   1030 <get_cputype@plt>
mov    %eax,%r15d
mov    $0x1,%edi
call   1030 <get_cputype@plt>
mov    %eax,%r12d
mov    $0x5,%edi
call   1030 <get_cputype@plt>
mov    %eax,%r14d
mov    $0x2,%edi
call   1030 <get_cputype@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <get_vendor@plt>
cmp    $0x6,%eax
je     11fc <get_coretype+0xcc>
cmp    $0x3,%eax
je     11c9 <get_coretype+0x99>
cmp    $0x1,%eax
jne    1258 <get_coretype+0x128>
add    $0xfffffffc,%r15d
cmp    $0xb,%r15d
ja     1235 <get_coretype+0x105>
mov    $0x1,%ebx
lea    0xe54(%rip),%rax
movslq (%rax,%r15,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x2,%ebx
jmp    1258 <get_coretype+0x128>
mov    $0x1,%ebx
jmp    1258 <get_coretype+0x128>
mov    $0x1,%ebx
cmp    $0x6,%r15d
jl     1258 <get_coretype+0x128>
mov    $0x9,%ebx
cmp    $0xf,%r15d
jb     1258 <get_coretype+0x128>
mov    $0x0,%ebx
jne    1258 <get_coretype+0x128>
and    $0xfffffffd,%r12d
cmp    $0x1,%r12d
mov    $0xb,%ebx
sbb    $0x0,%ebx
jmp    1258 <get_coretype+0x128>
cmp    $0x6,%r15d
mov    $0x13,%eax
mov    $0xc,%ebx
cmove  %eax,%ebx
jmp    1258 <get_coretype+0x128>
cmp    $0x1,%ebp
je     1239 <get_coretype+0x109>
test   %ebp,%ebp
jne    124c <get_coretype+0x11c>
cmp    $0x10,%r14d
jae    124c <get_coretype+0x11c>
mov    $0xefff,%eax
bt     %r14d,%eax
jae    124c <get_coretype+0x11c>
movslq %r14d,%rax
lea    0xdfd(%rip),%rcx
jmp    126c <get_coretype+0x13c>
xor    %ebx,%ebx
jmp    1258 <get_coretype+0x128>
lea    -0x6(%r14),%eax
cmp    $0xa,%eax
jae    124c <get_coretype+0x11c>
mov    $0x3f3,%ecx
bt     %eax,%ecx
jb     1263 <get_coretype+0x133>
xor    %ebx,%ebx
cmp    $0x3,%r14d
setl   %bl
xor    $0x7,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cltq
lea    0xe04(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
jmp    1258 <get_coretype+0x128>

LLVM IR (-O0):
define i32 @get_coretype() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 (...) @have_cpuid()
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
store i32 1, i32* %1
br label %78
10: ; preds = %0
%11 = call i32 @get_cputype(i32 4)
store i32 %11, i32* %2
%12 = call i32 @get_cputype(i32 1)
store i32 %12, i32* %3
%13 = call i32 @get_cputype(i32 5)
store i32 %13, i32* %4
%14 = call i32 @get_cputype(i32 2)
store i32 %14, i32* %5
%15 = call i32 (...) @get_vendor()
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %47
18: ; preds = %10
%19 = load i32, i32* %2
switch i32 %19, label %46 [
i32 4, label %20
i32 5, label %21
i32 6, label %22
i32 15, label %41
]
20: ; preds = %18
store i32 1, i32* %1
br label %78
21: ; preds = %18
store i32 2, i32* %1
br label %78
22: ; preds = %18
%23 = load i32, i32* %5
switch i32 %23, label %40 [
i32 0, label %24
i32 1, label %32
]
24: ; preds = %22
%25 = load i32, i32* %4
switch i32 %25, label %31 [
i32 0, label %26
i32 1, label %26
i32 2, label %26
i32 3, label %26
i32 4, label %26
i32 5, label %26
i32 6, label %26
i32 7, label %27
i32 8, label %28
i32 10, label %28
i32 11, label %28
i32 9, label %29
i32 13, label %29
i32 14, label %29
i32 15, label %30
]
26: ; preds = %24, %24, %24, %24, %24, %24, %24
store i32 3, i32* %1
br label %78
27: ; preds = %24
store i32 4, i32* %1
br label %78
28: ; preds = %24, %24, %24
store i32 5, i32* %1
br label %78
29: ; preds = %24, %24, %24
store i32 8, i32* %1
br label %78
30: ; preds = %24
store i32 14, i32* %1
br label %78
31: ; preds = %24
br label %40
32: ; preds = %22
%33 = load i32, i32* %4
switch i32 %33, label %39 [
i32 6, label %34
i32 7, label %35
i32 10, label %36
i32 11, label %36
i32 14, label %36
i32 15, label %36
i32 12, label %37
i32 13, label %38
]
34: ; preds = %32
store i32 14, i32* %1
br label %78
35: ; preds = %32
store i32 15, i32* %1
br label %78
36: ; preds = %32, %32, %32, %32
store i32 17, i32* %1
br label %78
37: ; preds = %32
store i32 18, i32* %1
br label %78
38: ; preds = %32
store i32 16, i32* %1
br label %78
39: ; preds = %32
br label %40
40: ; preds = %39, %22, %31
br label %41
41: ; preds = %18, %40
%42 = load i32, i32* %4
%43 = icmp sle i32 %42, 2
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 6, i32* %1
br label %78
45: ; preds = %41
store i32 7, i32* %1
br label %78
46: ; preds = %18
br label %47
47: ; preds = %46, %10
%48 = load i32, i32* %6
%49 = icmp eq i32 %48, 3
br i1 %49, label %50, label %70
50: ; preds = %47
%51 = load i32, i32* %2
%52 = icmp sle i32 %51, 5
br i1 %52, label %53, label %54
53: ; preds = %50
store i32 1, i32* %1
br label %78
54: ; preds = %50
%55 = load i32, i32* %2
%56 = icmp sle i32 %55, 14
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 9, i32* %1
br label %78
58: ; preds = %54
%59 = load i32, i32* %2
%60 = icmp eq i32 %59, 15
br i1 %60, label %61, label %69
61: ; preds = %58
%62 = load i32, i32* %3
%63 = icmp eq i32 %62, 0
br i1 %63, label %67, label %64
64: ; preds = %61
%65 = load i32, i32* %3
%66 = icmp eq i32 %65, 2
br i1 %66, label %67, label %68
67: ; preds = %64, %61
store i32 10, i32* %1
br label %78
68: ; preds = %64
store i32 11, i32* %1
br label %78
69: ; preds = %58
br label %70
70: ; preds = %69, %47
%71 = load i32, i32* %6
%72 = icmp eq i32 %71, 6
br i1 %72, label %73, label %77
73: ; preds = %70
%74 = load i32, i32* %2
switch i32 %74, label %76 [
i32 6, label %75
]
75: ; preds = %73
store i32 19, i32* %1
br label %78
76: ; preds = %73
store i32 12, i32* %1
br label %78
77: ; preds = %70
store i32 0, i32* %1
br label %78
78: ; preds = %77, %76, %75, %68, %67, %57, %53, %45, %44, %38, %37, %36, %35, %34, %30, %29, %28, %27, %26, %21, %20, %9
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@switch.table.get_coretype = [16 x i32] [i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 4, i32 5, i32 8, i32 5, i32 5, i32 3, i32 8, i32 8, i32 14]
@switch.table.get_coretype.1 = [10 x i32] [i32 14, i32 15, i32 14, i32 14, i32 17, i32 17, i32 18, i32 16, i32 17, i32 17]
define i32 @get_coretype() {
%1 = tail call i32 (...) @have_cpuid()
%2 = icmp eq i32 %1, 0
br i1 %2, label %52, label %3
3: ; preds = %0
%4 = tail call i32 @get_cputype(i32 4)
%5 = tail call i32 @get_cputype(i32 1)
%6 = tail call i32 @get_cputype(i32 5)
%7 = tail call i32 @get_cputype(i32 2)
%8 = tail call i32 (...) @get_vendor()
switch i32 %8, label %52 [
i32 1, label %9
i32 3, label %21
i32 6, label %31
]
9: ; preds = %3
switch i32 %4, label %20 [
i32 4, label %52
i32 5, label %10
i32 6, label %11
i32 15, label %17
]
10: ; preds = %9
br label %52
11: ; preds = %9
switch i32 %7, label %17 [
i32 0, label %12
i32 1, label %14
]
12: ; preds = %11
%13 = icmp ult i32 %6, 16
br i1 %13, label %34, label %17
14: ; preds = %11
%15 = add i32 %6, -6
%16 = icmp ult i32 %15, 10
br i1 %16, label %43, label %17
17: ; preds = %43, %14, %34, %12, %11, %9
%18 = icmp slt i32 %6, 3
%19 = select i1 %18, i32 6, i32 7
br label %52
20: ; preds = %9
br label %52
21: ; preds = %3
%22 = icmp slt i32 %4, 6
br i1 %22, label %52, label %23
23: ; preds = %21
%24 = icmp ult i32 %4, 15
br i1 %24, label %52, label %25
25: ; preds = %23
%26 = icmp eq i32 %4, 15
br i1 %26, label %27, label %52
27: ; preds = %25
%28 = and i32 %5, -3
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i32 10, i32 11
br label %52
31: ; preds = %3
%32 = icmp eq i32 %4, 6
%33 = select i1 %32, i32 19, i32 12
br label %52
34: ; preds = %12
%35 = trunc i32 %6 to i16
%36 = lshr i16 -4097, %35
%37 = and i16 %36, 1
%38 = icmp eq i16 %37, 0
br i1 %38, label %17, label %39
39: ; preds = %34
%40 = sext i32 %6 to i64
%41 = getelementptr inbounds [16 x i32], [16 x i32]* @switch.table.get_coretype, i64 0, i64 %40
%42 = load i32, i32* %41
br label %52
43: ; preds = %14
%44 = trunc i32 %15 to i16
%45 = lshr i16 1011, %44
%46 = and i16 %45, 1
%47 = icmp eq i16 %46, 0
br i1 %47, label %17, label %48
48: ; preds = %43
%49 = sext i32 %15 to i64
%50 = getelementptr inbounds [10 x i32], [10 x i32]* @switch.table.get_coretype.1, i64 0, i64 %49
%51 = load i32, i32* %50
br label %52
52: ; preds = %48, %39, %25, %20, %3, %31, %27, %23, %21, %17, %9, %0, %10
%53 = phi i32 [ 2, %10 ], [ 1, %0 ], [ 1, %9 ], [ %19, %17 ], [ 1, %21 ], [ 9, %23 ], [ %30, %27 ], [ %33, %31 ], [ 0, %3 ], [ 0, %20 ], [ 0, %25 ], [ %42, %39 ], [ %51, %48 ]
ret i32 %53
}