#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef short int8_t;

/* Variables and functions */
short *malloc(int);
short *create_random_shorts() {
  uint8_t *secret_page = (uint8_t *)0x4347c000;
  short *prand_shorts = malloc(1024 * sizeof(short));
  if (!prand_shorts)
    return NULL;
  for (unsigned int i = 0; i < 1024; i++)
    prand_shorts[i] = *(int8_t *)&secret_page[i * 3];
  return prand_shorts;
}


x86 assembly (clang, -O0):
<create_random_shorts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x4347c000,%eax
mov    %rax,-0x10(%rbp)
mov    $0x800,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1147 <create_random_shorts+0x37>
movq   $0x0,-0x8(%rbp)
jmp    118a <create_random_shorts+0x7a>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x400,-0x1c(%rbp)
jae    1182 <create_random_shorts+0x72>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x1c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%dx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %dx,(%rax,%rcx,2)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <create_random_shorts+0x3e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_random_shorts>:
push   %rax
mov    $0x800,%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1377 <create_random_shorts+0x267>
mov    $0x4347c000,%ecx
mov    $0x18,%edx
movdqa 0xeca(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
movdqa 0x20(%rcx),%xmm1
movdqa 0x40(%rcx),%xmm2
movdqa 0x50(%rcx),%xmm3
psrlq  $0x10,%xmm1
pshufd $0xec,0x30(%rcx),%xmm4
pshuflw $0x84,%xmm4,%xmm4
pslld  $0x10,%xmm3
psrldq $0x2,%xmm2
punpcklwd %xmm3,%xmm2
shufps $0xd7,%xmm4,%xmm2
punpckldq %xmm1,%xmm4
movdqa %xmm0,%xmm1
pandn  %xmm4,%xmm1
pshufd $0xc4,(%rcx),%xmm3
pshufhw $0xe8,%xmm3,%xmm3
punpckhdq 0x10(%rcx),%xmm3
pand   %xmm0,%xmm3
por    %xmm1,%xmm3
shufps $0x24,%xmm2,%xmm3
movups %xmm3,-0x30(%rax,%rdx,2)
movdqa 0x80(%rcx),%xmm1
movdqa 0xa0(%rcx),%xmm2
movdqa 0xb0(%rcx),%xmm3
pshufd $0xec,0x90(%rcx),%xmm4
psrlq  $0x10,%xmm1
pshuflw $0x84,%xmm4,%xmm4
pslld  $0x10,%xmm3
psrldq $0x2,%xmm2
punpcklwd %xmm3,%xmm2
shufps $0xd7,%xmm4,%xmm2
pshufd $0xc4,0x60(%rcx),%xmm3
punpckldq %xmm1,%xmm4
movdqa %xmm0,%xmm1
pshufhw $0xe8,%xmm3,%xmm3
punpckhdq 0x70(%rcx),%xmm3
pandn  %xmm4,%xmm1
pand   %xmm0,%xmm3
por    %xmm1,%xmm3
shufps $0x24,%xmm2,%xmm3
movups %xmm3,-0x20(%rax,%rdx,2)
movdqa 0xe0(%rcx),%xmm1
movdqa 0x100(%rcx),%xmm2
movdqa 0x110(%rcx),%xmm3
psrlq  $0x10,%xmm1
pshufd $0xec,0xf0(%rcx),%xmm4
pshuflw $0x84,%xmm4,%xmm4
pslld  $0x10,%xmm3
psrldq $0x2,%xmm2
punpcklwd %xmm3,%xmm2
shufps $0xd7,%xmm4,%xmm2
punpckldq %xmm1,%xmm4
movdqa %xmm0,%xmm1
pandn  %xmm4,%xmm1
pshufd $0xc4,0xc0(%rcx),%xmm3
pshufhw $0xe8,%xmm3,%xmm3
punpckhdq 0xd0(%rcx),%xmm3
pand   %xmm0,%xmm3
por    %xmm1,%xmm3
shufps $0x24,%xmm2,%xmm3
movups %xmm3,-0x10(%rax,%rdx,2)
cmp    $0x3f8,%rdx
je     12ff <create_random_shorts+0x1ef>
movdqa 0x140(%rcx),%xmm1
movdqa 0x160(%rcx),%xmm2
movdqa 0x170(%rcx),%xmm3
psrlq  $0x10,%xmm1
pshufd $0xec,0x150(%rcx),%xmm4
pshuflw $0x84,%xmm4,%xmm4
pslld  $0x10,%xmm3
psrldq $0x2,%xmm2
punpcklwd %xmm3,%xmm2
shufps $0xd7,%xmm4,%xmm2
punpckldq %xmm1,%xmm4
movdqa %xmm0,%xmm1
pandn  %xmm4,%xmm1
pshufd $0xc4,0x120(%rcx),%xmm3
pshufhw $0xe8,%xmm3,%xmm3
punpckhdq 0x130(%rcx),%xmm3
pand   %xmm0,%xmm3
por    %xmm1,%xmm3
shufps $0x24,%xmm2,%xmm3
movups %xmm3,(%rax,%rdx,2)
add    $0x180,%rcx
add    $0x20,%rdx
jmp    1140 <create_random_shorts+0x30>
movzwl 0x4347efa0,%ecx
43
mov    %cx,0x7f0(%rax)
movzwl 0x4347efac,%ecx
43
mov    %cx,0x7f2(%rax)
movzwl 0x4347efb8,%ecx
43
mov    %cx,0x7f4(%rax)
movzwl 0x4347efc4,%ecx
43
mov    %cx,0x7f6(%rax)
movzwl 0x4347efd0,%ecx
43
mov    %cx,0x7f8(%rax)
movzwl 0x4347efdc,%ecx
43
mov    %cx,0x7fa(%rax)
movzwl 0x4347efe8,%ecx
43
mov    %cx,0x7fc(%rax)
movzwl 0x4347eff4,%ecx
43
mov    %cx,0x7fe(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i16* @create_random_shorts() {
%1 = alloca i16*
%2 = alloca i32*
%3 = alloca i16*
%4 = alloca i32
store i32* inttoptr (i64 1128775680 to i32*), i32** %2
%5 = call i16* @malloc(i32 2048)
store i16* %5, i16** %3
%6 = load i16*, i16** %3
%7 = icmp ne i16* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i16* null, i16** %1
br label %30
9: ; preds = %0
store i32 0, i32* %4
br label %10
10: ; preds = %25, %9
%11 = load i32, i32* %4
%12 = icmp ult i32 %11, 1024
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = load i32, i32* %4
%16 = mul i32 %15, 3
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %14, i64 %17
%19 = bitcast i32* %18 to i16*
%20 = load i16, i16* %19
%21 = load i16*, i16** %3
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i16, i16* %21, i64 %23
store i16 %20, i16* %24
br label %25
25: ; preds = %13
%26 = load i32, i32* %4
%27 = add i32 %26, 1
store i32 %27, i32* %4
br label %10
28: ; preds = %10
%29 = load i16*, i16** %3
store i16* %29, i16** %1
br label %30
30: ; preds = %28, %8
%31 = load i16*, i16** %1
ret i16* %31
}

LLVM IR (-O2):
define noalias i16* @create_random_shorts() {
%1 = tail call i16* @malloc(i32 2048)
%2 = icmp eq i16* %1, null
br i1 %2, label %56, label %3
3: ; preds = %0, %30
%4 = phi i64 [ %38, %30 ], [ 0, %0 ]
%5 = mul nuw nsw i64 %4, 3
%6 = getelementptr inbounds i32, i32* inttoptr (i64 1128775680 to i32*), i64 %5
%7 = bitcast i32* %6 to <48 x i16>*
%8 = load <48 x i16>, <48 x i16>* %7
%9 = shufflevector <48 x i16> %8, <48 x i16> poison, <8 x i32> <i32 0, i32 6, i32 12, i32 18, i32 24, i32 30, i32 36, i32 42>
%10 = getelementptr inbounds i16, i16* %1, i64 %4
%11 = bitcast i16* %10 to <8 x i16>*
store <8 x i16> %9, <8 x i16>* %11
%12 = or i64 %4, 8
%13 = mul nuw nsw i64 %12, 3
%14 = getelementptr inbounds i32, i32* inttoptr (i64 1128775680 to i32*), i64 %13
%15 = bitcast i32* %14 to <48 x i16>*
%16 = load <48 x i16>, <48 x i16>* %15
%17 = shufflevector <48 x i16> %16, <48 x i16> poison, <8 x i32> <i32 0, i32 6, i32 12, i32 18, i32 24, i32 30, i32 36, i32 42>
%18 = getelementptr inbounds i16, i16* %1, i64 %12
%19 = bitcast i16* %18 to <8 x i16>*
store <8 x i16> %17, <8 x i16>* %19
%20 = or i64 %4, 16
%21 = mul nuw nsw i64 %20, 3
%22 = getelementptr inbounds i32, i32* inttoptr (i64 1128775680 to i32*), i64 %21
%23 = bitcast i32* %22 to <48 x i16>*
%24 = load <48 x i16>, <48 x i16>* %23
%25 = shufflevector <48 x i16> %24, <48 x i16> poison, <8 x i32> <i32 0, i32 6, i32 12, i32 18, i32 24, i32 30, i32 36, i32 42>
%26 = getelementptr inbounds i16, i16* %1, i64 %20
%27 = bitcast i16* %26 to <8 x i16>*
store <8 x i16> %25, <8 x i16>* %27
%28 = or i64 %4, 24
%29 = icmp eq i64 %28, 1016
br i1 %29, label %39, label %30
30: ; preds = %3
%31 = mul nuw nsw i64 %28, 3
%32 = getelementptr inbounds i32, i32* inttoptr (i64 1128775680 to i32*), i64 %31
%33 = bitcast i32* %32 to <48 x i16>*
%34 = load <48 x i16>, <48 x i16>* %33
%35 = shufflevector <48 x i16> %34, <48 x i16> poison, <8 x i32> <i32 0, i32 6, i32 12, i32 18, i32 24, i32 30, i32 36, i32 42>
%36 = getelementptr inbounds i16, i16* %1, i64 %28
%37 = bitcast i16* %36 to <8 x i16>*
store <8 x i16> %35, <8 x i16>* %37
%38 = add nuw nsw i64 %4, 32
br label %3
39: ; preds = %3
%40 = load i16, i16* inttoptr (i64 1128787872 to i16*)
%41 = getelementptr inbounds i16, i16* %1, i64 1016
store i16 %40, i16* %41
%42 = load i16, i16* inttoptr (i64 1128787884 to i16*)
%43 = getelementptr inbounds i16, i16* %1, i64 1017
store i16 %42, i16* %43
%44 = load i16, i16* inttoptr (i64 1128787896 to i16*)
%45 = getelementptr inbounds i16, i16* %1, i64 1018
store i16 %44, i16* %45
%46 = load i16, i16* inttoptr (i64 1128787908 to i16*)
%47 = getelementptr inbounds i16, i16* %1, i64 1019
store i16 %46, i16* %47
%48 = load i16, i16* inttoptr (i64 1128787920 to i16*)
%49 = getelementptr inbounds i16, i16* %1, i64 1020
store i16 %48, i16* %49
%50 = load i16, i16* inttoptr (i64 1128787932 to i16*)
%51 = getelementptr inbounds i16, i16* %1, i64 1021
store i16 %50, i16* %51
%52 = load i16, i16* inttoptr (i64 1128787944 to i16*)
%53 = getelementptr inbounds i16, i16* %1, i64 1022
store i16 %52, i16* %53
%54 = load i16, i16* inttoptr (i64 1128787956 to i16*)
%55 = getelementptr inbounds i16, i16* %1, i64 1023
store i16 %54, i16* %55
br label %56
56: ; preds = %39, %0
ret i16* %1
}