#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(const int *start, int n) {
  const int *left;
  const int *end;
  end = start + n - 1;
  left = start;
  printf("  %i: [", n);
  while (left <= end)
    printf(" %i", *(left++));
  printf(" ]\n");
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
ja     1181 <print_array+0x71>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <print_array+0x3f>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
movslq %esi,%rsi
lea    (%rdi,%rsi,4),%r15
add    $0xfffffffffffffffc,%r15
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %rbx,%r15
jb     1165 <print_array+0x45>
lea    0xebb(%rip),%r14
nopl   (%rax)
mov    (%rbx),%esi
add    $0x4,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r15,%rbx
jbe    1150 <print_array+0x30>
lea    0xea0(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c" %i: [\00"
@.str.1 = [4 x i8] c" %i\00"
@.str.2 = [4 x i8] c" ]\0A\00"
define void @print_array(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %7, i64 %9
%11 = getelementptr inbounds i32, i32* %10, i64 -1
store i32* %11, i32** %6
%12 = load i32*, i32** %3
store i32* %12, i32** %5
%13 = load i32, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %19, %2
%16 = load i32*, i32** %5
%17 = load i32*, i32** %6
%18 = icmp ule i32* %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %5
%22 = load i32, i32* %20
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %15
24: ; preds = %15
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c" %i: [\00"
@.str.1 = [4 x i8] c" %i\00"
@str = [3 x i8] c" ]\00"
define void @print_array(i32* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = getelementptr inbounds i32, i32* %4, i64 -1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = icmp ult i32* %5, %0
br i1 %7, label %14, label %8
8: ; preds = %2, %8
%9 = phi i32* [ %10, %8 ], [ %0, %2 ]
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %9
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = icmp ugt i32* %10, %5
br i1 %13, label %14, label %8
14: ; preds = %8, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}