#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*/ imprime(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ swap(int *, int *);
int main(void) {
  int array[10] = {2, 6, 4, 8, 10, 12, 89, 68, 45, 37};
  int size = 10;
  for (int pass = 0; pass < size - 1; pass++) {
    for (int j = 0; j < size - 1; j++) {
      if (array[j] > array[j + 1])
        swap(&array[j], &array[j + 1]);
      imprime(array, size);
    }
    printf("--- Nova iteração ---\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0xa,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1211 <main+0xd1>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f7 <main+0xb7>
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    -0x30(%rbp,%rcx,4),%eax
jle    11dd <main+0x9d>
movslq -0x3c(%rbp),%rax
lea    -0x30(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cltq
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1060 <swap@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <imprime@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    118a <main+0x4a>
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1172 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x40,%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    0xedb(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xebf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x14(%rsp),%rbp
lea    0x18(%rsp),%r14
lea    0x1c(%rsp),%r15
mov    $0x2,%eax
mov    $0x6,%ecx
mov    $0x8,%ebx
mov    %rsp,%r12
lea    0xe9f(%rip),%r13
cmp    %ecx,%eax
jle    119d <main+0x6d>
nopl   (%rax)
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x4(%rsp),%eax
cmp    0x8(%rsp),%eax
jle    11c3 <main+0x93>
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x8(%rsp),%eax
cmp    0xc(%rsp),%eax
jle    11e9 <main+0xb9>
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0xc(%rsp),%eax
cmp    0x10(%rsp),%eax
jle    120f <main+0xdf>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x10(%rsp),%eax
cmp    0x14(%rsp),%eax
jle    1233 <main+0x103>
lea    0x10(%rsp),%rdi
mov    %rbp,%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x14(%rsp),%eax
cmp    0x18(%rsp),%eax
jle    1255 <main+0x125>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x18(%rsp),%eax
cmp    0x1c(%rsp),%eax
jle    1277 <main+0x147>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x1c(%rsp),%eax
cmp    0x20(%rsp),%eax
jle    129b <main+0x16b>
mov    %r15,%rdi
lea    0x20(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    0x20(%rsp),%eax
cmp    0x24(%rsp),%eax
jle    12c1 <main+0x191>
lea    0x20(%rsp),%rdi
lea    0x24(%rsp),%rsi
call   1050 <swap@plt>
mov    %r12,%rdi
mov    $0xa,%esi
call   1040 <imprime@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
sub    $0x1,%ebx
jb     12ef <main+0x1bf>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jg     1190 <main+0x60>
jmp    119d <main+0x6d>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.array = [10 x i32] [i32 2, i32 6, i32 4, i32 8, i32 10, i32 12, i32 89, i32 68, i32 45, i32 37]
@.str = [25 x i8] c"--- Nova itera\C3\A7\C3\A3o ---\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
store i32 10, i32* %3
store i32 0, i32* %4
br label %7
7: ; preds = %47, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %50
12: ; preds = %7
store i32 0, i32* %5
br label %13
13: ; preds = %42, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %45
18: ; preds = %13
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %22, %27
br i1 %28, label %29, label %38
29: ; preds = %18
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %5
%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 = call i32 @swap(i32* %32, i32* %36)
br label %38
38: ; preds = %29, %18
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%40 = load i32, i32* %3
%41 = call i32 @imprime(i32* %39, i32 %40)
br label %42
42: ; preds = %38
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %13
45: ; preds = %13
%46 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %47
47: ; preds = %45
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %7
50: ; preds = %7
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@__const.main.array = [10 x i32] [i32 2, i32 6, i32 4, i32 8, i32 10, i32 12, i32 89, i32 68, i32 45, i32 37]
@str = [24 x i8] c"--- Nova itera\C3\A7\C3\A3o ---\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 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
br label %13
13: ; preds = %82, %0
%14 = phi i32 [ 6, %0 ], [ %84, %82 ]
%15 = phi i32 [ 2, %0 ], [ %83, %82 ]
%16 = phi i32 [ 0, %0 ], [ %80, %82 ]
%17 = icmp sgt i32 %15, %14
br i1 %17, label %19, label %21
18: ; preds = %77
ret i32 0
19: ; preds = %13
%20 = call i32 @swap(i32* %3, i32* %4)
br label %21
21: ; preds = %19, %13
%22 = call i32 @imprime(i32* %3, i32 10)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = icmp sgt i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @swap(i32* %4, i32* %5)
br label %28
28: ; preds = %26, %21
%29 = call i32 @imprime(i32* %3, i32 10)
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @swap(i32* %5, i32* %6)
br label %35
35: ; preds = %33, %28
%36 = call i32 @imprime(i32* %3, i32 10)
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sgt i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @swap(i32* %6, i32* %7)
br label %42
42: ; preds = %40, %35
%43 = call i32 @imprime(i32* %3, i32 10)
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = icmp sgt i32 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @swap(i32* %7, i32* %8)
br label %49
49: ; preds = %47, %42
%50 = call i32 @imprime(i32* %3, i32 10)
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @swap(i32* %8, i32* %9)
br label %56
56: ; preds = %54, %49
%57 = call i32 @imprime(i32* %3, i32 10)
%58 = load i32, i32* %9
%59 = load i32, i32* %10
%60 = icmp sgt i32 %58, %59
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @swap(i32* %9, i32* %10)
br label %63
63: ; preds = %61, %56
%64 = call i32 @imprime(i32* %3, i32 10)
%65 = load i32, i32* %10
%66 = load i32, i32* %11
%67 = icmp sgt i32 %65, %66
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 @swap(i32* %10, i32* %11)
br label %70
70: ; preds = %68, %63
%71 = call i32 @imprime(i32* %3, i32 10)
%72 = load i32, i32* %11
%73 = load i32, i32* %12
%74 = icmp sgt i32 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 @swap(i32* %11, i32* %12)
br label %77
77: ; preds = %75, %70
%78 = call i32 @imprime(i32* %3, i32 10)
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%80 = add nuw nsw i32 %16, 1
%81 = icmp eq i32 %80, 9
br i1 %81, label %18, label %82
82: ; preds = %77
%83 = load i32, i32* %3
%84 = load i32, i32* %4
br label %13
}