#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 printRev(int a[], int k) {
  int i;
  printf("[");
  for (i = 0; i < k; i++) {
    if (i > 0) {
      printf(",");
    }
    printf("%d", a[k - i - 1]);
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<printRev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <printRev+0x77>
cmpl   $0x0,-0x10(%rbp)
jle    1158 <printRev+0x48>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <printRev+0x24>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printRev>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%r15
mov    $0x5b,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1197 <printRev+0x67>
lea    -0x1(%r14),%eax
mov    (%r15,%rax,4),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x1,%r14d
je     1197 <printRev+0x67>
mov    %r14d,%ebx
lea    0xe90(%rip),%r14
mov    $0x2c,%edi
call   1030 <putchar@plt>
lea    -0x2(%rbx),%eax
cltq
mov    (%r15,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jne    1170 <printRev+0x40>
lea    0xe65(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@str = [2 x i8] c"]\00"
define void @printRev(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @putchar(i32 91)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = add nsw i32 %1, -1
%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 ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = icmp eq i32 %1, 1
br i1 %12, label %25, label %13
13: ; preds = %5, %13
%14 = phi i64 [ %23, %13 ], [ 1, %5 ]
%15 = tail call i32 @putchar(i32 44)
%16 = trunc i64 %14 to i32
%17 = xor i32 %16, -1
%18 = add i32 %17, %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %14, 1
%24 = icmp eq i64 %23, %6
br i1 %24, label %25, label %13
25: ; preds = %13, %5, %2
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}