#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 get_int();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int to_sort[5];
  for (int i = 0; i < 5; ++i) {
    to_sort[i] = get_int();
  }
  bool swapped = false;
  do {
    swapped = false;
    for (int i = 0; i < 5 - 1; ++i) {
      if (to_sort[i + 1] < to_sort[i]) {
        int tmp = to_sort[i];
        to_sort[i] = to_sort[i + 1];
        to_sort[i + 1] = tmp;
        swapped = true;
      }
    }
  } while (swapped);
  printf("Print sorted list\n-----------------\n");
  for (int i = 0; i < 5; ++i) {
    printf("%d\n", to_sort[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    115f <main+0x3f>
mov    $0x0,%al
call   1040 <get_int@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1136 <main+0x16>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x4,-0x2c(%rbp)
jge    11e0 <main+0xc0>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%eax
movslq -0x2c(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jge    11cd <main+0xad>
movslq -0x2c(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
movl   $0x1,-0x28(%rbp)
jmp    11d2 <main+0xb2>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1174 <main+0x54>
jmp    11e5 <main+0xc5>
cmpl   $0x0,-0x28(%rbp)
jne    1166 <main+0x46>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1232 <main+0x112>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1204 <main+0xe4>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <get_int@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <get_int@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1050 <get_int@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1050 <get_int@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1050 <get_int@plt>
mov    %ebx,%r8d
mov    %eax,%r15d
nop
mov    %r8d,%eax
mov    %r14d,%ecx
cmp    %r8d,%r14d
mov    %r14d,%edx
cmovl  %r8d,%edx
mov    %r12d,%esi
cmovl  %r14d,%r8d
cmp    %edx,%r12d
mov    %r12d,%edi
cmovl  %edx,%edi
mov    %edx,%r14d
cmovl  %r12d,%r14d
mov    %r13d,%ebp
cmp    %edi,%r13d
cmovl  %edi,%r13d
mov    %r15d,%ebx
mov    %edi,%r12d
cmovl  %ebp,%r12d
cmp    %r13d,%r15d
cmovl  %r13d,%r15d
cmovl  %ebx,%r13d
jl     1170 <main+0x40>
cmp    %edi,%ebp
jl     1170 <main+0x40>
cmp    %edx,%esi
jl     1170 <main+0x40>
cmp    %eax,%ecx
jl     1170 <main+0x40>
lea    0xe39(%rip),%rdi
mov    %r8d,%ebx
call   1030 <puts@plt>
lea    0xe26(%rip),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [36 x i8] c"Print sorted list\0A-----------------\00"
define i32 @main() {
%1 = tail call i32 (...) @get_int()
%2 = tail call i32 (...) @get_int()
%3 = tail call i32 (...) @get_int()
%4 = tail call i32 (...) @get_int()
%5 = tail call i32 (...) @get_int()
br label %6
6: ; preds = %0, %6
%7 = phi i32 [ %5, %0 ], [ %23, %6 ]
%8 = phi i32 [ %4, %0 ], [ %24, %6 ]
%9 = phi i32 [ %3, %0 ], [ %21, %6 ]
%10 = phi i32 [ %2, %0 ], [ %17, %6 ]
%11 = phi i32 [ %1, %0 ], [ %14, %6 ]
%12 = icmp slt i32 %10, %11
%13 = select i1 %12, i32 %11, i32 %10
%14 = select i1 %12, i32 %10, i32 %11
%15 = icmp slt i32 %9, %13
%16 = select i1 %15, i32 %13, i32 %9
%17 = select i1 %15, i32 %9, i32 %13
%18 = or i1 %15, %12
%19 = icmp slt i32 %8, %16
%20 = select i1 %19, i32 %16, i32 %8
%21 = select i1 %19, i32 %8, i32 %16
%22 = icmp slt i32 %7, %20
%23 = select i1 %22, i32 %20, i32 %7
%24 = select i1 %22, i32 %7, i32 %20
%25 = or i1 %22, %19
%26 = select i1 %25, i1 true, i1 %18
br i1 %26, label %6, label %27
27: ; preds = %6
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}