#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*/ intercambiar(int *, int *);
int burbujaMejorada(int *vector, unsigned int tope, unsigned int *compar,
                    unsigned int *inter) {
  unsigned int vuelta, posicion, desorden = 1;
  *compar = 0;
  *inter = 0;
  for (vuelta = 0; (vuelta < tope) && (desorden == 1); vuelta++) {
    desorden = 0;
    for (posicion = 0; posicion < tope - 1; posicion++) {
      if (vector[posicion] > vector[posicion + 1]) {
        intercambiar(&vector[posicion], &vector[posicion + 1]);
        desorden = 1;
        (*inter)++;
      }
      (*compar)++;
    }
  }
  return vuelta;
}


x86 assembly (clang, -O0):
<burbujaMejorada>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x2d(%rbp)
jae    1164 <burbujaMejorada+0x54>
cmpl   $0x1,-0x2c(%rbp)
sete   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1174 <burbujaMejorada+0x64>
jmp    1216 <burbujaMejorada+0x106>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    1203 <burbujaMejorada+0xf3>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%edx
add    $0x1,%edx
mov    %edx,%edx
cmp    (%rcx,%rdx,4),%eax
jle    11ea <burbujaMejorada+0xda>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <intercambiar@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1182 <burbujaMejorada+0x72>
jmp    1208 <burbujaMejorada+0xf8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1149 <burbujaMejorada+0x39>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<burbujaMejorada>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,(%rdx)
movl   $0x0,(%rcx)
test   %esi,%esi
je     11aa <burbujaMejorada+0x9a>
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %rdi,%rbp
lea    -0x1(%r15),%r12d
add    $0x4,%rbp
xor    %r13d,%r13d
mov    %rbp,0x10(%rsp)
mov    %r12,0x8(%rsp)
nop
test   %r12,%r12
je     11af <burbujaMejorada+0x9f>
xor    %eax,%eax
jmp    116d <burbujaMejorada+0x5d>
nopl   0x0(%rax)
addl   $0x1,(%rbx)
add    $0x4,%rbp
add    $0xffffffffffffffff,%r12
je     1190 <burbujaMejorada+0x80>
mov    -0x4(%rbp),%ecx
cmp    0x0(%rbp),%ecx
jle    1160 <burbujaMejorada+0x50>
lea    -0x4(%rbp),%rdi
mov    %rbp,%rsi
call   1030 <intercambiar@plt>
addl   $0x1,(%r14)
mov    $0x1,%eax
jmp    1160 <burbujaMejorada+0x50>
nopl   0x0(%rax)
add    $0x1,%r13d
cmp    %r15d,%r13d
jae    11b3 <burbujaMejorada+0xa3>
cmp    $0x1,%eax
mov    0x10(%rsp),%rbp
mov    0x8(%rsp),%r12
je     1150 <burbujaMejorada+0x40>
jmp    11b3 <burbujaMejorada+0xa3>
xor    %r13d,%r13d
jmp    11b3 <burbujaMejorada+0xa3>
add    $0x1,%r13d
mov    %r13d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @burbujaMejorada(i32* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 1, i32* %11
%12 = load i32*, i32** %7
store i32 0, i32* %12
%13 = load i32*, i32** %8
store i32 0, i32* %13
store i32 0, i32* %9
br label %14
14: ; preds = %64, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %11
%20 = icmp eq i32 %19, 1
br label %21
21: ; preds = %18, %14
%22 = phi i1 [ false, %14 ], [ %20, %18 ]
br i1 %22, label %23, label %67
23: ; preds = %21
store i32 0, i32* %11
store i32 0, i32* %10
br label %24
24: ; preds = %60, %23
%25 = load i32, i32* %10
%26 = load i32, i32* %6
%27 = sub i32 %26, 1
%28 = icmp ult i32 %25, %27
br i1 %28, label %29, label %63
29: ; preds = %24
%30 = load i32*, i32** %5
%31 = load i32, i32* %10
%32 = zext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32*, i32** %5
%36 = load i32, i32* %10
%37 = add i32 %36, 1
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
%40 = load i32, i32* %39
%41 = icmp sgt i32 %34, %40
br i1 %41, label %42, label %56
42: ; preds = %29
%43 = load i32*, i32** %5
%44 = load i32, i32* %10
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32*, i32** %5
%48 = load i32, i32* %10
%49 = add i32 %48, 1
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %47, i64 %50
%52 = call i32 @intercambiar(i32* %46, i32* %51)
store i32 1, i32* %11
%53 = load i32*, i32** %8
%54 = load i32, i32* %53
%55 = add i32 %54, 1
store i32 %55, i32* %53
br label %56
56: ; preds = %42, %29
%57 = load i32*, i32** %7
%58 = load i32, i32* %57
%59 = add i32 %58, 1
store i32 %59, i32* %57
br label %60
60: ; preds = %56
%61 = load i32, i32* %10
%62 = add i32 %61, 1
store i32 %62, i32* %10
br label %24
63: ; preds = %24
br label %64
64: ; preds = %63
%65 = load i32, i32* %9
%66 = add i32 %65, 1
store i32 %66, i32* %9
br label %14
67: ; preds = %21
%68 = load i32, i32* %9
ret i32 %68
}

LLVM IR (-O2):
define i32 @burbujaMejorada(i32* %0, i32 %1, i32* nocapture %2, i32* nocapture %3) {
store i32 0, i32* %2
store i32 0, i32* %3
%5 = icmp eq i32 %1, 0
br i1 %5, label %37, label %6
6: ; preds = %4
%7 = add i32 %1, -1
%8 = icmp eq i32 %7, 0
%9 = zext i32 %7 to i64
br label %10
10: ; preds = %6, %32
%11 = phi i32 [ 0, %6 ], [ %33, %32 ]
br i1 %8, label %12, label %14
12: ; preds = %10
%13 = add nuw i32 %11, 1
br label %37
14: ; preds = %10, %27
%15 = phi i64 [ %19, %27 ], [ 0, %10 ]
%16 = phi i32 [ %28, %27 ], [ 0, %10 ]
%17 = getelementptr inbounds i32, i32* %0, i64 %15
%18 = load i32, i32* %17
%19 = add nuw nsw i64 %15, 1
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = icmp sgt i32 %18, %21
br i1 %22, label %23, label %27
23: ; preds = %14
%24 = tail call i32 @intercambiar(i32* %17, i32* %20)
%25 = load i32, i32* %3
%26 = add i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %23, %14
%28 = phi i32 [ 1, %23 ], [ %16, %14 ]
%29 = load i32, i32* %2
%30 = add i32 %29, 1
store i32 %30, i32* %2
%31 = icmp eq i64 %19, %9
br i1 %31, label %32, label %14
32: ; preds = %27
%33 = add nuw i32 %11, 1
%34 = icmp ult i32 %33, %1
%35 = icmp eq i32 %28, 1
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %10, label %37
37: ; preds = %32, %12, %4
%38 = phi i32 [ 0, %4 ], [ %13, %12 ], [ %33, %32 ]
ret i32 %38
}