#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 *, char *, int, int);
void show_elements_from_array(int *array, char *optnional_message) {
  int i = 0;
  for (; i < 10; ++i) {
    printf("%s at[%i] is: %i\n", optnional_message, i, array[i]);
  }
}


x86 assembly (clang, -O0):
<show_elements_from_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    115d <show_elements_from_array+0x4d>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <show_elements_from_array+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_elements_from_array>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%ecx
lea    0xedc(%rip),%r15
mov    %r15,%rdi
xor    %edx,%edx
call   1030 <printf@plt>
mov    0x4(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    0x8(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <printf@plt>
mov    0xc(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    0x10(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    0x14(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <printf@plt>
mov    0x18(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <printf@plt>
mov    0x1c(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <printf@plt>
mov    0x20(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <printf@plt>
mov    0x24(%rbx),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [18 x i8] c"%s at[%i] is: %i\0A\00"
define void @show_elements_from_array(i32* nocapture %0, i8* %1) {
%3 = load i32, i32* %0
%4 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 0, i32 %3)
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 1, i32 %6)
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 2, i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 3, i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 4
%15 = load i32, i32* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 4, i32 %15)
%17 = getelementptr inbounds i32, i32* %0, i64 5
%18 = load i32, i32* %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 5, i32 %18)
%20 = getelementptr inbounds i32, i32* %0, i64 6
%21 = load i32, i32* %20
%22 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 6, i32 %21)
%23 = getelementptr inbounds i32, i32* %0, i64 7
%24 = load i32, i32* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 7, i32 %24)
%26 = getelementptr inbounds i32, i32* %0, i64 8
%27 = load i32, i32* %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 8, i32 %27)
%29 = getelementptr inbounds i32, i32* %0, i64 9
%30 = load i32, i32* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i32 9, i32 %30)
ret void
}