#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*/ bubble_sort(int *, int);
int rand();
int /*<<< orphan*/ show_array(int *, int);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  int array[10];
  srand((unsigned int)time(NULL));
  for (i = 0; i < 10; ++i)
    array[i] = rand() % 100;
  show_array(array, 10);
  bubble_sort(array, 10);
  show_array(array, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11ac <main+0x5c>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
movslq -0x14(%rbp),%rax
mov    %edx,-0x40(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x2d>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1050 <show_array@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1070 <bubble_sort@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
call   1050 <show_array@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x24(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <show_array@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <bubble_sort@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <show_array@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 @time(i32* null)
%9 = trunc i64 %8 to i32
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %6
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 10
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 100
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %18
store i32 %16, i32* %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %11
23: ; preds = %11
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%25 = call i32 @show_array(i32* %24, i32 10)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%27 = call i32 @bubble_sort(i32* %26, i32 10)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%29 = call i32 @show_array(i32* %28, i32 10)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 100
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 %9, i32* %10
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, 100
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 %12, i32* %13
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 %15, i32* %16
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 100
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 %18, i32* %19
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
store i32 %21, i32* %22
%23 = tail call i32 (...) @rand()
%24 = srem i32 %23, 100
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
store i32 %24, i32* %25
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 100
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
store i32 %27, i32* %28
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 100
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
store i32 %30, i32* %31
%32 = tail call i32 (...) @rand()
%33 = srem i32 %32, 100
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
store i32 %33, i32* %34
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 100
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
store i32 %36, i32* %37
%38 = call i32 @show_array(i32* %10, i32 10)
%39 = call i32 @bubble_sort(i32* %10, i32 10)
%40 = call i32 @show_array(i32* %10, i32 10)
ret i32 0
}