#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*/ bubblesort(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
void main() {
  int values[10], j;
  for (j = 0; j < 10; j++)
    values[j] = rand() % 100;
  printf("\nUnsorted values.\n");
  for (j = 0; j < 10; j++)
    printf("%d ", values[j]);
  printf("\nSorted values.\n");
  bubblesort(values, 10);
  for (j = 0; j < 10; j++)
    printf("%d ", values[j]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    116e <main+0x3e>
mov    $0x0,%al
call   1050 <rand@plt>
mov    $0x64,%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    113f <main+0xf>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11b1 <main+0x81>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1183 <main+0x53>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <bubblesort@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1202 <main+0xd2>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d4 <main+0xa4>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x50(%rsp)
mov    %edx,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x48(%rsp)
mov    %edx,0x4(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x40(%rsp)
mov    %edx,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x38(%rsp)
mov    %edx,0xc(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x30(%rsp)
mov    %edx,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebp
mov    %ebp,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r15
imul   $0x51eb851f,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r15d
mov    %r15d,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
mov    %r12d,0x1c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r13
imul   $0x51eb851f,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r13d
mov    %r13d,0x20(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
mov    %ebx,0x24(%rsp)
lea    0xced(%rip),%rdi
call   1030 <puts@plt>
lea    0xcdd(%rip),%r14
mov    %r14,%rdi
mov    0x50(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    0x48(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    0x40(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    0x38(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    0x30(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc62(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
mov    $0xa,%esi
call   1050 <bubblesort@plt>
mov    (%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"\0AUnsorted values.\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [17 x i8] c"\0ASorted values.\0A\00"
define void @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %12, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 100
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %10
store i32 %8, i32* %11
br label %12
12: ; preds = %6
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %3
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %17
17: ; preds = %26, %15
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %20
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %17
29: ; preds = %17
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%32 = call i32 @bubblesort(i32* %31, i32 10)
store i32 0, i32* %2
br label %33
33: ; preds = %42, %29
%34 = load i32, i32* %2
%35 = icmp slt i32 %34, 10
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %33
45: ; preds = %33
ret void
}

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