#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*/ assert(int *);
int /*<<< orphan*/ printf(char *, ...);
void print_array(int *a, int len) {
  assert(a);
  if (!a)
    return;
  for (int i = 0; i < len; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
jne    1148 <print_array+0x28>
jmp    1190 <print_array+0x70>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1182 <print_array+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <print_array+0x2f>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
call   1050 <assert@plt>
test   %r15,%r15
je     118b <print_array+0x5b>
test   %ebp,%ebp
jle    1177 <print_array+0x47>
mov    %ebp,%ebp
lea    0xead(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <print_array+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @print_array(i32* %0, i32 %1) {
%3 = tail call i32 @assert(i32* %0)
%4 = icmp eq i32* %0, null
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = zext i32 %1 to i64
br label %11
9: ; preds = %11, %5
%10 = tail call i32 @putchar(i32 10)
br label %18
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %16, %11 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %9, label %11
18: ; preds = %2, %9
ret void
}