#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 print_array(int *array, size_t array_size) {
  if (!array || !array_size) {
    printf("Empty Array\n");
    return;
  }
  printf("Array data\n[");
  int i;
  for (i = 0; i < array_size; i++) {
    printf("%d", array[i]);
    if (i < array_size - 1)
      printf(", ");
    else
      printf("]\n");
  }
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1136 <print_array+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    1149 <print_array+0x39>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <print_array+0xbe>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ce <print_array+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x14(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    11ad <print_array+0x9d>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <print_array+0xab>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <print_array+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <print_array+0x4e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1194 <print_array+0x74>
mov    %rsi,%r14
test   %rsi,%rsi
je     1194 <print_array+0x74>
mov    %rdi,%rbx
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r14),%rbp
lea    0xeb9(%rip),%r15
lea    0xec4(%rip),%r13
xor    %r12d,%r12d
jmp    1171 <print_array+0x51>
mov    %r13,%rdi
call   1030 <puts@plt>
add    $0x1,%r12
cmp    %r12,%r14
je     11ae <print_array+0x8e>
mov    (%rbx,%r12,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,%rbp
jbe    1160 <print_array+0x40>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1168 <print_array+0x48>
lea    0xe78(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Empty Array\0A\00"
@.str.1 = [13 x i8] c"Array data\0A[\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c", \00"
@.str.4 = [3 x i8] c"]\0A\00"
define void @print_array(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i32
store i32* %0, i32** %3
store i64 %1, i64* %4
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i64, i64* %4
%10 = icmp ne i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %40
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %15
15: ; preds = %37, %13
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = load i64, i64* %4
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %40
20: ; preds = %15
%21 = load i32*, i32** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = load i64, i64* %4
%30 = sub i64 %29, 1
%31 = icmp ult i64 %28, %30
br i1 %31, label %32, label %34
32: ; preds = %20
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
34: ; preds = %20
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %15
40: ; preds = %11, %15
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"Array data\0A[\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [3 x i8] c", \00"
@str = [12 x i8] c"Empty Array\00"
@str.5 = [2 x i8] c"]\00"
define void @print_array(i32* %0, i64 %1) {
%3 = icmp ne i32* %0, null
%4 = icmp ne i64 %1, 0
%5 = and i1 %3, %4
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %24
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%10 = add i64 %1, -1
br label %11
11: ; preds = %8, %21
%12 = phi i64 [ 0, %8 ], [ %22, %21 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = icmp ugt i64 %10, %12
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %21
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0))
br label %21
21: ; preds = %17, %19
%22 = add nuw i64 %12, 1
%23 = icmp eq i64 %22, %1
br i1 %23, label %24, label %11
24: ; preds = %21, %6
ret void
}