#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, int);
int random();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  srand(time(0));
  int arr[10];
  int i, j, max, index;
  for (i = 0; i <= 9; i++)
    arr[i] = random() % 10000;
  for (j = 0; j <= 9; j++) {
    max = arr[j];
    for (i = j; i <= 9; i++) {
      if (max < arr[i]) {
        max = arr[i];
        index = i;
      }
    }
    arr[index] = arr[j];
    arr[j] = max;
  }
  for (i = 0; i <= 9; i++)
    printf("NUM.%d=%d\n", i + 1, arr[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     1193 <main+0x53>
mov    $0x0,%al
call   1060 <random@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
movslq -0x34(%rbp),%rax
mov    %edx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1164 <main+0x24>
movl   $0x0,-0x38(%rbp)
cmpl   $0x9,-0x38(%rbp)
jg     121d <main+0xdd>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     11f4 <main+0xb4>
mov    -0x3c(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11e1 <main+0xa1>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11e6 <main+0xa6>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b5 <main+0x75>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x40(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    119a <main+0x5a>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jg     1256 <main+0x116>
mov    -0x34(%rbp),%esi
add    $0x1,%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xdbd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1224 <main+0xe4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <random@plt>
movslq %eax,%r14
imul   $0x68db8bad,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0xc,%eax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%r14d
mov    %r14d,(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1060 <random@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xc,%ecx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rdx
mov    %r14d,%ecx
cmp    $0xa,%rdx
je     1345 <main+0x205>
nopl   (%rax)
mov    (%rsp,%rdx,4),%esi
cmp    %esi,%ecx
cmovl  %esi,%ecx
cmovl  %edx,%eax
add    $0x1,%rdx
cmp    $0xa,%rdx
jne    1330 <main+0x1f0>
movslq %eax,%rdx
mov    %r14d,(%rsp,%rdx,4)
mov    %ecx,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0xa,%rbx
je     135f <main+0x21f>
mov    (%rsp,%rbx,4),%r14d
jmp    1320 <main+0x1e0>
mov    (%rsp),%edx
lea    0xc97(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"NUM.%d=%d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = tail call i32 @time(i32 0)
%3 = tail call i32 @srand(i32 %2)
%4 = bitcast [10 x i32]* %1 to i8*
%5 = tail call i32 (...) @random()
%6 = srem i32 %5, 10000
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 %6, i32* %7
%8 = tail call i32 (...) @random()
%9 = srem i32 %8, 10000
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 %9, i32* %10
%11 = tail call i32 (...) @random()
%12 = srem i32 %11, 10000
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 %12, i32* %13
%14 = tail call i32 (...) @random()
%15 = srem i32 %14, 10000
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 %15, i32* %16
%17 = tail call i32 (...) @random()
%18 = srem i32 %17, 10000
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 %18, i32* %19
%20 = tail call i32 (...) @random()
%21 = srem i32 %20, 10000
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 %21, i32* %22
%23 = tail call i32 (...) @random()
%24 = srem i32 %23, 10000
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
store i32 %24, i32* %25
%26 = tail call i32 (...) @random()
%27 = srem i32 %26, 10000
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
store i32 %27, i32* %28
%29 = tail call i32 (...) @random()
%30 = srem i32 %29, 10000
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 %30, i32* %31
%32 = tail call i32 (...) @random()
%33 = srem i32 %32, 10000
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 %33, i32* %34
br label %35
35: ; preds = %0, %61
%36 = phi i32 [ %6, %0 ], [ %63, %61 ]
%37 = phi i64 [ 0, %0 ], [ %59, %61 ]
%38 = phi i32 [ undef, %0 ], [ %56, %61 ]
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %37
%40 = add nuw nsw i64 %37, 1
%41 = icmp eq i64 %40, 10
br i1 %41, label %54, label %42
42: ; preds = %35, %42
%43 = phi i64 [ %52, %42 ], [ %40, %35 ]
%44 = phi i32 [ %51, %42 ], [ %38, %35 ]
%45 = phi i32 [ %49, %42 ], [ %36, %35 ]
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %43
%47 = load i32, i32* %46
%48 = icmp slt i32 %45, %47
%49 = select i1 %48, i32 %47, i32 %45
%50 = trunc i64 %43 to i32
%51 = select i1 %48, i32 %50, i32 %44
%52 = add nuw nsw i64 %43, 1
%53 = icmp eq i64 %52, 10
br i1 %53, label %54, label %42
54: ; preds = %42, %35
%55 = phi i32 [ %36, %35 ], [ %49, %42 ]
%56 = phi i32 [ %38, %35 ], [ %51, %42 ]
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %57
store i32 %36, i32* %58
store i32 %55, i32* %39
%59 = add nuw nsw i64 %37, 1
%60 = icmp eq i64 %59, 10
br i1 %60, label %64, label %61
61: ; preds = %54
%62 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %59
%63 = load i32, i32* %62
br label %35
64: ; preds = %54
%65 = load i32, i32* %7
%66 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i32 %65)
%67 = load i32, i32* %10
%68 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2, i32 %67)
%69 = load i32, i32* %13
%70 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 3, i32 %69)
%71 = load i32, i32* %16
%72 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 4, i32 %71)
%73 = load i32, i32* %19
%74 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5, i32 %73)
%75 = load i32, i32* %22
%76 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 6, i32 %75)
%77 = load i32, i32* %25
%78 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 7, i32 %77)
%79 = load i32, i32* %28
%80 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 8, i32 %79)
%81 = load i32, i32* %31
%82 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 9, i32 %81)
%83 = load i32, i32* %34
%84 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i32 %83)
ret i32 0
}