#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;
  do {
    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);
    }
  } while ((i < 10) && (ordenado));
  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)
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     1211 <main+0xe1>
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    11e3 <main+0xb3>
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    0xe33(%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    1180 <main+0x50>
jmp    1216 <main+0xe6>
xor    %eax,%eax
cmpl   $0xa,-0x34(%rbp)
mov    %al,-0x45(%rbp)
jge    122f <main+0xff>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    1169 <main+0x39>
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)
mov    $0x1,%ebx
mov    $0x9,%r12d
lea    0xec4(%rip),%r14
lea    0x10(%rsp),%r15
mov    $0x1,%eax
xchg   %ax,%ax
mov    %rax,0x8(%rsp)
add    $0x1,%eax
mov    %eax,0x4(%rsp)
mov    %ebx,%ebx
xor    %eax,%eax
xor    %r13d,%r13d
jmp    11a8 <main+0x88>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
call   1040 <imprimir_arreglo@plt>
mov    %rbp,%rax
cmp    %rbp,%r12
je     11d0 <main+0xb0>
lea    (%rbx,%rax,1),%rsi
mov    0x10(%rsp,%rax,4),%ecx
mov    0x14(%rsp,%rax,4),%edx
lea    0x1(%rax),%rbp
cmp    %edx,%ecx
jle    1190 <main+0x70>
mov    %edx,0x10(%rsp,%rax,4)
mov    %ecx,0x14(%rsp,%rax,4)
mov    $0x1,%r13d
jmp    1190 <main+0x70>
nopl   0x0(%rax)
cmpl   $0x8,0x8(%rsp)
ja     11e6 <main+0xc6>
add    $0xffffffffffffffff,%r12
add    %ebp,%ebx
mov    0x4(%rsp),%eax
test   %r13d,%r13d
jne    1170 <main+0x50>
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
br label %9
9: ; preds = %62, %0
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
store i32 0, i32* %5
store i32 0, i32* %4
br label %12
12: ; preds = %52, %9
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = sub nsw i32 10, %14
%16 = icmp sle i32 %13, %15
br i1 %16, label %17, label %55
17: ; preds = %12
%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
store i32 1, i32* %5
%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* %7
%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* %7
%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* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
%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 %12
55: ; preds = %12
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = icmp slt i32 %57, 10
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %5
%61 = icmp ne i32 %60, 0
br label %62
62: ; preds = %59, %56
%63 = phi i1 [ false, %56 ], [ %61, %59 ]
br i1 %63, label %9, label %64
64: ; preds = %62
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
br label %4
4: ; preds = %0, %26
%5 = phi i64 [ %30, %26 ], [ 9, %0 ]
%6 = phi i32 [ %22, %26 ], [ 1, %0 ]
%7 = phi i32 [ %8, %26 ], [ 1, %0 ]
%8 = add nuw nsw i32 %7, 1
br label %9
9: ; preds = %4, %20
%10 = phi i64 [ 0, %4 ], [ %15, %20 ]
%11 = phi i32 [ %6, %4 ], [ %22, %20 ]
%12 = phi i32 [ 0, %4 ], [ %21, %20 ]
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %10
%14 = load i32, i32* %13
%15 = add nuw nsw i64 %10, 1
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp sgt i32 %14, %17
br i1 %18, label %19, label %20
19: ; preds = %9
store i32 %17, i32* %13
store i32 %14, i32* %16
br label %20
20: ; preds = %19, %9
%21 = phi i32 [ 1, %19 ], [ %12, %9 ]
%22 = add nsw i32 %11, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %11)
%24 = call i32 @imprimir_arreglo(i32* %3)
%25 = icmp eq i64 %15, %5
br i1 %25, label %26, label %9
26: ; preds = %20
%27 = icmp ult i32 %7, 9
%28 = icmp ne i32 %21, 0
%29 = select i1 %27, i1 %28, i1 false
%30 = add nsw i64 %5, -1
br i1 %29, label %4, label %31
31: ; preds = %26
ret i32 0
}