#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*/ is_sorted(int *);
int /*<<< orphan*/ scanf(char *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ swap(int *, int, int);
int main() {
  int arr[5];
  scanf("%d %d %d %d %d", arr, arr + 1, arr + 2, arr + 3, arr + 4);
  while (!is_sorted(arr)) {
    for (int i = 0; i < 4; i++) {
      if (*(arr + i) > *(arr + i + 1))
        swap(arr, i, i + 1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rsi
lea    -0x20(%rbp),%rdx
add    $0x4,%rdx
lea    -0x20(%rbp),%rcx
add    $0x8,%rcx
lea    -0x20(%rbp),%r8
add    $0xc,%r8
lea    -0x20(%rbp),%r9
add    $0x10,%r9
lea    0xe96(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <is_sorted@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118d <main+0x5d>
jmp    11de <main+0xae>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11d9 <main+0xa9>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
movslq -0x24(%rbp),%rcx
cmp    -0x1c(%rbp,%rcx,4),%eax
jle    11c6 <main+0x96>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
call   1050 <swap@plt>
jmp    11cb <main+0x9b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <main+0x64>
jmp    116f <main+0x3f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x10(%rsp),%r9
lea    0xeb0(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
call   1030 <is_sorted@plt>
test   %eax,%eax
je     116f <main+0x3f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    %rsp,%rbx
jmp    118c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1030 <is_sorted@plt>
test   %eax,%eax
jne    1167 <main+0x37>
mov    0x4(%rsp),%eax
cmp    %eax,(%rsp)
jle    11a8 <main+0x78>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <swap@plt>
mov    0x4(%rsp),%eax
mov    0x8(%rsp),%ecx
cmp    %ecx,%eax
jle    11c6 <main+0x96>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1050 <swap@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%ecx
jle    11e4 <main+0xb4>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1050 <swap@plt>
mov    0xc(%rsp),%eax
cmp    0x10(%rsp),%eax
jle    1180 <main+0x50>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1050 <swap@plt>
jmp    1180 <main+0x50>

LLVM IR (-O0):
@.str = [15 x i8] c"%d %d %d %d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%8 = getelementptr inbounds i32, i32* %7, i64 2
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds i32, i32* %9, i64 3
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%12 = getelementptr inbounds i32, i32* %11, i64 4
%13 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %6, i32* %8, i32* %10, i32* %12)
br label %14
14: ; preds = %46, %0
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%16 = call i32 @is_sorted(i32* %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %47
19: ; preds = %14
store i32 0, i32* %3
br label %20
20: ; preds = %43, %19
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = getelementptr inbounds i32, i32* %32, i64 1
%34 = load i32, i32* %33
%35 = icmp sgt i32 %28, %34
br i1 %35, label %36, label %42
36: ; preds = %23
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%38 = load i32, i32* %3
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
%41 = call i32 @swap(i32* %37, i32 %38, i32 %40)
br label %42
42: ; preds = %36, %23
br label %43
43: ; preds = %42
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %20
46: ; preds = %20
br label %14
47: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d %d %d %d %d\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%8 = call i32 @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6, i32* %7)
%9 = call i32 @is_sorted(i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %46
11: ; preds = %0
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
br label %16
16: ; preds = %11, %43
%17 = load i32, i32* %3
%18 = load i32, i32* %12
%19 = icmp sgt i32 %17, %18
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @swap(i32* %3, i32 0, i32 1)
%22 = load i32, i32* %4
br label %23
23: ; preds = %16, %20
%24 = phi i32 [ %18, %16 ], [ %22, %20 ]
%25 = load i32, i32* %13
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 @swap(i32* %3, i32 1, i32 2)
%29 = load i32, i32* %5
br label %30
30: ; preds = %27, %23
%31 = phi i32 [ %29, %27 ], [ %25, %23 ]
%32 = load i32, i32* %14
%33 = icmp sgt i32 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = call i32 @swap(i32* %3, i32 2, i32 3)
%36 = load i32, i32* %6
br label %37
37: ; preds = %34, %30
%38 = phi i32 [ %36, %34 ], [ %32, %30 ]
%39 = load i32, i32* %15
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @swap(i32* %3, i32 3, i32 4)
br label %43
43: ; preds = %41, %37
%44 = call i32 @is_sorted(i32* %3)
%45 = icmp eq i32 %44, 0
br i1 %45, label %16, label %46
46: ; preds = %43, %0
ret i32 0
}