#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 */
struct ltable {
  int dummy;
};

/* Variables and functions */
int *ltable_getn(struct ltable *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void _dumparray(struct ltable *t) {
  unsigned int i = 0;
  int *p;
  printf("iter array:\n");
  while (p = ltable_getn(t, i)) {
    printf("\t%d: %d\n", i, *p);
    i++;
  }
}


x86 assembly (clang, -O0):
<_dumparray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <ltable_getn@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1180 <_dumparray+0x60>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1141 <_dumparray+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dumparray>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <ltable_getn@plt>
test   %rax,%rax
je     1180 <_dumparray+0x50>
lea    0xea7(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    (%rax),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <ltable_getn@plt>
test   %rax,%rax
jne    1160 <_dumparray+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.ltable = type { i32 }
@.str = [13 x i8] c"iter array:\0A\00"
@.str.1 = [9 x i8] c"\09%d: %d\0A\00"
define void @_dumparray(%struct.ltable* %0) {
%2 = alloca %struct.ltable*
%3 = alloca i32
%4 = alloca i32*
store %struct.ltable* %0, %struct.ltable** %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %11, %1
%7 = load %struct.ltable*, %struct.ltable** %2
%8 = load i32, i32* %3
%9 = call i32* @ltable_getn(%struct.ltable* %7, i32 %8)
store i32* %9, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = load i32, i32* %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %14)
%16 = load i32, i32* %3
%17 = add i32 %16, 1
store i32 %17, i32* %3
br label %6
18: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.ltable = type { i32 }
@.str.1 = [9 x i8] c"\09%d: %d\0A\00"
@str = [12 x i8] c"iter array:\00"
define void @_dumparray(%struct.ltable* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%3 = tail call i32* @ltable_getn(%struct.ltable* %0, i32 0)
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %1, %5
%6 = phi i32* [ %11, %5 ], [ %3, %1 ]
%7 = phi i32 [ %10, %5 ], [ 0, %1 ]
%8 = load i32, i32* %6
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
%10 = add i32 %7, 1
%11 = tail call i32* @ltable_getn(%struct.ltable* %0, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %5
13: ; preds = %5, %1
ret void
}