#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;
  int j;
  int iteracion = 1;
  imprimir_arreglo(arreglo);
  for (i = 0; i < 10; i++) {
    for (j = 0; j <= 8; j++) {
      if (arreglo[j] > arreglo[j + 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    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1210 <main+0xe0>
movl   $0x0,-0x38(%rbp)
cmpl   $0x8,-0x38(%rbp)
jg     11fd <main+0xcd>
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    11cf <main+0x9f>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x40(%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    -0x40(%rbp),%ecx
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    0xe47(%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    117c <main+0x4c>
jmp    1202 <main+0xd2>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116b <main+0x3b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0xeee(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    $0x1,%r12d
lea    0xec2(%rip),%r15
jmp    1193 <main+0x73>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
add    $0x2,%ebx
cmp    $0x52,%r12d
mov    %ebx,%r12d
je     12f6 <main+0x1d6>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jle    11a5 <main+0x85>
mov    %ecx,(%rsp)
mov    %eax,0x4(%rsp)
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x4(%rsp),%eax
mov    0x8(%rsp),%ecx
cmp    %ecx,%eax
jle    11cc <main+0xac>
mov    %ecx,0x4(%rsp)
mov    %eax,0x8(%rsp)
lea    0x1(%r12),%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    %ecx,%eax
jle    11f7 <main+0xd7>
mov    %ecx,0x8(%rsp)
mov    %eax,0xc(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%ecx
cmp    %ecx,%eax
jle    1220 <main+0x100>
mov    %ecx,0xc(%rsp)
mov    %eax,0x10(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%ecx
cmp    %ecx,%eax
jle    1249 <main+0x129>
mov    %ecx,0x10(%rsp)
mov    %eax,0x14(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x14(%rsp),%eax
mov    0x18(%rsp),%ecx
cmp    %ecx,%eax
jle    1272 <main+0x152>
mov    %ecx,0x14(%rsp)
mov    %eax,0x18(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x18(%rsp),%eax
mov    0x1c(%rsp),%ecx
cmp    %ecx,%eax
jle    129b <main+0x17b>
mov    %ecx,0x18(%rsp)
mov    %eax,0x1c(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x1c(%rsp),%eax
mov    0x20(%rsp),%ecx
cmp    %ecx,%eax
jle    12c4 <main+0x1a4>
mov    %ecx,0x1c(%rsp)
mov    %eax,0x20(%rsp)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
call   1040 <imprimir_arreglo@plt>
mov    0x20(%rsp),%eax
mov    0x24(%rsp),%ecx
cmp    %ecx,%eax
jle    1170 <main+0x50>
mov    %ecx,0x20(%rsp)
mov    %eax,0x24(%rsp)
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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
store i32 0, i32* %1
%7 = bitcast [10 x i32]* %2 to i8*
store i32 1, i32* %5
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = call i32 @imprimir_arreglo(i32* %8)
store i32 0, i32* %3
br label %10
10: ; preds = %56, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %59
13: ; preds = %10
store i32 0, i32* %4
br label %14
14: ; preds = %52, %13
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 8
br i1 %16, label %17, label %55
17: ; preds = %14
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp sgt i32 %21, %26
br i1 %27, label %28, label %46
28: ; preds = %17
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %6
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %39
store i32 %37, i32* %40
%41 = load i32, i32* %6
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %44
store i32 %41, i32* %45
br label %46
46: ; preds = %28, %17
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
%49 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %47)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%51 = call i32 @imprimir_arreglo(i32* %50)
br label %52
52: ; preds = %46
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
br label %14
55: ; preds = %14
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %10
59: ; preds = %10
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)
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
br label %14
14: ; preds = %0, %85
%15 = phi i32 [ 0, %0 ], [ %89, %85 ]
%16 = phi i32 [ 1, %0 ], [ %86, %85 ]
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 %18, i32* %3
store i32 %17, i32* %5
br label %21
21: ; preds = %20, %14
%22 = add nuw nsw i32 %16, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %16)
%24 = call i32 @imprimir_arreglo(i32* %3)
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %21
store i32 %26, i32* %5
store i32 %25, i32* %6
br label %29
29: ; preds = %28, %21
%30 = add nuw nsw i32 %16, 2
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %22)
%32 = call i32 @imprimir_arreglo(i32* %3)
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %29
store i32 %34, i32* %6
store i32 %33, i32* %7
br label %37
37: ; preds = %36, %29
%38 = add nuw nsw i32 %16, 3
%39 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %30)
%40 = call i32 @imprimir_arreglo(i32* %3)
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %37
store i32 %42, i32* %7
store i32 %41, i32* %8
br label %45
45: ; preds = %44, %37
%46 = add nuw nsw i32 %16, 4
%47 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %38)
%48 = call i32 @imprimir_arreglo(i32* %3)
%49 = load i32, i32* %8
%50 = load i32, i32* %9
%51 = icmp sgt i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %45
store i32 %50, i32* %8
store i32 %49, i32* %9
br label %53
53: ; preds = %52, %45
%54 = add nuw nsw i32 %16, 5
%55 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %46)
%56 = call i32 @imprimir_arreglo(i32* %3)
%57 = load i32, i32* %9
%58 = load i32, i32* %10
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %61
60: ; preds = %53
store i32 %58, i32* %9
store i32 %57, i32* %10
br label %61
61: ; preds = %60, %53
%62 = add nuw nsw i32 %16, 6
%63 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %54)
%64 = call i32 @imprimir_arreglo(i32* %3)
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = icmp sgt i32 %65, %66
br i1 %67, label %68, label %69
68: ; preds = %61
store i32 %66, i32* %10
store i32 %65, i32* %11
br label %69
69: ; preds = %68, %61
%70 = add nuw nsw i32 %16, 7
%71 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %62)
%72 = call i32 @imprimir_arreglo(i32* %3)
%73 = load i32, i32* %11
%74 = load i32, i32* %12
%75 = icmp sgt i32 %73, %74
br i1 %75, label %76, label %77
76: ; preds = %69
store i32 %74, i32* %11
store i32 %73, i32* %12
br label %77
77: ; preds = %76, %69
%78 = add nuw nsw i32 %16, 8
%79 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %70)
%80 = call i32 @imprimir_arreglo(i32* %3)
%81 = load i32, i32* %12
%82 = load i32, i32* %13
%83 = icmp sgt i32 %81, %82
br i1 %83, label %84, label %85
84: ; preds = %77
store i32 %82, i32* %12
store i32 %81, i32* %13
br label %85
85: ; preds = %84, %77
%86 = add nuw nsw i32 %16, 9
%87 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %78)
%88 = call i32 @imprimir_arreglo(i32* %3)
%89 = add nuw nsw i32 %15, 1
%90 = icmp eq i32 %89, 10
br i1 %90, label %91, label %14
91: ; preds = %85
ret i32 0
}