#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;
  for (i = 0; i < 9; i++) {
    printf("Iteracion #%03d ", iteracion++);
    int minimo = i;
    for (j = i + 1; j < 10; j++) {
      if (arreglo[j] < arreglo[i]) {
        minimo = j;
      }
    }
    int aux = arreglo[i];
    arreglo[i] = arreglo[minimo];
    arreglo[minimo] = aux;
    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,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jge    1208 <main+0xd8>
mov    -0x3c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    11cb <main+0x9b>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11b8 <main+0x88>
mov    -0x38(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11bd <main+0x8d>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1192 <main+0x62>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x44(%rbp)
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x34(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x44(%rbp),%ecx
movslq -0x40(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
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,%r12d
xor    %r13d,%r13d
lea    0xec7(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rbx
add    $0x1,%r12
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0x1(%r13),%rbp
mov    (%rsp,%r13,4),%eax
mov    %r13d,%ecx
nopl   0x0(%rax)
cmp    %eax,(%rsp,%rbx,4)
cmovl  %ebx,%ecx
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    1190 <main+0x70>
movslq %ecx,%rcx
mov    (%rsp,%rcx,4),%edx
mov    %edx,(%rsp,%r13,4)
mov    %eax,(%rsp,%rcx,4)
mov    %r15,%rdi
call   1040 <imprimir_arreglo@plt>
mov    %rbp,%r13
cmp    $0x9,%rbp
jne    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
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [10 x i32]* %2 to i8*
store i32 1, i32* %5
store i32 0, i32* %3
br label %9
9: ; preds = %56, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %59
12: ; preds = %9
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 1
store i32 %14, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %13)
%16 = load i32, i32* %3
store i32 %16, i32* %6
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %35, %12
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 10
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = load i32, i32* %4
%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 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp slt i32 %26, %30
br i1 %31, label %32, label %34
32: ; preds = %22
%33 = load i32, i32* %4
store i32 %33, i32* %6
br label %34
34: ; preds = %32, %22
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %19
38: ; preds = %19
%39 = load i32, i32* %3
%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* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %48
store i32 %46, i32* %49
%50 = load i32, i32* %7
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %52
store i32 %50, i32* %53
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%55 = call i32 @imprimir_arreglo(i32* %54)
br label %56
56: ; preds = %38
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %9
59: ; preds = %9
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 = %24, %0
%5 = phi i64 [ 0, %0 ], [ %10, %24 ]
%6 = phi i64 [ 1, %0 ], [ %8, %24 ]
%7 = trunc i64 %6 to i32
%8 = add nuw nsw i64 %6, 1
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
%10 = add nuw nsw i64 %5, 1
%11 = trunc i64 %5 to i32
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %5
%13 = load i32, i32* %12
br label %14
14: ; preds = %4, %14
%15 = phi i64 [ %6, %4 ], [ %22, %14 ]
%16 = phi i32 [ %11, %4 ], [ %21, %14 ]
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %15
%18 = load i32, i32* %17
%19 = icmp slt i32 %18, %13
%20 = trunc i64 %15 to i32
%21 = select i1 %19, i32 %20, i32 %16
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, 10
br i1 %23, label %24, label %14
24: ; preds = %14
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %5
%26 = sext i32 %21 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %25
store i32 %13, i32* %27
%29 = call i32 @imprimir_arreglo(i32* %3)
%30 = icmp eq i64 %10, 9
br i1 %30, label %31, label %4
31: ; preds = %24
ret i32 0
}