#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 max_index(int *, int);
int poramni(int);
int /*<<< orphan*/ print_arr(int *, int);
scalar_t__ scanf(char *, int *);
int /*<<< orphan*/ sort_asc(int *, int);
int main() {
  int x, k, n, max_i;
  int a[5];
  n = 0;
  while (scanf("%d", &x)) {
    k = poramni(x);
    if (n >= 5) {
      max_i = max_index(a, 5);
      if (a[max_i] > k) {
        a[max_i] = k;
      }
    } else {
      a[n] = k;
      n++;
    }
  }
  sort_asc(a, n);
  print_arr(a, n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     11e0 <main+0x90>
mov    -0x8(%rbp),%edi
call   1060 <poramni@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x5,-0x10(%rbp)
jl     11c7 <main+0x77>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1070 <max_index@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0xc(%rbp),%eax
jle    11c2 <main+0x72>
mov    -0xc(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11db <main+0x8b>
mov    -0xc(%rbp),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <main+0x16>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <sort_asc@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <print_arr@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xe9d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11d5 <main+0x85>
lea    0x10(%rsp),%r14
lea    0xe80(%rip),%r15
lea    0xc(%rsp),%r12
jmp    11aa <main+0x5a>
nopw   0x0(%rax,%rax,1)
movslq %ebx,%rax
mov    %ebp,0x10(%rsp,%rax,4)
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
test   %rax,%rax
je     11d5 <main+0x85>
mov    0xc(%rsp),%edi
call   1060 <poramni@plt>
mov    %eax,%ebp
cmp    $0x5,%ebx
jl     1190 <main+0x40>
mov    %r14,%rdi
mov    $0x5,%esi
call   1070 <max_index@plt>
cltq
cmp    %ebp,0x10(%rsp,%rax,4)
jle    119a <main+0x4a>
mov    %ebp,0x10(%rsp,%rax,4)
jmp    119a <main+0x4a>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <sort_asc@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1040 <print_arr@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %0
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
br label %9
9: ; preds = %7, %25
%10 = phi i32 [ 0, %7 ], [ %26, %25 ]
%11 = load i32, i32* %1
%12 = call i32 @poramni(i32 %11)
%13 = icmp sgt i32 %10, 4
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = call i32 @max_index(i32* %8, i32 5)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, %12
br i1 %19, label %20, label %25
20: ; preds = %14
store i32 %12, i32* %17
br label %25
21: ; preds = %9
%22 = sext i32 %10 to i64
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %22
store i32 %12, i32* %23
%24 = add nsw i32 %10, 1
br label %25
25: ; preds = %14, %20, %21
%26 = phi i32 [ %10, %20 ], [ %10, %14 ], [ %24, %21 ]
%27 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %9
29: ; preds = %25, %0
%30 = phi i32 [ 0, %0 ], [ %26, %25 ]
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%32 = call i32 @sort_asc(i32* %31, i32 %30)
%33 = call i32 @print_arr(i32* %31, i32 %30)
ret i32 0
}