#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_decrease(int *, int *);
int /*<<< orphan*/ bubble_increase(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void bubble_sort(int *front, int *end) {
  int i;
  int size = end - front;
  bubble_increase(front, end);
  for (i = 0; i <= size; ++i)
    printf("%d ", *(front + i));
  printf("\n");
  bubble_decrease(front, end);
  for (i = 0; i <= size; ++i)
    printf("%d ", *(front + i));
  return;
}


x86 assembly (clang, -O0):
<bubble_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <bubble_increase@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1199 <bubble_sort+0x69>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <bubble_sort+0x36>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <bubble_decrease@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11ee <bubble_sort+0xbe>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <bubble_sort+0x8b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bubble_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%r13
sub    %rdi,%r13
call   1040 <bubble_increase@plt>
bt     $0x21,%r13
jb     1205 <bubble_sort+0xc5>
mov    %rbp,(%rsp)
mov    %r13,%r12
shr    $0x2,%r12
lea    0x1(%r12),%ebp
lea    0xe82(%rip),%r15
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r14,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1190 <bubble_sort+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    (%rsp),%rsi
call   1060 <bubble_decrease@plt>
bt     $0x21,%r13
jb     11f6 <bubble_sort+0xb6>
add    $0x1,%r12d
lea    0xe31(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11e0 <bubble_sort+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <bubble_decrease@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @bubble_sort(i32* %0, i32* %1) {
%3 = ptrtoint i32* %1 to i64
%4 = ptrtoint i32* %0 to i64
%5 = sub i64 %3, %4
%6 = lshr exact i64 %5, 2
%7 = tail call i32 @bubble_increase(i32* %0, i32* %1)
%8 = and i64 %5, 8589934592
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %33
10: ; preds = %2
%11 = add nuw nsw i64 %6, 1
%12 = and i64 %11, 4294967295
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %18, %13 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, %12
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 @bubble_decrease(i32* %0, i32* %1)
br i1 %9, label %23, label %36
23: ; preds = %20
%24 = add nuw nsw i64 %6, 1
%25 = and i64 %24, 4294967295
br label %26
26: ; preds = %23, %26
%27 = phi i64 [ 0, %23 ], [ %31, %26 ]
%28 = getelementptr inbounds i32, i32* %0, i64 %27
%29 = load i32, i32* %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = add nuw nsw i64 %27, 1
%32 = icmp eq i64 %31, %25
br i1 %32, label %36, label %26
33: ; preds = %2
%34 = tail call i32 @putchar(i32 10)
%35 = tail call i32 @bubble_decrease(i32* %0, i32* %1)
br label %36
36: ; preds = %26, %33, %20
ret void
}