#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printArray(int, int *, int);
int /*<<< orphan*/ printf(char *);
void manualArray(void) {
  int countToFive[5] = {1, 2, 3, 4, 5};
  printf("countToFive:");
  printArray(5, countToFive, 0);
  printf("countToFive ptrs:");
  printArray(5, countToFive, 1);
  printf("countToFive relative position:");
  printArray(5, countToFive, 2);
  printf("\n");
  int *ptrArray = malloc(5 * sizeof(int));
  *ptrArray = 1;
  *(ptrArray + 1) = 2;
  *(ptrArray + 2) = 3;
  ptrArray[3] = 4;
  ptrArray[4] = 5;
  printf("ptrArray:");
  printArray(5, ptrArray, 0);
  printf("ptrArray ptrs:");
  printArray(5, ptrArray, 1);
  printf("ptrArray relative position:");
  printArray(5, ptrArray, 2);
  free(ptrArray);
}


x86 assembly (clang, -O0):
<manualArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
mov    $0x5,%edi
xor    %edx,%edx
call   1060 <printArray@plt>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
mov    $0x5,%edi
mov    $0x1,%edx
call   1060 <printArray@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
mov    $0x5,%edi
mov    $0x2,%edx
call   1060 <printArray@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x14,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x28(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x28(%rbp),%rax
movl   $0x4,0xc(%rax)
mov    -0x28(%rbp),%rax
movl   $0x5,0x10(%rax)
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    $0x5,%edi
xor    %edx,%edx
call   1060 <printArray@plt>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    $0x5,%edi
mov    $0x1,%edx
call   1060 <printArray@plt>
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    $0x5,%edi
mov    $0x2,%edx
call   1060 <printArray@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manualArray>:
push   %rbx
sub    $0x20,%rsp
mov    0xec5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb3(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    $0x5,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <printArray@plt>
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <printArray@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1070 <printArray@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movaps 0xe1e(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x5,0x10(%rax)
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1070 <printArray@plt>
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <printArray@plt>
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x5,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1070 <printArray@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.manualArray.countToFive = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str = [13 x i8] c"countToFive:\00"
@.str.1 = [18 x i8] c"countToFive ptrs:\00"
@.str.2 = [31 x i8] c"countToFive relative position:\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [10 x i8] c"ptrArray:\00"
@.str.5 = [15 x i8] c"ptrArray ptrs:\00"
@.str.6 = [28 x i8] c"ptrArray relative position:\00"
define void @manualArray() {
%1 = alloca [5 x i32]
%2 = alloca i32*
%3 = bitcast [5 x i32]* %1 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @printArray(i32 5, i32* %5, i32 0)
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%9 = call i32 @printArray(i32 5, i32* %8, i32 1)
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%12 = call i32 @printArray(i32 5, i32* %11, i32 2)
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32* @malloc(i32 20)
store i32* %14, i32** %2
%15 = load i32*, i32** %2
store i32 1, i32* %15
%16 = load i32*, i32** %2
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 2, i32* %17
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 2
store i32 3, i32* %19
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 3
store i32 4, i32* %21
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i64 4
store i32 5, i32* %23
%24 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32*, i32** %2
%26 = call i32 @printArray(i32 5, i32* %25, i32 0)
%27 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32*, i32** %2
%29 = call i32 @printArray(i32 5, i32* %28, i32 1)
%30 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%31 = load i32*, i32** %2
%32 = call i32 @printArray(i32 5, i32* %31, i32 2)
%33 = load i32*, i32** %2
%34 = call i32 @free(i32* %33)
ret void
}

LLVM IR (-O2):
@__const.manualArray.countToFive = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@.str = [13 x i8] c"countToFive:\00"
@.str.1 = [18 x i8] c"countToFive ptrs:\00"
@.str.2 = [31 x i8] c"countToFive relative position:\00"
@.str.4 = [10 x i8] c"ptrArray:\00"
@.str.5 = [15 x i8] c"ptrArray ptrs:\00"
@.str.6 = [28 x i8] c"ptrArray relative position:\00"
define void @manualArray() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = call i32 @printArray(i32 5, i32* %4, i32 0)
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printArray(i32 5, i32* %4, i32 1)
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @printArray(i32 5, i32* %4, i32 2)
%10 = call i32 @putchar(i32 10)
%11 = call i32* @malloc(i32 20)
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %11, i64 4
store i32 5, i32* %13
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @printArray(i32 5, i32* %11, i32 0)
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @printArray(i32 5, i32* %11, i32 1)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @printArray(i32 5, i32* %11, i32 2)
%20 = call i32 @free(i32* %11)
ret void
}