#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 *, long, int);
void print_results(int *array, long numberofitems) {
  long i;
  for (i = 0; i < 5; i++)
    printf(" array[%li]: %i\n", i, array[i]);
  if (numberofitems > 5)
    for (i = numberofitems - 5; i < numberofitems; i++)
      printf(" array[%li]: %i\n", i, array[i]);
}


x86 assembly (clang, -O0):
<print_results>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x5,-0x18(%rbp)
jge    115f <print_results+0x4f>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <print_results+0x18>
cmpq   $0x5,-0x10(%rbp)
jle    11b5 <print_results+0xa5>
mov    -0x10(%rbp),%rax
sub    $0x5,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11b0 <print_results+0xa0>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1176 <print_results+0x66>
jmp    11b5 <print_results+0xa5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_results>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edx
lea    0xedc(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    0x4(%rbx),%edx
mov    $0x1,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%edx
mov    $0x2,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0xc(%rbx),%edx
mov    $0x3,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0x10(%rbx),%edx
mov    $0x4,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
cmp    $0x6,%r14
jl     11d8 <print_results+0xc8>
lea    -0x5(%r14),%rsi
mov    -0x14(%rbx,%r14,4),%edx
lea    0xe7c(%rip),%r15
mov    %r15,%rdi
call   1030 <printf@plt>
lea    -0x4(%r14),%rsi
mov    -0x10(%rbx,%r14,4),%edx
mov    %r15,%rdi
call   1030 <printf@plt>
lea    -0x3(%r14),%rsi
mov    -0xc(%rbx,%r14,4),%edx
mov    %r15,%rdi
call   1030 <printf@plt>
lea    -0x2(%r14),%rsi
mov    -0x8(%rbx,%r14,4),%edx
mov    %r15,%rdi
call   1030 <printf@plt>
mov    -0x4(%rbx,%r14,4),%edx
add    $0xffffffffffffffff,%r14
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c" array[%li]: %i\0A\00"
define void @print_results(i32* nocapture %0, i64 %1) {
%3 = load i32, i32* %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 0, i32 %3)
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 1, i32 %6)
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 2, i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 3, i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 4
%15 = load i32, i32* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 4, i32 %15)
%17 = icmp sgt i64 %1, 5
br i1 %17, label %18, label %39
18: ; preds = %2
%19 = add nsw i64 %1, -5
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %19, i32 %21)
%23 = add nsw i64 %1, -4
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %23, i32 %25)
%27 = add nsw i64 %1, -3
%28 = getelementptr inbounds i32, i32* %0, i64 %27
%29 = load i32, i32* %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %27, i32 %29)
%31 = add nsw i64 %1, -2
%32 = getelementptr inbounds i32, i32* %0, i64 %31
%33 = load i32, i32* %32
%34 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %31, i32 %33)
%35 = add nsw i64 %1, -1
%36 = getelementptr inbounds i32, i32* %0, i64 %35
%37 = load i32, i32* %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %35, i32 %37)
br label %39
39: ; preds = %18, %2
ret void
}