#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*/ getCpuid(unsigned int *, int /*<<< orphan*/);
short back_get_system_uid(void) {
  unsigned int cpuinfo[4] = {0, 0, 0, 0};
  getCpuid(cpuinfo, 0);
  unsigned short hash = 0;
  unsigned int *ptr = &cpuinfo[0];
  for (unsigned int i = 0; i < 4; i++) {
    hash += (ptr[i] & 0xFFFF) + (ptr[i] >> 16);
  }
  return hash;
}


x86 assembly (clang, -O0):
<back_get_system_uid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <getCpuid@plt>
movw   $0x0,-0x12(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jae    1199 <back_get_system_uid+0x79>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,4),%ecx
and    $0xffff,%ecx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%edx
mov    (%rax,%rdx,4),%eax
shr    $0x10,%eax
add    %eax,%ecx
movzwl -0x12(%rbp),%eax
add    %ecx,%eax
mov    %ax,-0x12(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1158 <back_get_system_uid+0x38>
movswl -0x12(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<back_get_system_uid>:
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <getCpuid@plt>
movdqa (%rsp),%xmm0
movdqa %xmm0,%xmm1
psrld  $0x10,%xmm1
paddd  %xmm0,%xmm1
pshuflw $0xe8,%xmm1,%xmm0
pshufhw $0xe8,%xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm1
pshufd $0xaa,%xmm0,%xmm0
paddw  %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrld  $0x10,%xmm1
paddw  %xmm0,%xmm1
movd   %xmm1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define signext i16 @back_get_system_uid() {
%1 = alloca [4 x i32]
%2 = alloca i16
%3 = alloca i32*
%4 = alloca i32
%5 = bitcast [4 x i32]* %1 to i8*
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%7 = call i32 @getCpuid(i32* %6, i32 0)
store i16 0, i16* %2
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
store i32* %8, i32** %3
store i32 0, i32* %4
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %4
%11 = icmp ult i32 %10, 4
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = and i32 %17, 65535
%19 = load i32*, i32** %3
%20 = load i32, i32* %4
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = lshr i32 %23, 16
%25 = add i32 %18, %24
%26 = load i16, i16* %2
%27 = zext i16 %26 to i32
%28 = add i32 %27, %25
%29 = trunc i32 %28 to i16
store i16 %29, i16* %2
br label %30
30: ; preds = %12
%31 = load i32, i32* %4
%32 = add i32 %31, 1
store i32 %32, i32* %4
br label %9
33: ; preds = %9
%34 = load i16, i16* %2
ret i16 %34
}

LLVM IR (-O2):
define signext i16 @back_get_system_uid() {
%1 = alloca <4 x i32>
%2 = bitcast <4 x i32>* %1 to i8*
%3 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 0
%4 = call i32 @getCpuid(i32* %3, i32 0)
%5 = load <4 x i32>, <4 x i32>* %1
%6 = lshr <4 x i32> %5, <i32 16, i32 16, i32 16, i32 16>
%7 = add <4 x i32> %6, %5
%8 = trunc <4 x i32> %7 to <4 x i16>
%9 = call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> %8)
ret i16 %9
}