#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 temporal;
  int iteracion = 1;
  for (i = 2; i < 10; i++) {
    j = i - 1;
    while ((j >= 1) && (arreglo[j] > arreglo[j + 1])) {
      temporal = arreglo[j + 1];
      arreglo[j + 1] = arreglo[j];
      arreglo[j] = temporal;
      j--;
      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,-0x40(%rbp)
movl   $0x2,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    121e <main+0xee>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x38(%rbp)
mov    %al,-0x41(%rbp)
jl     119f <main+0x6f>
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
setg   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11af <main+0x7f>
jmp    120b <main+0xdb>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x3c(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
mov    -0x38(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x40(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
jmp    1175 <main+0x45>
jmp    1210 <main+0xe0>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1162 <main+0x32>
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    $0x28,%rsp
mov    0xeeb(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x1,%r13d
lea    0xeca(%rip),%r14
mov    %rsp,%r15
mov    $0x1,%esi
jmp    117a <main+0x5a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x9,%r13d
je     11c6 <main+0xa6>
lea    (%rsi,%r13,1),%r12d
mov    %r13d,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
add    $0x1,%eax
mov    (%rsp,%rbp,4),%ecx
mov    (%rsp,%rax,4),%edx
cmp    %edx,%ecx
jle    1170 <main+0x50>
mov    %ecx,(%rsp,%rax,4)
mov    %edx,(%rsp,%rbp,4)
lea    0x1(%rsi),%ebx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
call   1040 <imprimir_arreglo@plt>
mov    %ebx,%esi
add    $0xffffffff,%ebp
mov    %ebp,%eax
jne    1190 <main+0x70>
mov    %r12d,%esi
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x28,%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
store i32 0, i32* %1
%7 = bitcast [10 x i32]* %2 to i8*
store i32 1, i32* %6
store i32 2, i32* %3
br label %8
8: ; preds = %56, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %59
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %4
br label %14
14: ; preds = %30, %11
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 1
br i1 %16, label %17, label %28
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 label %28
28: ; preds = %17, %14
%29 = phi i1 [ false, %14 ], [ %27, %17 ]
br i1 %29, label %30, label %55
30: ; preds = %28
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %33
%35 = load i32, i32* %34
store i32 %35, i32* %5
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %42
store i32 %39, i32* %43
%44 = load i32, i32* %5
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %46
store i32 %44, i32* %47
%48 = load i32, i32* %4
%49 = add nsw i32 %48, -1
store i32 %49, i32* %4
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %50)
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%54 = call i32 @imprimir_arreglo(i32* %53)
br label %14
55: ; preds = %28
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %8
59: ; preds = %8
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, %25
%5 = phi i32 [ 1, %0 ], [ %28, %25 ]
%6 = phi i32 [ 1, %0 ], [ %26, %25 ]
%7 = phi i32 [ 2, %0 ], [ %27, %25 ]
%8 = add i32 %6, %5
br label %9
9: ; preds = %4, %20
%10 = phi i32 [ %6, %4 ], [ %21, %20 ]
%11 = phi i32 [ %7, %4 ], [ %12, %20 ]
%12 = add nsw i32 %11, -1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = zext i32 %11 to i64
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = icmp sgt i32 %15, %18
br i1 %19, label %20, label %25
20: ; preds = %9
store i32 %15, i32* %17
store i32 %18, i32* %14
%21 = add i32 %10, 1
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %10)
%23 = call i32 @imprimir_arreglo(i32* %3)
%24 = icmp eq i32 %21, %8
br i1 %24, label %25, label %9
25: ; preds = %9, %20
%26 = phi i32 [ %10, %9 ], [ %8, %20 ]
%27 = add nuw nsw i32 %7, 1
%28 = add nuw nsw i32 %5, 1
%29 = icmp eq i32 %28, 9
br i1 %29, label %30, label %4
30: ; preds = %25
ret i32 0
}