#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 display_array(int array[], unsigned size) {
  if (array != NULL) {
    printf("\n--array begin--\n");
    for (unsigned i = 0; i < size; i++) {
      printf("value in array at index[%d]=%d\n", i, array[i]);
    }
    printf("--array end--\n");
  } else {
    printf("\n--array NULL--\n");
  }
}


x86 assembly (clang, -O0):
<display_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1187 <display_array+0x77>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1174 <display_array+0x64>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113f <display_array+0x2f>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <display_array+0x85>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_array>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
je     117b <display_array+0x5b>
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xef6(%rip),%rdi
call   1030 <puts@plt>
lea    0xefb(%rip),%r14
test   %ebx,%ebx
je     1182 <display_array+0x62>
mov    %ebx,%r13d
lea    0xeac(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <display_array+0x40>
jmp    1182 <display_array+0x62>
lea    0xe9e(%rip),%r14
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\0A--array begin--\0A\00"
@.str.1 = [32 x i8] c"value in array at index[%d]=%d\0A\00"
@.str.2 = [15 x i8] c"--array end--\0A\00"
@.str.3 = [17 x i8] c"\0A--array NULL--\0A\00"
define void @display_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** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %27
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %10
10: ; preds = %22, %8
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %5
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
ret void
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"value in array at index[%d]=%d\0A\00"
@str = [16 x i8] c"\0A--array NULL--\00"
@str.4 = [17 x i8] c"\0A--array begin--\00"
@str.5 = [14 x i8] c"--array end--\00"
define void @display_array(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0))
%6 = icmp eq i32 %1, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %15, %9 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = trunc i64 %10 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %12)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %8
br i1 %16, label %17, label %9
17: ; preds = %9, %2, %4
%18 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0), %4 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0), %9 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) %18)
ret void
}