#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 n, int swap1, int swap2) {
  int i;
  for (i = 0; i < n; i++) {
    if (i == swap1 || i == swap2) {
      printf("\x1B[1;31m"
             "%3d ",
             array[i]);
      printf("\x1B[0m");
    } else {
      printf("%3d ", array[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    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <print_array+0x98>
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1150 <print_array+0x40>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    117c <print_array+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <print_array+0x85>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <print_array+0x8a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <print_array+0x1c>
lea    0xe62(%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   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    118f <print_array+0x6f>
mov    %rdi,%rbx
mov    %ecx,%r13d
mov    %edx,%ebp
mov    %esi,%r14d
lea    0xec6(%rip),%r12
xor    %r15d,%r15d
jmp    1175 <print_array+0x55>
cs nopw 0x0(%rax,%rax,1)
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     118f <print_array+0x6f>
mov    (%rbx,%r15,4),%esi
cmp    %r15,%rbp
je     1150 <print_array+0x30>
cmp    %r15,%r13
je     1150 <print_array+0x30>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116c <print_array+0x4c>
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 = [12 x i8] c"\1B[1;31m%3d \00"
@.str.1 = [5 x i8] c"\1B[0m\00"
@.str.2 = [5 x i8] c"%3d \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @print_array(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %38, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = load i32, i32* %9
%16 = load i32, i32* %7
%17 = icmp eq i32 %15, %16
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = load i32, i32* %9
%20 = load i32, i32* %8
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %30
22: ; preds = %18, %14
%23 = load i32*, i32** %5
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %37
30: ; preds = %18
%31 = load i32*, i32** %5
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30, %22
br label %38
38: ; preds = %37
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %10
41: ; preds = %10
%42 = 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 = [12 x i8] c"\1B[1;31m%3d \00"
@.str.1 = [5 x i8] c"\1B[0m\00"
@.str.2 = [5 x i8] c"%3d \00"
define void @print_array(i32* nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %25
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = zext i32 %2 to i64
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %6, %22
%11 = phi i64 [ 0, %6 ], [ %23, %22 ]
%12 = icmp eq i64 %11, %8
%13 = icmp eq i64 %11, %7
%14 = or i1 %12, %13
%15 = getelementptr inbounds i32, i32* %0, i64 %11
%16 = load i32, i32* %15
br i1 %14, label %17, label %20
17: ; preds = %10
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %16)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %10
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %22
22: ; preds = %17, %20
%23 = add nuw nsw i64 %11, 1
%24 = icmp eq i64 %23, %9
br i1 %24, label %25, label %10
25: ; preds = %22, %4
%26 = tail call i32 @putchar(i32 10)
ret void
}