#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 /*<<< orphan*/ arch_cpuid_1(int);
int /*<<< orphan*/ cpuid_vendor(char *);
void workaround_nehalem_aaj79(unsigned *ebx) {
  union {
    unsigned eax;
    struct {
      unsigned stepping : 4;
      unsigned model : 4;
      unsigned family : 4;
      unsigned type : 2;
      unsigned res : 2;
      unsigned ext_model : 4;
      unsigned ext_family : 8;
      unsigned res2 : 4;
    };
  } v;
  unsigned model;
  if (!cpuid_vendor("GenuineIntel"))
    return;
  arch_cpuid_1(1);
  model = (v.ext_model << 4) + v.model;
  if (v.family != 6 || model != 26 || v.stepping > 4)
    return;
  *ebx |= (1 << 2);
}


x86 assembly (clang, -O0):
<workaround_nehalem_aaj79>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <cpuid_vendor@plt>
cmp    $0x0,%eax
jne    1146 <workaround_nehalem_aaj79+0x26>
jmp    11a5 <workaround_nehalem_aaj79+0x85>
mov    $0x1,%edi
call   1040 <arch_cpuid_1@plt>
mov    -0x10(%rbp),%eax
shr    $0x10,%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    -0x10(%rbp),%ecx
shr    $0x4,%ecx
and    $0xf,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
shr    $0x8,%eax
and    $0xf,%eax
cmp    $0x6,%eax
jne    1195 <workaround_nehalem_aaj79+0x75>
cmpl   $0x1a,-0x14(%rbp)
jne    1195 <workaround_nehalem_aaj79+0x75>
mov    -0x10(%rbp),%eax
and    $0xf,%eax
cmp    $0x4,%eax
jle    119a <workaround_nehalem_aaj79+0x7a>
jmp    11a5 <workaround_nehalem_aaj79+0x85>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
or     $0x4,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<workaround_nehalem_aaj79>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <cpuid_vendor@plt>
test   %eax,%eax
je     113c <workaround_nehalem_aaj79+0x1c>
mov    $0x1,%edi
pop    %rax
jmp    1040 <arch_cpuid_1@plt>
pop    %rax
ret

LLVM IR (-O0):
%union.anon = type { i32 }
%struct.anon = type { i32 }
@.str = [13 x i8] c"GenuineIntel\00"
define void @workaround_nehalem_aaj79(i32* %0) {
%2 = alloca i32*
%3 = alloca %union.anon
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 @cpuid_vendor(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
br label %42
8: ; preds = %1
%9 = call i32 @arch_cpuid_1(i32 1)
%10 = bitcast %union.anon* %3 to %struct.anon*
%11 = bitcast %struct.anon* %10 to i32*
%12 = load i32, i32* %11
%13 = lshr i32 %12, 16
%14 = and i32 %13, 15
%15 = shl i32 %14, 4
%16 = bitcast %union.anon* %3 to %struct.anon*
%17 = bitcast %struct.anon* %16 to i32*
%18 = load i32, i32* %17
%19 = lshr i32 %18, 4
%20 = and i32 %19, 15
%21 = add nsw i32 %15, %20
store i32 %21, i32* %4
%22 = bitcast %union.anon* %3 to %struct.anon*
%23 = bitcast %struct.anon* %22 to i32*
%24 = load i32, i32* %23
%25 = lshr i32 %24, 8
%26 = and i32 %25, 15
%27 = icmp ne i32 %26, 6
br i1 %27, label %37, label %28
28: ; preds = %8
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 26
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = bitcast %union.anon* %3 to %struct.anon*
%33 = bitcast %struct.anon* %32 to i32*
%34 = load i32, i32* %33
%35 = and i32 %34, 15
%36 = icmp sgt i32 %35, 4
br i1 %36, label %37, label %38
37: ; preds = %31, %28, %8
br label %42
38: ; preds = %31
%39 = load i32*, i32** %2
%40 = load i32, i32* %39
%41 = or i32 %40, 4
store i32 %41, i32* %39
br label %42
42: ; preds = %38, %37, %7
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"GenuineIntel\00"
define void @workaround_nehalem_aaj79(i32* nocapture readnone %0) {
%2 = tail call i32 @cpuid_vendor(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @arch_cpuid_1(i32 1)
br label %6
6: ; preds = %1, %4
ret void
}