#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 *, ...);
int rand();
void print_random(int *var, int num) {
  int top, temp;
  for (int i = num - 1; i > 0; i--) {
    top = rand() % (i + 1);
    temp = var[top];
    var[top] = var[i];
    var[i] = temp;
  }
  printf("{");
  for (int i = 0; i < num - 1; i++)
    printf("%d, ", var[i]);
  printf("%d}\n", var[num - 1]);
}


x86 assembly (clang, -O0):
<print_random>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1195 <print_random+0x75>
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <print_random+0x18>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e2 <print_random+0xc2>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11aa <print_random+0x8a>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_random>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    -0x1(%r14),%r15d
cmp    $0x1,%esi
jle    11a8 <print_random+0x78>
mov    %r15d,%r12d
lea    0x1(%r12),%rbp
nop
xor    %eax,%eax
call   1050 <rand@plt>
cltd
idiv   %ebp
movslq %edx,%rax
mov    (%rbx,%rax,4),%ecx
mov    -0x4(%rbx,%rbp,4),%edx
mov    %edx,(%rbx,%rax,4)
mov    %ecx,-0x4(%rbx,%rbp,4)
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
ja     1150 <print_random+0x20>
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r14d
jl     11b2 <print_random+0x82>
lea    0xe74(%rip),%r14
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1190 <print_random+0x60>
jmp    11b2 <print_random+0x82>
mov    $0x7b,%edi
call   1030 <putchar@plt>
movslq %r15d,%rax
mov    (%rbx,%rax,4),%esi
lea    0xe46(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

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