#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 array[], int len, int index) {
  printf("\n");
  int i;
  for (i = 0; i < len; i++) {
    if (i == index || i == index + 1) {
      if (array[index] > array[index + 1]) {
        printf("\x1B[1;32m"
               "%d ",
               array[i]);
      } else {
        printf("\x1B[1;31m"
               "%d ",
               array[i]);
      }
    } else {
      printf("\x1B[0m"
             "%d ",
             array[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)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e9 <print_array+0xd9>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1160 <print_array+0x50>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    11bd <print_array+0xad>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jle    119f <print_array+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b8 <print_array+0xa8>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d6 <print_array+0xc6>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11db <print_array+0xcb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print_array+0x27>
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
mov    %edx,%r14d
mov    %esi,%r13d
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r13d,%r13d
jle    11aa <print_array+0x8a>
movslq %r14d,%r15
add    $0x1,%r14d
movslq %r14d,%rax
mov    %rax,(%rsp)
mov    %r15d,%ebp
mov    %r13d,%r13d
xor    %r12d,%r12d
jmp    1177 <print_array+0x57>
nopl   0x0(%rax)
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r13
je     11aa <print_array+0x8a>
cmp    %r12,%rbp
je     1190 <print_array+0x70>
cmp    %r12,%r14
je     1190 <print_array+0x70>
mov    (%rbx,%r12,4),%esi
lea    0xe8a(%rip),%rdi
jmp    1167 <print_array+0x47>
xchg   %ax,%ax
mov    (%rbx,%r15,4),%eax
mov    (%rbx,%r12,4),%esi
mov    (%rsp),%rcx
cmp    (%rbx,%rcx,4),%eax
jle    1160 <print_array+0x40>
lea    0xe58(%rip),%rdi
jmp    1167 <print_array+0x47>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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