#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 PrintDown(int *array, int length, int index) {
  int k;
  for (k = 0; k < length - index; k++) {
    printf("%4d", array[k]);
  }
  if (k < length) {
    printf(" [ ");
    for (k = length - index; k < length; k++) {
      printf("%4d", array[k]);
    }
    printf(" ]");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<PrintDown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    1161 <PrintDown+0x51>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <PrintDown+0x19>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c5 <PrintDown+0xb5>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <PrintDown+0xa7>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <PrintDown+0x74>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintDown>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %esi,%r12d
sub    %edx,%r12d
test   %r12d,%r12d
jle    1175 <PrintDown+0x55>
mov    %ebp,0x4(%rsp)
mov    %r12d,%ebp
lea    0xeb4(%rip),%r13
xor    %r14d,%r14d
nop
mov    (%rbx,%r14,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1150 <PrintDown+0x30>
mov    %r12d,%eax
mov    0x4(%rsp),%ebp
cmp    %r15d,%eax
jl     117c <PrintDown+0x5c>
jmp    11c4 <PrintDown+0xa4>
xor    %eax,%eax
cmp    %r15d,%eax
jge    11c4 <PrintDown+0xa4>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11b6 <PrintDown+0x96>
movslq %r12d,%rbp
movslq %r15d,%r15
lea    0xe65(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %r15,%rbp
jl     11a0 <PrintDown+0x80>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%4d\00"
@.str.1 = [4 x i8] c" [ \00"
@.str.2 = [3 x i8] c" ]\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @PrintDown(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
store i32 0, i32* %7
br label %8
8: ; preds = %21, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = sub nsw i32 %10, %11
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %24
14: ; preds = %8
%15 = load i32*, i32** %4
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %8
24: ; preds = %8
%25 = load i32, i32* %7
%26 = load i32, i32* %5
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %49
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = sub nsw i32 %30, %31
store i32 %32, i32* %7
br label %33
33: ; preds = %44, %28
%34 = load i32, i32* %7
%35 = load i32, i32* %5
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i32*, i32** %4
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %37
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %33
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %49
49: ; preds = %47, %24
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

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