#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*/ printf(char *, ...);
void DumpArray(const int *pArray, const int size) {
  int i = 0;
  printf("Dump array:\n");
  if (pArray == NULL) {
    printf("Array pointer is NULL\n\n");
    return;
  }
  if (size < 1) {
    printf("An array of size %d is invalid\n\n", size);
    return;
  }
  for (i = 0; i < size; ++i) {
    printf("  [%3d] = %d\n", i, pArray[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<DumpArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
jne    1152 <DumpArray+0x42>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <DumpArray+0xad>
cmpl   $0x1,-0xc(%rbp)
jge    1172 <DumpArray+0x62>
mov    -0xc(%rbp),%esi
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bd <DumpArray+0xad>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11af <DumpArray+0x9f>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <DumpArray+0x69>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DumpArray>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
test   %r15,%r15
je     118d <DumpArray+0x5d>
test   %ebp,%ebp
jle    11a3 <DumpArray+0x73>
mov    %ebp,%ebx
lea    0xec7(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,4),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <DumpArray+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
lea    0xea7(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
lea    0xe56(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Dump array:\0A\00"
@.str.1 = [24 x i8] c"Array pointer is NULL\0A\0A\00"
@.str.2 = [33 x i8] c"An array of size %d is invalid\0A\0A\00"
@.str.3 = [14 x i8] c" [%3d] = %d\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @DumpArray(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = load i32*, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %35
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %35
17: ; preds = %11
store i32 0, i32* %5
br label %18
18: ; preds = %30, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* %5
%24 = load i32*, i32** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %18
33: ; preds = %18
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %14, %9
ret void
}

LLVM IR (-O2):
@.str.2 = [33 x i8] c"An array of size %d is invalid\0A\0A\00"
@.str.3 = [14 x i8] c" [%3d] = %d\0A\00"
@str = [12 x i8] c"Dump array:\00"
@str.5 = [23 x i8] c"Array pointer is NULL\0A\00"
define void @DumpArray(i32* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32* %0, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
br label %23
7: ; preds = %2
%8 = icmp slt i32 %1, 1
br i1 %8, label %11, label %9
9: ; preds = %7
%10 = zext i32 %1 to i64
br label %13
11: ; preds = %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %23
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %19, %13 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = trunc i64 %14 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %16)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %21, label %13
21: ; preds = %13
%22 = tail call i32 @putchar(i32 10)
br label %23
23: ; preds = %21, %11, %5
ret void
}