#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 EOF;
int getchar();
int /*<<< orphan*/ insertionSort(unsigned char *, unsigned int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
scalar_t__ processParam(int, char **);
int main(int argc, char *argv[]) {
  static unsigned char buf[64];
  unsigned char *pBuf = buf;
  int c;
  unsigned int numElements = 0;
  unsigned int i;
  if (processParam(argc, argv)) {
    return 1;
  }
  while ((c = getchar()) != EOF) {
    if ((c != '\r') && (c != '\n')) {
      *pBuf++ = (unsigned char)c;
      numElements++;
      if (numElements >= 64) {
        break;
      }
    }
  }
  insertionSort(&buf[0], numElements);
  pBuf = buf;
  for (i = 0; i < numElements; i++) {
    printf("%c\n", *pBuf++);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0x2ef3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <processParam@plt>
cmp    $0x0,%rax
je     118a <main+0x4a>
movl   $0x1,-0x4(%rbp)
jmp    1254 <main+0x114>
jmp    118f <main+0x4f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%eax
je     11f4 <main+0xb4>
cmpl   $0xd,-0x1c(%rbp)
je     11ef <main+0xaf>
cmpl   $0xa,-0x1c(%rbp)
je     11ef <main+0xaf>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x40,-0x20(%rbp)
jb     11ea <main+0xaa>
jmp    11f4 <main+0xb4>
jmp    11ef <main+0xaf>
jmp    118f <main+0x4f>
mov    -0x20(%rbp),%esi
lea    0x2e52(%rip),%rdi
call   1050 <insertionSort@plt>
lea    0x2e46(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    124d <main+0x10d>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movzbl (%rax),%esi
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1215 <main+0xd5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
call   1060 <processParam@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    1226 <main+0xe6>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e7d(%rip),%r14
cmp    (%r14),%eax
jne    1186 <main+0x46>
lea    0x2ed9(%rip),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
call   1050 <insertionSort@plt>
jmp    1226 <main+0xe6>
lea    0x2ec3(%rip),%r15
xor    %r13d,%r13d
jmp    11ac <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     11c9 <main+0x89>
cmp    $0xa,%eax
je     11a0 <main+0x60>
cmp    $0xd,%eax
je     11a0 <main+0x60>
mov    %al,(%r15)
add    $0x1,%r13d
cmp    $0x40,%r13d
jae    11e2 <main+0xa2>
add    $0x1,%r15
jmp    11a0 <main+0x60>
lea    0x2e80(%rip),%rdi
mov    %r13d,%esi
call   1050 <insertionSort@plt>
test   %r13d,%r13d
jne    11f1 <main+0xb1>
xor    %r14d,%r14d
jmp    1226 <main+0xe6>
lea    0x2e67(%rip),%rdi
mov    %r13d,%esi
call   1050 <insertionSort@plt>
add    $0xffffffff,%r13d
add    $0x1,%r13
xor    %r14d,%r14d
lea    0x2e4d(%rip),%r12
lea    0xdf6(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%rbx,%r12,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1210 <main+0xd0>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@main.buf = internal global [64 x i8] zeroinitializer
@EOF = global i32 0
@.str = [4 x i8] c"%c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i8** %6
store i32 0, i32* %8
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i64 @processParam(i32 %10, i8** %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %55
15: ; preds = %2
br label %16
16: ; preds = %37, %15
%17 = call i32 (...) @getchar()
store i32 %17, i32* %7
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %38
20: ; preds = %16
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 13
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = load i32, i32* %7
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %6
store i8 %28, i8* %29
%31 = load i32, i32* %8
%32 = add i32 %31, 1
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp uge i32 %33, 64
br i1 %34, label %35, label %36
35: ; preds = %26
br label %38
36: ; preds = %26
br label %37
37: ; preds = %36, %23, %20
br label %16
38: ; preds = %35, %16
%39 = load i32, i32* %8
%40 = call i32 @insertionSort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i32 %39)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i8** %6
store i32 0, i32* %9
br label %41
41: ; preds = %51, %38
%42 = load i32, i32* %9
%43 = load i32, i32* %8
%44 = icmp ult i32 %42, %43
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i8*, i8** %6
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %6
%48 = load i8, i8* %46
%49 = zext i8 %48 to i32
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %49)
br label %51
51: ; preds = %45
%52 = load i32, i32* %9
%53 = add i32 %52, 1
store i32 %53, i32* %9
br label %41
54: ; preds = %41
store i32 0, i32* %3
br label %55
55: ; preds = %54, %14
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@main.buf = internal global [64 x i8] zeroinitializer
@EOF = global i32 0
@.str = [4 x i8] c"%c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 @processParam(i32 %0, i8** %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %43
5: ; preds = %2
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @insertionSort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i32 0)
br label %43
11: ; preds = %5, %22
%12 = phi i32 [ %25, %22 ], [ %6, %5 ]
%13 = phi i32 [ %24, %22 ], [ 0, %5 ]
%14 = phi i8* [ %23, %22 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), %5 ]
switch i32 %12, label %15 [
i32 13, label %22
i32 10, label %22
]
15: ; preds = %11
%16 = trunc i32 %12 to i8
%17 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %16, i8* %14
%18 = add i32 %13, 1
%19 = icmp ugt i32 %18, 63
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @insertionSort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i32 %18)
br label %31
22: ; preds = %11, %11, %15
%23 = phi i8* [ %17, %15 ], [ %14, %11 ], [ %14, %11 ]
%24 = phi i32 [ %18, %15 ], [ %13, %11 ], [ %13, %11 ]
%25 = tail call i32 (...) @getchar()
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %11
28: ; preds = %22
%29 = tail call i32 @insertionSort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), i32 %24)
%30 = icmp eq i32 %24, 0
br i1 %30, label %43, label %31
31: ; preds = %20, %28
%32 = phi i32 [ %18, %20 ], [ %24, %28 ]
%33 = add i32 %32, -1
%34 = zext i32 %33 to i64
%35 = getelementptr [64 x i8], [64 x i8]* @main.buf, i64 0, i64 %34
br label %36
36: ; preds = %31, %36
%37 = phi i8* [ %38, %36 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @main.buf, i64 0, i64 0), %31 ]
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %37
%40 = zext i8 %39 to i32
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = icmp eq i8* %37, %35
br i1 %42, label %43, label %36
43: ; preds = %36, %9, %28, %2
%44 = phi i32 [ 1, %2 ], [ 0, %28 ], [ 0, %9 ], [ 0, %36 ]
ret i32 %44
}