#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*/ Troca(int *, int, int);
void Bubble(int *vet) {
  int i, j;
  for (i = 1; i < 100000; i++)
    for (j = 0; j < (100000 - i); j++)
      if (*(vet + j + 1) < *(vet + j))
        Troca(vet, j, j + 1);
  return;
}


x86 assembly (clang, -O0):
<Bubble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x186a0,-0xc(%rbp)
jge    119f <Bubble+0x8f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x186a0,%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    118c <Bubble+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    0x4(%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1179 <Bubble+0x69>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
call   1030 <Troca@plt>
jmp    117e <Bubble+0x6e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <Bubble+0x27>
jmp    1191 <Bubble+0x81>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <Bubble+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bubble>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%r15d
mov    $0x1869f,%ebp
jmp    1141 <Bubble+0x31>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0xffffffffffffffff,%rbp
cmp    $0x186a0,%r15d
je     1173 <Bubble+0x63>
xor    %ebx,%ebx
jmp    1159 <Bubble+0x49>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1130 <Bubble+0x20>
mov    0x4(%r14,%rbx,4),%eax
cmp    (%r14,%rbx,4),%eax
jge    1150 <Bubble+0x40>
lea    0x1(%rbx),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <Troca@plt>
jmp    1150 <Bubble+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Bubble(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %3
br label %5
5: ; preds = %38, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 100000
br i1 %7, label %8, label %41
8: ; preds = %5
store i32 0, i32* %4
br label %9
9: ; preds = %34, %8
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = sub nsw i32 100000, %11
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %37
14: ; preds = %9
%15 = load i32*, i32** %2
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = load i32, i32* %19
%21 = load i32*, i32** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = icmp slt i32 %20, %25
br i1 %26, label %27, label %33
27: ; preds = %14
%28 = load i32*, i32** %2
%29 = load i32, i32* %4
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
%32 = call i32 @Troca(i32* %28, i32 %29, i32 %31)
br label %33
33: ; preds = %27, %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %9
37: ; preds = %9
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %5
41: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @Bubble(i32* %0) {
br label %2
2: ; preds = %19, %1
%3 = phi i64 [ 99999, %1 ], [ %21, %19 ]
%4 = phi i32 [ 1, %1 ], [ %20, %19 ]
br label %5
5: ; preds = %2, %16
%6 = phi i64 [ 0, %2 ], [ %17, %16 ]
%7 = trunc i64 %6 to i32
%8 = getelementptr inbounds i32, i32* %0, i64 %6
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = load i32, i32* %8
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = add nuw nsw i32 %7, 1
%15 = tail call i32 @Troca(i32* %0, i32 %7, i32 %14)
br label %16
16: ; preds = %5, %13
%17 = add nuw nsw i64 %6, 1
%18 = icmp eq i64 %17, %3
br i1 %18, label %19, label %5
19: ; preds = %16
%20 = add nuw nsw i32 %4, 1
%21 = add nsw i64 %3, -1
%22 = icmp eq i32 %20, 100000
br i1 %22, label %23, label %2
23: ; preds = %19
ret void
}