#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 */
typedef int /*<<< orphan*/ arr2;
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ bubble_sorti(int *, int);
int /*<<< orphan*/ optimized_bubble_sorti(int *, int);
int /*<<< orphan*/ printvinl(int *, int);
int main() {
  int arr[] = {5, 1, 4, 2, 8};
  int arr2[] = {5, 1, 4, 2, 8, -10};
  bubble_sorti(arr, (sizeof(arr) / sizeof(arr[0])));
  printvinl(arr, (sizeof(arr) / sizeof(arr[0])));
  optimized_bubble_sorti(arr2, (sizeof(arr2) / sizeof(arr2[0])));
  printvinl(arr2, (sizeof(arr2) / sizeof(arr2[0])));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1050 <bubble_sorti@plt>
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
call   1040 <printvinl@plt>
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1030 <optimized_bubble_sorti@plt>
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1040 <printvinl@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xed5(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0xedf(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <bubble_sorti@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <printvinl@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <optimized_bubble_sorti@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <printvinl@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [5 x i32] [i32 5, i32 1, i32 4, i32 2, i32 8]
@__const.main.arr2 = [6 x i32] [i32 5, i32 1, i32 4, i32 2, i32 8, i32 -10]
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca [6 x i32]
store i32 0, i32* %1
%4 = bitcast [5 x i32]* %2 to i8*
%5 = bitcast [6 x i32]* %3 to i8*
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%7 = call i32 @bubble_sorti(i32* %6, i32 5)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%9 = call i32 @printvinl(i32* %8, i32 5)
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%11 = call i32 @optimized_bubble_sorti(i32* %10, i32 6)
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%13 = call i32 @printvinl(i32* %12, i32 6)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [5 x i32] [i32 5, i32 1, i32 4, i32 2, i32 8]
@__const.main.arr2 = [6 x i32] [i32 5, i32 1, i32 4, i32 2, i32 8, i32 -10]
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [6 x i32]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = bitcast [6 x i32]* %2 to i8*
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%6 = call i32 @bubble_sorti(i32* %5, i32 5)
%7 = call i32 @printvinl(i32* %5, i32 5)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 0
%9 = call i32 @optimized_bubble_sorti(i32* %8, i32 6)
%10 = call i32 @printvinl(i32* %8, i32 6)
ret i32 0
}