#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 *, int, int);
void showItens(int *array, int index) {
  int i, j = 0;
  for (i = index; i < 10; i++) {
    if (array[i] != -1) {
      j++;
      printf("\n%d - value: %d\n", j, array[i]);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<showItens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    117e <showItens+0x6e>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     116b <showItens+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    1170 <showItens+0x60>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112c <showItens+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showItens>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x9,%esi
jg     1161 <showItens+0x51>
movslq %esi,%rax
lea    (%rdi,%rax,4),%r15
mov    $0xa,%r12d
sub    %esi,%r12d
xor    %ebx,%ebx
lea    0xeca(%rip),%r14
xor    %ebp,%ebp
jmp    1149 <showItens+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %ebx,%r12d
je     1161 <showItens+0x51>
mov    (%r15,%rbx,4),%edx
cmp    $0xffffffff,%edx
je     1140 <showItens+0x30>
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    1140 <showItens+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"\0A%d - value: %d\0A\00"
define void @showItens(i32* nocapture %0, i32 %1) {
%3 = icmp slt i32 %1, 10
br i1 %3, label %4, label %20
4: ; preds = %2
%5 = sext i32 %1 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ %5, %4 ], [ %17, %15 ]
%8 = phi i32 [ 0, %4 ], [ %16, %15 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %7
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, -1
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = add nsw i32 %8, 1
%14 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %10)
br label %15
15: ; preds = %6, %12
%16 = phi i32 [ %13, %12 ], [ %8, %6 ]
%17 = add nsw i64 %7, 1
%18 = trunc i64 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %6
20: ; preds = %15, %2
ret void
}