#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*/ _IONBF;
int atoi(char *);
int *ecalloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ slsort(int *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int *arr, i;
  size_t len;
  if (argc < 2) {
    fprintf(stderr, "usage: num ...\n");
    exit(1);
  }
  arr = ecalloc(argc - 1, sizeof(*arr));
  len = 0;
  for (i = 1; i < argc; i++) {
    arr[i - 1] = atoi(argv[i]);
    len++;
  }
  setvbuf(stdout, NULL, _IONBF, 0);
  if (slsort(arr, len) < 0)
    fprintf(stderr, "failed to allocate memory for sleepsort\n");
  free(arr);
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11af <main+0x3f>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    $0x4,%esi
call   1040 <ecalloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121b <main+0xab>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d2 <main+0x62>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <slsort@plt>
cmp    $0x0,%rax
jge    1264 <main+0xf4>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x1,%edi
jle    121f <main+0xaf>
mov    %rsi,%r13
mov    %edi,%r12d
lea    -0x1(%r12),%edi
mov    $0x4,%esi
call   1040 <ecalloc@plt>
mov    %rax,%r15
lea    -0x2(%r12),%r14d
mov    %r12d,%r12d
add    $0xffffffffffffffff,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x8(%r13,%rbx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <main+0x40>
add    $0x1,%r14
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <slsort@plt>
test   %rax,%rax
jns    120b <main+0x9b>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"usage: num ...\0A\00"
@stdout = global i32 0
@_IONBF = global i32 0
@.str.1 = [41 x i8] c"failed to allocate memory for sleepsort\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = call i32* @ecalloc(i32 %17, i32 4)
store i32* %18, i32** %6
store i64 0, i64* %8
store i32 1, i32* %7
br label %19
19: ; preds = %37, %15
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %40
23: ; preds = %19
%24 = load i8**, i8*** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
%30 = load i32*, i32** %6
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %30, i64 %33
store i32 %29, i32* %34
%35 = load i64, i64* %8
%36 = add i64 %35, 1
store i64 %36, i64* %8
br label %37
37: ; preds = %23
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %19
40: ; preds = %19
%41 = load i32, i32* @stdout
%42 = load i32, i32* @_IONBF
%43 = call i32 @setvbuf(i32 %41, i32* null, i32 %42, i32 0)
%44 = load i32*, i32** %6
%45 = load i64, i64* %8
%46 = call i64 @slsort(i32* %44, i64 %45)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %51
51: ; preds = %48, %40
%52 = load i32*, i32** %6
%53 = call i32 @free(i32* %52)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"usage: num ...\0A\00"
@stdout = global i32 0
@_IONBF = global i32 0
@.str.1 = [41 x i8] c"failed to allocate memory for sleepsort\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = add nsw i32 %0, -1
%10 = tail call i32* @ecalloc(i32 %9, i32 4)
%11 = add nsw i32 %0, -2
%12 = zext i32 %11 to i64
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %8, %14
%15 = phi i64 [ 1, %8 ], [ %21, %14 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = add nsw i64 %15, -1
%20 = getelementptr inbounds i32, i32* %10, i64 %19
store i32 %18, i32* %20
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, %13
br i1 %22, label %23, label %14
23: ; preds = %14
%24 = add nuw nsw i64 %12, 1
%25 = load i32, i32* @stdout
%26 = load i32, i32* @_IONBF
%27 = tail call i32 @setvbuf(i32 %25, i32* null, i32 %26, i32 0)
%28 = tail call i64 @slsort(i32* %10, i64 %24)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %30, %23
%34 = tail call i32 @free(i32* %10)
ret i32 0
}