#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*/ _swap(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void bubble_sort(int A[], int start, int end) {
  int x = start, y = start;
  for (y = start; y <= end; y++) {
    for (x = start; x <= end - y; x++) {
      printf("%d %d \t", x, x + 1);
      _swap(A, x, x + 1);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<bubble_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11ba <bubble_sort+0x9a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jg     119e <bubble_sort+0x7e>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1040 <_swap@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <bubble_sort+0x36>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <bubble_sort+0x24>
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    %esi,(%rsp)
cmp    %edx,%esi
jle    1151 <bubble_sort+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edx,%r15d
mov    %rdi,%r13
lea    0xea2(%rip),%r12
mov    (%rsp),%eax
mov    %eax,%r14d
mov    %edx,0x4(%rsp)
jmp    118b <bubble_sort+0x5b>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
mov    0x4(%rsp),%r15d
cmp    %r15d,%r14d
mov    %eax,%r14d
je     1142 <bubble_sort+0x12>
sub    %r14d,%r15d
cmp    (%rsp),%r15d
jl     1170 <bubble_sort+0x40>
mov    (%rsp),%eax
mov    %eax,%ebx
nopl   0x0(%rax)
lea    0x1(%rbx),%ebp
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <_swap@plt>
cmp    %r15d,%ebx
mov    %ebp,%ebx
jl     11a0 <bubble_sort+0x70>
jmp    1170 <bubble_sort+0x40>

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

LLVM IR (-O2):
@.str = [8 x i8] c"%d %d \09\00"
define void @bubble_sort(i32* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, %2
br i1 %4, label %19, label %5
5: ; preds = %3, %15
%6 = phi i32 [ %17, %15 ], [ %1, %3 ]
%7 = sub nsw i32 %2, %6
%8 = icmp slt i32 %7, %1
br i1 %8, label %15, label %9
9: ; preds = %5, %9
%10 = phi i32 [ %11, %9 ], [ %1, %5 ]
%11 = add nsw i32 %10, 1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = tail call i32 @_swap(i32* %0, i32 %10, i32 %11)
%14 = icmp slt i32 %10, %7
br i1 %14, label %9, label %15
15: ; preds = %9, %5
%16 = tail call i32 @putchar(i32 10)
%17 = add i32 %6, 1
%18 = icmp eq i32 %6, %2
br i1 %18, label %19, label %5
19: ; preds = %15, %3
ret void
}