#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 */
unsigned int rapl_get_cpu_id();
char rapl_available() {
  unsigned int eax;
  eax = rapl_get_cpu_id();
  int model = (((eax >> 16) & 0xF) << 4) + ((eax >> 4) & 0xF);
  int family = ((eax >> 8) & 0xF);
  if (family == 6) {
    switch (model) {
    case 0x2a:
    case 0x2d:
    case 0x3a:
    case 0x3e:
      return 1;
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<rapl_available>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <rapl_get_cpu_id@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x10,%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    -0x8(%rbp),%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jne    11a7 <rapl_available+0x97>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x2a,%eax
je     1199 <rapl_available+0x89>
jmp    1166 <rapl_available+0x56>
mov    -0x14(%rbp),%eax
sub    $0x2d,%eax
je     1199 <rapl_available+0x89>
jmp    1177 <rapl_available+0x67>
mov    -0x14(%rbp),%eax
sub    $0x3a,%eax
je     1199 <rapl_available+0x89>
jmp    1188 <rapl_available+0x78>
mov    -0x14(%rbp),%eax
sub    $0x3e,%eax
jne    11a2 <rapl_available+0x92>
jmp    1199 <rapl_available+0x89>
movb   $0x1,-0x1(%rbp)
jmp    11ab <rapl_available+0x9b>
jmp    11a7 <rapl_available+0x97>
movb   $0x0,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rapl_available>:
push   %rax
xor    %eax,%eax
call   1030 <rapl_get_cpu_id@plt>
mov    %eax,%ecx
and    $0xf00,%ecx
cmp    $0x600,%ecx
jne    1151 <rapl_available+0x41>
mov    %eax,%ecx
shr    $0xc,%ecx
and    $0xf0,%ecx
shr    $0x4,%eax
and    $0xf,%eax
or     %ecx,%eax
cmp    $0x3e,%al
ja     1151 <rapl_available+0x41>
mov    $0x1,%cl
movabs $0x4400240000000000,%rdx
bt     %rax,%rdx
jb     1153 <rapl_available+0x43>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define signext i8 @rapl_available() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @rapl_get_cpu_id()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = lshr i32 %6, 16
%8 = and i32 %7, 15
%9 = shl i32 %8, 4
%10 = load i32, i32* %2
%11 = lshr i32 %10, 4
%12 = and i32 %11, 15
%13 = add i32 %9, %12
store i32 %13, i32* %3
%14 = load i32, i32* %2
%15 = lshr i32 %14, 8
%16 = and i32 %15, 15
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 6
br i1 %18, label %19, label %23
19: ; preds = %0
%20 = load i32, i32* %3
switch i32 %20, label %22 [
i32 42, label %21
i32 45, label %21
i32 58, label %21
i32 62, label %21
]
21: ; preds = %19, %19, %19, %19
store i8 1, i8* %1
br label %24
22: ; preds = %19
br label %23
23: ; preds = %22, %0
store i8 0, i8* %1
br label %24
24: ; preds = %23, %21
%25 = load i8, i8* %1
ret i8 %25
}

LLVM IR (-O2):
define signext i8 @rapl_available() {
%1 = tail call i32 (...) @rapl_get_cpu_id()
%2 = and i32 %1, 3840
%3 = icmp eq i32 %2, 1536
br i1 %3, label %4, label %11
4: ; preds = %0
%5 = lshr i32 %1, 12
%6 = and i32 %5, 240
%7 = lshr i32 %1, 4
%8 = and i32 %7, 15
%9 = or i32 %6, %8
%10 = trunc i32 %9 to i8
switch i8 %10, label %11 [
i8 42, label %12
i8 45, label %12
i8 58, label %12
i8 62, label %12
]
11: ; preds = %4, %0
br label %12
12: ; preds = %4, %4, %4, %4, %11
%13 = phi i8 [ 0, %11 ], [ 1, %4 ], [ 1, %4 ], [ 1, %4 ], [ 1, %4 ]
ret i8 %13
}