#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 *calloc(int, int);
int **malloc(int);
int **createArray() {
  int *values = calloc(10 * 32, sizeof(int));
  int **arr = malloc(32 * sizeof(int *));
  int i;
  for (i = 0; i < 32; i++)
    arr[i] = values + i * 10;
  return arr;
}


x86 assembly (clang, -O0):
<createArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x140,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1185 <createArray+0x65>
mov    -0x8(%rbp),%rdx
imul   $0xa,-0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <createArray+0x30>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createArray>:
push   %rbx
mov    $0x140,%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rbx,(%rax)
movq   %rbx,%xmm0
pshufd $0x44,%xmm0,%xmm0
movdqa 0xeae(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x8(%rax)
movdqa 0xead(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x18(%rax)
movdqa 0xeac(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x28(%rax)
movdqa 0xeab(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x38(%rax)
movdqa 0xeaa(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x48(%rax)
movdqa 0xea9(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x58(%rax)
movdqa 0xea8(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x68(%rax)
movdqa 0xea7(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x78(%rax)
movdqa 0xea6(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x88(%rax)
movdqa 0xea2(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0x98(%rax)
movdqa 0xe9e(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0xa8(%rax)
movdqa 0xe9a(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0xb8(%rax)
movdqa 0xe96(%rip),%xmm1
paddq  %xmm0,%xmm1
movdqu %xmm1,0xc8(%rax)
movdqa 0xe92(%rip),%xmm1
paddq  %xmm0,%xmm1
paddq  0xe96(%rip),%xmm0
movdqu %xmm1,0xd8(%rax)
movdqu %xmm0,0xe8(%rax)
add    $0x4d8,%rbx
mov    %rbx,0xf8(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i32** @createArray() {
%1 = alloca i32*
%2 = alloca i32**
%3 = alloca i32
%4 = call i32* @calloc(i32 320, i32 4)
store i32* %4, i32** %1
%5 = call i32** @malloc(i32 256)
store i32** %5, i32*** %2
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 32
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32*, i32** %1
%11 = load i32, i32* %3
%12 = mul nsw i32 %11, 10
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %10, i64 %13
%15 = load i32**, i32*** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32*, i32** %15, i64 %17
store i32* %14, i32** %18
br label %19
19: ; preds = %9
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %6
22: ; preds = %6
%23 = load i32**, i32*** %2
ret i32** %23
}

LLVM IR (-O2):
define noalias i32** @createArray() {
%1 = tail call i32* @calloc(i32 320, i32 4)
%2 = tail call i32** @malloc(i32 256)
store i32* %1, i32** %2
%3 = getelementptr inbounds i32*, i32** %2, i64 1
%4 = insertelement <2 x i32*> poison, i32* %1, i64 0
%5 = shufflevector <2 x i32*> %4, <2 x i32*> poison, <2 x i32> zeroinitializer
%6 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 10, i64 20>
%7 = bitcast i32** %3 to <2 x i32*>*
store <2 x i32*> %6, <2 x i32*>* %7
%8 = getelementptr inbounds i32*, i32** %2, i64 3
%9 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 30, i64 40>
%10 = bitcast i32** %8 to <2 x i32*>*
store <2 x i32*> %9, <2 x i32*>* %10
%11 = getelementptr inbounds i32*, i32** %2, i64 5
%12 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 50, i64 60>
%13 = bitcast i32** %11 to <2 x i32*>*
store <2 x i32*> %12, <2 x i32*>* %13
%14 = getelementptr inbounds i32*, i32** %2, i64 7
%15 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 70, i64 80>
%16 = bitcast i32** %14 to <2 x i32*>*
store <2 x i32*> %15, <2 x i32*>* %16
%17 = getelementptr inbounds i32*, i32** %2, i64 9
%18 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 90, i64 100>
%19 = bitcast i32** %17 to <2 x i32*>*
store <2 x i32*> %18, <2 x i32*>* %19
%20 = getelementptr inbounds i32*, i32** %2, i64 11
%21 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 110, i64 120>
%22 = bitcast i32** %20 to <2 x i32*>*
store <2 x i32*> %21, <2 x i32*>* %22
%23 = getelementptr inbounds i32*, i32** %2, i64 13
%24 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 130, i64 140>
%25 = bitcast i32** %23 to <2 x i32*>*
store <2 x i32*> %24, <2 x i32*>* %25
%26 = getelementptr inbounds i32*, i32** %2, i64 15
%27 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 150, i64 160>
%28 = bitcast i32** %26 to <2 x i32*>*
store <2 x i32*> %27, <2 x i32*>* %28
%29 = getelementptr inbounds i32*, i32** %2, i64 17
%30 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 170, i64 180>
%31 = bitcast i32** %29 to <2 x i32*>*
store <2 x i32*> %30, <2 x i32*>* %31
%32 = getelementptr inbounds i32*, i32** %2, i64 19
%33 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 190, i64 200>
%34 = bitcast i32** %32 to <2 x i32*>*
store <2 x i32*> %33, <2 x i32*>* %34
%35 = getelementptr inbounds i32*, i32** %2, i64 21
%36 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 210, i64 220>
%37 = bitcast i32** %35 to <2 x i32*>*
store <2 x i32*> %36, <2 x i32*>* %37
%38 = getelementptr inbounds i32*, i32** %2, i64 23
%39 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 230, i64 240>
%40 = bitcast i32** %38 to <2 x i32*>*
store <2 x i32*> %39, <2 x i32*>* %40
%41 = getelementptr inbounds i32*, i32** %2, i64 25
%42 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 250, i64 260>
%43 = bitcast i32** %41 to <2 x i32*>*
store <2 x i32*> %42, <2 x i32*>* %43
%44 = getelementptr inbounds i32*, i32** %2, i64 27
%45 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 270, i64 280>
%46 = bitcast i32** %44 to <2 x i32*>*
store <2 x i32*> %45, <2 x i32*>* %46
%47 = getelementptr inbounds i32*, i32** %2, i64 29
%48 = getelementptr i32, <2 x i32*> %5, <2 x i64> <i64 290, i64 300>
%49 = bitcast i32** %47 to <2 x i32*>*
store <2 x i32*> %48, <2 x i32*>* %49
%50 = getelementptr inbounds i32, i32* %1, i64 310
%51 = getelementptr inbounds i32*, i32** %2, i64 31
store i32* %50, i32** %51
ret i32** %2
}