#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_hsort_data(int a[], int idx[], const int N, FILE *out) {
  int i;
  printf("i\tidx[i]\ta[idx[i]]\ta[i]\n");
  for (i = 0; i < N; i++) {
    printf("%d\t%d\t%d\t\t%d\n", i, idx[i], a[idx[i]], a[i]);
  }
}


x86 assembly (clang, -O0):
<print_hsort_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1191 <print_hsort_data+0x81>
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdi
movslq (%rcx,%rdi,4),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113c <print_hsort_data+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hsort_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    1171 <print_hsort_data+0x51>
mov    %ebx,%r13d
lea    0xeb5(%rip),%r15
xor    %ebx,%ebx
nopl   (%rax)
movslq (%r14,%rbx,4),%rdx
mov    (%r12,%rdx,4),%ecx
mov    (%r12,%rbx,4),%r8d
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <print_hsort_data+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"i\09idx[i]\09a[idx[i]]\09a[i]\0A\00"
@.str.1 = [14 x i8] c"%d\09%d\09%d\09\09%d\0A\00"
define void @print_hsort_data(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
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %11
11: ; preds = %37, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %11
%16 = load i32, i32* %9
%17 = load i32*, i32** %6
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32*, i32** %5
%23 = load i32*, i32** %6
%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 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %22, i64 %28
%30 = load i32, i32* %29
%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 ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %21, i32 %30, i32 %35)
br label %37
37: ; preds = %15
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %11
40: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"%d\09%d\09%d\09\09%d\0A\00"
@str = [24 x i8] c"i\09idx[i]\09a[idx[i]]\09a[i]\00"
define void @print_hsort_data(i32* nocapture %0, i32* nocapture %1, i32 %2, i32* nocapture readnone %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %20, %9 ]
%11 = getelementptr inbounds i32, i32* %1, i64 %10
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %0, i64 %10
%17 = load i32, i32* %16
%18 = trunc i64 %10 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %12, i32 %15, i32 %17)
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %9, %4
ret void
}