#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*/ imprimir_arreglo(int *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int main() {
  int arreglo[10] = {1, 4, 20, 10, 3, 8, 9, 14, 21, 6};
  int i = 1;
  int j;
  int ordenado = 1;
  int iteracion = 1;
  imprimir_arreglo(arreglo);
  while ((ordenado) && (i < 10)) {
    i++;
    ordenado = 0;
    for (j = 0; j <= 10 - i; j++) {
      if (arreglo[j] > arreglo[j + 1]) {
        ordenado = 1;
        int aux = arreglo[j];
        arreglo[j] = arreglo[j + 1];
        arreglo[j + 1] = aux;
      }
      printf("Iteracion #%03d ", iteracion++);
      imprimir_arreglo(arreglo);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x34(%rbp)
movl   $0x1,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
xor    %eax,%eax
cmpl   $0x0,-0x3c(%rbp)
mov    %al,-0x45(%rbp)
je     118b <main+0x5b>
cmpl   $0xa,-0x34(%rbp)
setl   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    119b <main+0x6b>
jmp    1248 <main+0x118>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    $0xa,%ecx
sub    -0x34(%rbp),%ecx
cmp    %ecx,%eax
jg     1243 <main+0x113>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x38(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    1215 <main+0xe5>
movl   $0x1,-0x3c(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x44(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x44(%rbp),%ecx
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b2 <main+0x82>
jmp    1172 <main+0x42>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0xeeb(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    $0x1,%eax
mov    $0x9,%ebx
lea    0xeb8(%rip),%r15
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
lea    0x1(%rcx),%eax
mov    %eax,0x4(%rsp)
mov    %ebp,%ebp
xor    %eax,%eax
xor    %r13d,%r13d
jmp    11b8 <main+0x98>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    %r12,%rax
cmp    %r12,%rbx
je     11e0 <main+0xc0>
lea    (%rax,%rbp,1),%rsi
mov    0x10(%rsp,%rax,4),%ecx
mov    0x14(%rsp,%rax,4),%edx
lea    0x1(%rax),%r12
cmp    %edx,%ecx
jle    11a0 <main+0x80>
mov    %edx,0x10(%rsp,%rax,4)
mov    %ecx,0x14(%rsp,%rax,4)
mov    $0x1,%r13d
jmp    11a0 <main+0x80>
nopl   0x0(%rax)
test   %r13d,%r13d
mov    0x4(%rsp),%eax
je     11f7 <main+0xd7>
add    $0xffffffffffffffff,%rbx
add    %r12d,%ebp
cmpl   $0x8,0x8(%rsp)
jbe    1180 <main+0x60>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.arreglo = [10 x i32] [i32 1, i32 4, i32 20, i32 10, i32 3, i32 8, i32 9, i32 14, i32 21, i32 6]
@.str = [17 x i8] c"Iteracion #%03d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [10 x i32]* %2 to i8*
store i32 1, i32* %3
store i32 1, i32* %5
store i32 1, i32* %6
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = call i32 @imprimir_arreglo(i32* %9)
br label %11
11: ; preds = %65, %0
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 10
br label %17
17: ; preds = %14, %11
%18 = phi i1 [ false, %11 ], [ %16, %14 ]
br i1 %18, label %19, label %66
19: ; preds = %17
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
store i32 0, i32* %5
store i32 0, i32* %4
br label %22
22: ; preds = %62, %19
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = sub nsw i32 10, %24
%26 = icmp sle i32 %23, %25
br i1 %26, label %27, label %65
27: ; preds = %22
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp sgt i32 %31, %36
br i1 %37, label %38, label %56
38: ; preds = %27
store i32 1, i32* %5
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
store i32 %42, i32* %7
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %49
store i32 %47, i32* %50
%51 = load i32, i32* %7
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %54
store i32 %51, i32* %55
br label %56
56: ; preds = %38, %27
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
%59 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %57)
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%61 = call i32 @imprimir_arreglo(i32* %60)
br label %62
62: ; preds = %56
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %22
65: ; preds = %22
br label %11
66: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@__const.main.arreglo = [10 x i32] [i32 1, i32 4, i32 20, i32 10, i32 3, i32 8, i32 9, i32 14, i32 21, i32 6]
@.str = [17 x i8] c"Iteracion #%03d \00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i32 @imprimir_arreglo(i32* %3)
br label %10
5: ; preds = %26
%6 = icmp ne i32 %27, 0
%7 = icmp ult i32 %12, 9
%8 = select i1 %6, i1 %7, i1 false
%9 = add nsw i64 %11, -1
br i1 %8, label %10, label %32
10: ; preds = %5, %0
%11 = phi i64 [ 9, %0 ], [ %9, %5 ]
%12 = phi i32 [ 1, %0 ], [ %14, %5 ]
%13 = phi i32 [ 1, %0 ], [ %28, %5 ]
%14 = add nuw nsw i32 %12, 1
br label %15
15: ; preds = %10, %26
%16 = phi i64 [ 0, %10 ], [ %21, %26 ]
%17 = phi i32 [ %13, %10 ], [ %28, %26 ]
%18 = phi i32 [ 0, %10 ], [ %27, %26 ]
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
%20 = load i32, i32* %19
%21 = add nuw nsw i64 %16, 1
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp sgt i32 %20, %23
br i1 %24, label %25, label %26
25: ; preds = %15
store i32 %23, i32* %19
store i32 %20, i32* %22
br label %26
26: ; preds = %25, %15
%27 = phi i32 [ 1, %25 ], [ %18, %15 ]
%28 = add nsw i32 %17, 1
%29 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %17)
%30 = call i32 @imprimir_arreglo(i32* %3)
%31 = icmp eq i64 %21, %11
br i1 %31, label %5, label %15
32: ; preds = %5
ret i32 0
}