#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*/ printf(char *, ...);
int main() {
  int teste[10] = {62, 89, 71, 12, 16, 14, 3, 1, 23, 8};
  int aux, min, i, j;
  printf("Desordenado:\n");
  for (i = 0; i < 10; i++)
    printf("T[%d] = %d\n", i, teste[i]);
  for (i = 0; i < 10; i++) {
    min = i;
    for (j = i + 1; j < 10; j++)
      if (teste[j] < teste[min])
        min = j;
    aux = teste[i];
    teste[i] = teste[min];
    teste[min] = aux;
  }
  printf("Ordenado:\n");
  for (i = 0; i < 10; i++)
    printf("T[%d] = %d\n", i, teste[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    118a <main+0x6a>
mov    -0x3c(%rbp),%esi
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1159 <main+0x39>
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    1217 <main+0xf7>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
cmpl   $0xa,-0x40(%rbp)
jge    11e3 <main+0xc3>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
movslq -0x38(%rbp),%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jge    11d0 <main+0xb0>
mov    -0x40(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11d5 <main+0xb5>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11aa <main+0x8a>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x34(%rbp)
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1191 <main+0x71>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0xa,-0x3c(%rbp)
jge    125d <main+0x13d>
mov    -0x3c(%rbp),%esi
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    122c <main+0x10c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xef0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%r14
xor    %r15d,%r15d
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3e,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x59,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x47,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0xc,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x10,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0xe,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x17,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    1251 <main+0x131>
xchg   %ax,%ax
mov    %r15d,%esi
mov    (%rsp,%r15,4),%ecx
movslq %esi,%rdx
mov    (%rsp,%rdx,4),%esi
mov    %esi,(%rsp,%r15,4)
mov    %ecx,(%rsp,%rdx,4)
add    $0x1,%rax
mov    %r8,%r15
cmp    $0xa,%r8
je     128d <main+0x16d>
lea    0x1(%r15),%r8
cmp    $0x8,%r15
ja     1230 <main+0x110>
mov    %rax,%rdx
mov    %r15d,%edi
jmp    127c <main+0x15c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdx
mov    %esi,%edi
cmp    $0xa,%rdx
je     1233 <main+0x113>
mov    (%rsp,%rdx,4),%ecx
movslq %edi,%rbx
mov    %edx,%esi
cmp    (%rsp,%rbx,4),%ecx
jl     1270 <main+0x150>
mov    %edi,%esi
jmp    1270 <main+0x150>
lea    0xdad(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%edx
lea    0xd85(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.teste = [10 x i32] [i32 62, i32 89, i32 71, i32 12, i32 16, i32 14, i32 3, i32 1, i32 23, i32 8]
@.str = [14 x i8] c"Desordenado:\0A\00"
@.str.1 = [12 x i8] c"T[%d] = %d\0A\00"
@.str.2 = [11 x i8] c"Ordenado:\0A\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*
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = load i32, i32* %5
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %17)
br label %19
19: ; preds = %12
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
store i32 0, i32* %5
br label %23
23: ; preds = %65, %22
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %68
26: ; preds = %23
%27 = load i32, i32* %5
store i32 %27, i32* %4
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %30
30: ; preds = %46, %26
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %49
33: ; preds = %30
%34 = load i32, i32* %6
%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
%41 = load i32, i32* %40
%42 = icmp slt i32 %37, %41
br i1 %42, label %43, label %45
43: ; preds = %33
%44 = load i32, i32* %6
store i32 %44, i32* %4
br label %45
45: ; preds = %43, %33
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %30
49: ; preds = %30
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %51
%53 = load i32, i32* %52
store i32 %53, i32* %3
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %59
store i32 %57, i32* %60
%61 = load i32, i32* %3
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %63
store i32 %61, i32* %64
br label %65
65: ; preds = %49
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %23
68: ; preds = %23
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %70
70: ; preds = %80, %68
%71 = load i32, i32* %5
%72 = icmp slt i32 %71, 10
br i1 %72, label %73, label %83
73: ; preds = %70
%74 = load i32, i32* %5
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %76
%78 = load i32, i32* %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %74, i32 %78)
br label %80
80: ; preds = %73
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %70
83: ; preds = %70
ret i32 0
}

LLVM IR (-O2):
@__const.main.teste = [10 x i32] [i32 62, i32 89, i32 71, i32 12, i32 16, i32 14, i32 3, i32 1, i32 23, i32 8]
@.str.1 = [12 x i8] c"T[%d] = %d\0A\00"
@str = [13 x i8] c"Desordenado:\00"
@str.3 = [10 x i8] c"Ordenado:\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 62)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 89)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 71)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 12)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 16)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 14)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 3)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 23)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 8)
br label %14
14: ; preds = %0, %33
%15 = phi i64 [ 0, %0 ], [ %17, %33 ]
%16 = phi i64 [ 1, %0 ], [ %40, %33 ]
%17 = add nuw nsw i64 %15, 1
%18 = icmp ult i64 %15, 9
%19 = trunc i64 %15 to i32
br i1 %18, label %20, label %33
20: ; preds = %14, %20
%21 = phi i64 [ %31, %20 ], [ %16, %14 ]
%22 = phi i32 [ %30, %20 ], [ %19, %14 ]
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %21
%24 = load i32, i32* %23
%25 = sext i32 %22 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = icmp slt i32 %24, %27
%29 = trunc i64 %21 to i32
%30 = select i1 %28, i32 %29, i32 %22
%31 = add nuw nsw i64 %21, 1
%32 = icmp eq i64 %31, 10
br i1 %32, label %33, label %20
33: ; preds = %20, %14
%34 = phi i32 [ %19, %14 ], [ %30, %20 ]
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %15
%36 = load i32, i32* %35
%37 = sext i32 %34 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %37
%39 = load i32, i32* %38
store i32 %39, i32* %35
store i32 %36, i32* %38
%40 = add nuw nsw i64 %16, 1
%41 = icmp eq i64 %17, 10
br i1 %41, label %42, label %14
42: ; preds = %33
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%49 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.3, i64 0, i64 0))
%54 = load i32, i32* %52
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %54)
%56 = load i32, i32* %51
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %56)
%58 = load i32, i32* %50
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %58)
%60 = load i32, i32* %49
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %60)
%62 = load i32, i32* %48
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %62)
%64 = load i32, i32* %47
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %64)
%66 = load i32, i32* %46
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 6, i32 %66)
%68 = load i32, i32* %45
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 7, i32 %68)
%70 = load i32, i32* %44
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 8, i32 %70)
%72 = load i32, i32* %43
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 9, i32 %72)
ret i32 0
}