#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*/ assert(int);
int /*<<< orphan*/ bubble_a(long *, int);
int /*<<< orphan*/ bubble_p(long *, int);
int main(int argc, char *argv[]) {
  long data4a[4] = {1, 4, 3, 2};
  long data4p[4] = {4, 2, 1, 3};
  bubble_a(data4a, 4);
  bubble_p(data4p, 4);
  for (int i = 0; i < 4; i++) {
    assert(data4a[i] == data4p[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1030 <bubble_a@plt>
lea    -0x50(%rbp),%rdi
mov    $0x4,%esi
call   1050 <bubble_p@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x4,-0x54(%rbp)
jge    11f8 <main+0xc8>
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
movslq -0x54(%rbp),%rcx
cmp    -0x50(%rbp,%rcx,8),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c1 <main+0x91>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x4,%esi
call   1030 <bubble_a@plt>
mov    %rsp,%rdi
mov    $0x4,%esi
call   1050 <bubble_p@plt>
mov    0x20(%rsp),%rax
xor    %edi,%edi
cmp    (%rsp),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x28(%rsp),%rax
xor    %edi,%edi
cmp    0x8(%rsp),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x30(%rsp),%rax
xor    %edi,%edi
cmp    0x10(%rsp),%rax
sete   %dil
call   1040 <assert@plt>
mov    0x38(%rsp),%rax
xor    %edi,%edi
cmp    0x18(%rsp),%rax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@__const.main.data4a = [4 x i64] [i64 1, i64 4, i64 3, i64 2]
@__const.main.data4p = [4 x i64] [i64 4, i64 2, i64 1, i64 3]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i64]
%7 = alloca [4 x i64]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [4 x i64]* %6 to i8*
%10 = bitcast [4 x i64]* %7 to i8*
%11 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 0
%12 = call i32 @bubble_a(i64* %11, i32 4)
%13 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 0
%14 = call i32 @bubble_p(i64* %13, i32 4)
store i32 0, i32* %8
br label %15
15: ; preds = %30, %2
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i64], [4 x i64]* %6, i64 0, i64 %20
%22 = load i64, i64* %21
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 %24
%26 = load i64, i64* %25
%27 = icmp eq i64 %22, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
br label %30
30: ; preds = %18
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %15
33: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@__const.main.data4a = [4 x i64] [i64 1, i64 4, i64 3, i64 2]
@__const.main.data4p = [4 x i64] [i64 4, i64 2, i64 1, i64 3]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i64]
%4 = alloca [4 x i64]
%5 = bitcast [4 x i64]* %3 to i8*
%6 = bitcast [4 x i64]* %4 to i8*
%7 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 0
%8 = call i32 @bubble_a(i64* %7, i32 4)
%9 = getelementptr inbounds [4 x i64], [4 x i64]* %4, i64 0, i64 0
%10 = call i32 @bubble_p(i64* %9, i32 4)
%11 = load i64, i64* %7
%12 = load i64, i64* %9
%13 = icmp eq i64 %11, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 1
%17 = load i64, i64* %16
%18 = getelementptr inbounds [4 x i64], [4 x i64]* %4, i64 0, i64 1
%19 = load i64, i64* %18
%20 = icmp eq i64 %17, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 2
%24 = load i64, i64* %23
%25 = getelementptr inbounds [4 x i64], [4 x i64]* %4, i64 0, i64 2
%26 = load i64, i64* %25
%27 = icmp eq i64 %24, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 3
%31 = load i64, i64* %30
%32 = getelementptr inbounds [4 x i64], [4 x i64]* %4, i64 0, i64 3
%33 = load i64, i64* %32
%34 = icmp eq i64 %31, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
ret i32 0
}