#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int *shuffle_cards(int *, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int cards[52], i;
  int *shuffled;
  for (i = 0; i < 52; i++) {
    cards[i] = i + 1;
  }
  if ((shuffled = shuffle_cards(cards, 30, 52)) == NULL) {
    fprintf(stderr, "Failed to sort cards");
    exit(1);
  }
  printf("Sorted cards are : \n");
  for (i = 0; i < 52; i++) {
    printf("%d\n", shuffled[i]);
  }
  free(shuffled);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x34,-0xe4(%rbp)
jge    11ab <main+0x5b>
mov    -0xe4(%rbp),%ecx
add    $0x1,%ecx
movslq -0xe4(%rbp),%rax
mov    %ecx,-0xe0(%rbp,%rax,4)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1173 <main+0x23>
lea    -0xe0(%rbp),%rdi
mov    $0x1e,%esi
mov    $0x34,%edx
call   1060 <shuffle_cards@plt>
mov    %rax,-0xf0(%rbp)
cmp    $0x0,%rax
jne    11f1 <main+0xa1>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xe4(%rbp)
cmpl   $0x34,-0xe4(%rbp)
jge    1249 <main+0xf9>
mov    -0xf0(%rbp),%rax
movslq -0xe4(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1209 <main+0xb9>
mov    -0xf0(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xe92(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
mov    %rsp,%rdi
mov    $0x1e,%esi
mov    $0x34,%edx
call   1070 <shuffle_cards@plt>
test   %rax,%rax
je     127f <main+0x11f>
mov    %rax,%r15
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
lea    0xea2(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x34,%rbx
jne    1250 <main+0xf0>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"Failed to sort cards\00"
@.str.1 = [21 x i8] c"Sorted cards are : \0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [52 x i32]
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %9
9: ; preds = %18, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 52
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %7
%14 = add nsw i32 %13, 1
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [52 x i32], [52 x i32]* %6, i64 0, i64 %16
store i32 %14, i32* %17
br label %18
18: ; preds = %12
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %9
21: ; preds = %9
%22 = getelementptr inbounds [52 x i32], [52 x i32]* %6, i64 0, i64 0
%23 = call i32* @shuffle_cards(i32* %22, i32 30, i32 52)
store i32* %23, i32** %8
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %31
31: ; preds = %41, %29
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 52
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32*, i32** %8
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %31
44: ; preds = %31
%45 = load i32*, i32** %8
%46 = call i32 @free(i32* %45)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"Failed to sort cards\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@str = [20 x i8] c"Sorted cards are : \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [52 x i32]
%4 = bitcast [52 x i32]* %3 to i8*
%5 = bitcast [52 x i32]* %3 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %5
%6 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 4
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %7
%8 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 8
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 9, i32 10, i32 11, i32 12>, <4 x i32>* %9
%10 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 12
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 13, i32 14, i32 15, i32 16>, <4 x i32>* %11
%12 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 16
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 17, i32 18, i32 19, i32 20>, <4 x i32>* %13
%14 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 20
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 21, i32 22, i32 23, i32 24>, <4 x i32>* %15
%16 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 24
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 25, i32 26, i32 27, i32 28>, <4 x i32>* %17
%18 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 28
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 29, i32 30, i32 31, i32 32>, <4 x i32>* %19
%20 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 32
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 33, i32 34, i32 35, i32 36>, <4 x i32>* %21
%22 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 36
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 37, i32 38, i32 39, i32 40>, <4 x i32>* %23
%24 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 40
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> <i32 41, i32 42, i32 43, i32 44>, <4 x i32>* %25
%26 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 44
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> <i32 45, i32 46, i32 47, i32 48>, <4 x i32>* %27
%28 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 48
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> <i32 49, i32 50, i32 51, i32 52>, <4 x i32>* %29
%30 = getelementptr inbounds [52 x i32], [52 x i32]* %3, i64 0, i64 0
%31 = call i32* @shuffle_cards(i32* %30, i32 30, i32 52)
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %2
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %2
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %39
39: ; preds = %37, %39
%40 = phi i64 [ 0, %37 ], [ %44, %39 ]
%41 = getelementptr inbounds i32, i32* %31, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %40, 1
%45 = icmp eq i64 %44, 52
br i1 %45, label %46, label %39
46: ; preds = %39
%47 = call i32 @free(i32* %31)
ret i32 0
}