#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int *malloc(int);
int /*<<< orphan*/ stderr;
void create_array(int **array, int size) {
  *array = malloc(sizeof(int) * size);
  if (*array == NULL) {
    fprintf(stderr, "Err. can't allocate memory");
    exit(EXIT_FAILURE);
  }
  for (int i = 0; i < size; i++)
    (*array)[i] = i * i;
}


x86 assembly (clang, -O0):
<create_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1189 <create_array+0x59>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <create_array+0x8f>
mov    -0x10(%rbp),%edx
imul   -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1190 <create_array+0x60>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_array>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x0(,%rbx,4),%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     12fe <create_array+0x1ce>
test   %ebx,%ebx
jle    12e1 <create_array+0x1b1>
mov    %ebx,%ecx
cmp    $0x8,%ebx
jae    1167 <create_array+0x37>
xor    %edx,%edx
jmp    12d0 <create_array+0x1a0>
mov    %ecx,%edx
and    $0xfffffff8,%edx
lea    -0x8(%rdx),%rsi
mov    %rsi,%rbx
shr    $0x3,%rbx
add    $0x1,%rbx
test   %rsi,%rsi
je     12e9 <create_array+0x1b9>
mov    %rbx,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xe6d(%rip),%xmm0
xor    %esi,%esi
movdqa 0xe73(%rip),%xmm1
movdqa 0xe7b(%rip),%xmm2
movdqa 0xe83(%rip),%xmm3
movdqa 0xe8b(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm0,%xmm5
paddd  %xmm1,%xmm5
movdqa %xmm0,%xmm6
pmuludq %xmm0,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm6
pshufd $0xf5,%xmm5,%xmm7
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm5
movdqu %xmm6,(%rax,%rsi,4)
movdqu %xmm5,0x10(%rax,%rsi,4)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
pshufd $0xf5,%xmm5,%xmm7
pmuludq %xmm5,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm5
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm6,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pmuludq %xmm7,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm6
movdqu %xmm5,0x20(%rax,%rsi,4)
movdqu %xmm6,0x30(%rax,%rsi,4)
add    $0x10,%rsi
paddd  %xmm4,%xmm0
add    $0xfffffffffffffffe,%rdi
jne    11c0 <create_array+0x90>
test   $0x1,%bl
je     12c3 <create_array+0x193>
movdqa 0xd92(%rip),%xmm1
paddd  %xmm0,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm0,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm2,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pshufd $0xf5,%xmm1,%xmm2
pmuludq %xmm1,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm2,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
movdqu %xmm0,(%rax,%rsi,4)
movdqu %xmm1,0x10(%rax,%rsi,4)
cmp    %rcx,%rdx
je     12e1 <create_array+0x1b1>
nopl   0x0(%rax,%rax,1)
mov    %edx,%esi
imul   %edx,%esi
mov    %esi,(%rax,%rdx,4)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    12d0 <create_array+0x1a0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
movdqa 0xd0f(%rip),%xmm0
xor    %esi,%esi
test   $0x1,%bl
jne    1276 <create_array+0x146>
jmp    12c3 <create_array+0x193>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"Err. can't allocate memory\00"
@EXIT_FAILURE = global i32 0
define void @create_array(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i32
store i32** %0, i32*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = mul i64 4, %7
%9 = trunc i64 %8 to i32
%10 = call i32* @malloc(i32 %9)
%11 = load i32**, i32*** %3
store i32* %10, i32** %11
%12 = load i32**, i32*** %3
%13 = load i32*, i32** %12
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
store i32 0, i32* %5
br label %21
21: ; preds = %34, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %5
%27 = load i32, i32* %5
%28 = mul nsw i32 %26, %27
%29 = load i32**, i32*** %3
%30 = load i32*, i32** %29
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
store i32 %28, i32* %33
br label %34
34: ; preds = %25
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %21
37: ; preds = %21
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Err. can't allocate memory\00"
@EXIT_FAILURE = global i32 0
define void @create_array(i32** nocapture %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = tail call i32* @malloc(i32 %3)
store i32* %4, i32** %0
%5 = icmp eq i32* %4, null
br i1 %5, label %60, label %6
6: ; preds = %2
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %65
8: ; preds = %6
%9 = zext i32 %1 to i64
%10 = icmp ult i32 %1, 8
br i1 %10, label %58, label %11
11: ; preds = %8
%12 = and i64 %9, 4294967288
%13 = add nsw i64 %12, -8
%14 = lshr exact i64 %13, 3
%15 = add nuw nsw i64 %14, 1
%16 = and i64 %15, 1
%17 = icmp eq i64 %13, 0
br i1 %17, label %44, label %18
18: ; preds = %11
%19 = and i64 %15, 4611686018427387902
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ 0, %18 ], [ %40, %20 ]
%22 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %18 ], [ %41, %20 ]
%23 = phi i64 [ 0, %18 ], [ %42, %20 ]
%24 = add <4 x i32> %22, <i32 4, i32 4, i32 4, i32 4>
%25 = mul nsw <4 x i32> %22, %22
%26 = mul nsw <4 x i32> %24, %24
%27 = getelementptr inbounds i32, i32* %4, i64 %21
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %28
%29 = getelementptr inbounds i32, i32* %27, i64 4
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %30
%31 = or i64 %21, 8
%32 = add <4 x i32> %22, <i32 8, i32 8, i32 8, i32 8>
%33 = add <4 x i32> %22, <i32 12, i32 12, i32 12, i32 12>
%34 = mul nsw <4 x i32> %32, %32
%35 = mul nsw <4 x i32> %33, %33
%36 = getelementptr inbounds i32, i32* %4, i64 %31
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> %34, <4 x i32>* %37
%38 = getelementptr inbounds i32, i32* %36, i64 4
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> %35, <4 x i32>* %39
%40 = add nuw i64 %21, 16
%41 = add <4 x i32> %22, <i32 16, i32 16, i32 16, i32 16>
%42 = add i64 %23, 2
%43 = icmp eq i64 %42, %19
br i1 %43, label %44, label %20
44: ; preds = %20, %11
%45 = phi i64 [ 0, %11 ], [ %40, %20 ]
%46 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %11 ], [ %41, %20 ]
%47 = icmp eq i64 %16, 0
br i1 %47, label %56, label %48
48: ; preds = %44
%49 = add <4 x i32> %46, <i32 4, i32 4, i32 4, i32 4>
%50 = mul nsw <4 x i32> %46, %46
%51 = mul nsw <4 x i32> %49, %49
%52 = getelementptr inbounds i32, i32* %4, i64 %45
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %53
%54 = getelementptr inbounds i32, i32* %52, i64 4
%55 = bitcast i32* %54 to <4 x i32>*
store <4 x i32> %51, <4 x i32>* %55
br label %56
56: ; preds = %44, %48
%57 = icmp eq i64 %12, %9
br i1 %57, label %65, label %58
58: ; preds = %8, %56
%59 = phi i64 [ 0, %8 ], [ %12, %56 ]
br label %66
60: ; preds = %2
%61 = load i32, i32* @stderr
%62 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
%64 = tail call i32 @exit(i32 %63)
unreachable
65: ; preds = %66, %56, %6
ret void
66: ; preds = %58, %66
%67 = phi i64 [ %71, %66 ], [ %59, %58 ]
%68 = trunc i64 %67 to i32
%69 = mul nsw i32 %68, %68
%70 = getelementptr inbounds i32, i32* %4, i64 %67
store i32 %69, i32* %70
%71 = add nuw nsw i64 %67, 1
%72 = icmp eq i64 %71, %9
br i1 %72, label %65, label %66
}