#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 InstructionSet();
int mkl_vml_service_cpu_detect(void) {
  int n = InstructionSet();
  if (n < 4)
    return 0;
  if (sizeof(void *) == 4) {
    switch (n) {
    case 4:
      n = 2;
      break;
    case 5:
      n = 3;
      break;
    case 6:
    case 7:
      n = 4;
      break;
    case 8:
    case 9:
      n = 5;
      break;
    case 10:
      n = 6;
      break;
    default:
      n = 6;
      break;
    }
  } else {
    switch (n) {
    case 4:
    case 5:
      n = 1;
      break;
    case 6:
    case 7:
      n = 2;
      break;
    case 8:
    case 9:
      n = 3;
      break;
    case 10:
      n = 4;
      break;
    default:
      n = 4;
      break;
    }
  }
  return n;
}


x86 assembly (clang, -O0):
<mkl_vml_service_cpu_detect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <InstructionSet@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1138 <mkl_vml_service_cpu_detect+0x28>
movl   $0x0,-0x4(%rbp)
jmp    119e <mkl_vml_service_cpu_detect+0x8e>
mov    -0x8(%rbp),%eax
add    $0xfffffffc,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     1191 <mkl_vml_service_cpu_detect+0x81>
mov    -0x10(%rbp),%rax
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x8(%rbp)
jmp    1198 <mkl_vml_service_cpu_detect+0x88>
movl   $0x2,-0x8(%rbp)
jmp    1198 <mkl_vml_service_cpu_detect+0x88>
movl   $0x3,-0x8(%rbp)
jmp    1198 <mkl_vml_service_cpu_detect+0x88>
movl   $0x4,-0x8(%rbp)
jmp    1198 <mkl_vml_service_cpu_detect+0x88>
movl   $0x4,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkl_vml_service_cpu_detect>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <InstructionSet@plt>
cmp    $0x4,%eax
jl     1138 <mkl_vml_service_cpu_detect+0x28>
add    $0xfffffffc,%eax
mov    $0x4,%ebx
cmp    $0x6,%eax
ja     1138 <mkl_vml_service_cpu_detect+0x28>
cltq
lea    0xecb(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @mkl_vml_service_cpu_detect() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @InstructionSet()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 4
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %16
7: ; preds = %0
%8 = load i32, i32* %2
switch i32 %8, label %13 [
i32 4, label %9
i32 5, label %9
i32 6, label %10
i32 7, label %10
i32 8, label %11
i32 9, label %11
i32 10, label %12
]
9: ; preds = %7, %7
store i32 1, i32* %2
br label %14
10: ; preds = %7, %7
store i32 2, i32* %2
br label %14
11: ; preds = %7, %7
store i32 3, i32* %2
br label %14
12: ; preds = %7
store i32 4, i32* %2
br label %14
13: ; preds = %7
store i32 4, i32* %2
br label %14
14: ; preds = %13, %12, %11, %10, %9
%15 = load i32, i32* %2
store i32 %15, i32* %1
br label %16
16: ; preds = %14, %6
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@switch.table.mkl_vml_service_cpu_detect = [7 x i32] [i32 1, i32 1, i32 2, i32 2, i32 3, i32 3, i32 4]
define i32 @mkl_vml_service_cpu_detect() {
%1 = tail call i32 (...) @InstructionSet()
%2 = icmp slt i32 %1, 4
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = add i32 %1, -4
%5 = icmp ult i32 %4, 7
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.mkl_vml_service_cpu_detect, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %3, %6, %0
%11 = phi i32 [ 0, %0 ], [ %9, %6 ], [ 4, %3 ]
ret i32 %11
}