#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);
void print_array(int a[], int start, int length) {
  for (int i = start; i < length; ++i) {
    if (i + 1 < length) {
      printf("%d ", a[i]);
    } else {
      printf("%d\n", a[i]);
    }
  }
}


x86 assembly (clang, -O0):
<print_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1189 <print_array+0x79>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cmp    -0x10(%rbp),%eax
jge    115f <print_array+0x4f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <print_array+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    117b <print_array+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1128 <print_array+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %edx,%esi
jge    115d <print_array+0x4d>
mov    %edx,%ebp
mov    %rdi,%r14
movslq %esi,%rbx
movslq %edx,%r15
add    $0x1,%rbx
sub    %esi,%ebp
lea    0xec9(%rip),%r12
lea    0xec6(%rip),%r13
xchg   %ax,%ax
cmp    %r15,%rbx
mov    -0x4(%r14,%rbx,4),%esi
mov    %r13,%rdi
cmovl  %r12,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
add    $0xffffffff,%ebp
jne    1140 <print_array+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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