#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 *, ...);
void print_array(int x[], unsigned int p, unsigned int q) {
  unsigned int i;
  printf("array[%d..%d]: ", p, q);
  for (i = p; i <= q; i++) {
    printf("%d ", x[i]);
  }
  printf("\n");
}


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),%esi
mov    -0x10(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     116e <print_array+0x5e>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <print_array+0x2c>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,%ebp
ja     1167 <print_array+0x47>
lea    0xec9(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    %ebp,%eax
mov    (%r14,%rax,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebx,%ebp
jbe    1150 <print_array+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"array[%d..%d]: \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\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
%9 = load i32, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %5
store i32 %11, i32* %7
br label %12
12: ; preds = %23, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp ule i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32*, i32** %4
%18 = load i32, i32* %7
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %7
%25 = add i32 %24, 1
store i32 %25, i32* %7
br label %12
26: ; preds = %12
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

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