#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ selection_sort(int *, int);
int main(int argc, char *argv[]) {
  int a[10];
  int i;
  if (argc <= 1) {
    printf("Usage: %s <int1> <int2> ...\n", argv[0]);
    return -1;
  }
  for (i = 0; i < (argc - 1); i++) {
    a[i] = atoi(argv[i + 1]);
  }
  for (i = 0; i < (argc - 1); i++) {
    printf("%d\n", a[i]);
  }
  selection_sort(a, argc - 1);
  for (i = 0; i < (argc - 1); i++) {
    printf("%d\n", a[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <main+0x115>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1178 <main+0x48>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f3 <main+0xc3>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11be <main+0x8e>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <selection_sort@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    123e <main+0x10e>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1209 <main+0xd9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r15
cmp    $0x2,%edi
jge    1161 <main+0x31>
mov    (%r15),%rsi
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%r15d
jmp    1206 <main+0xd6>
mov    %edi,%r14d
lea    -0x1(%r14),%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%r13
mov    0x8(%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,(%rsp,%rbx,4)
mov    %r13,%rbx
cmp    %r13,%r12
jne    1170 <main+0x40>
cmp    $0x1,%r14d
jle    11f8 <main+0xc8>
lea    0xe87(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11a0 <main+0x70>
mov    %rsp,%rdi
mov    %r12d,%esi
call   1030 <selection_sort@plt>
xor    %r15d,%r15d
cmp    $0x2,%r14d
jl     1206 <main+0xd6>
xor    %r15d,%r15d
lea    0xe49(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <main+0xb0>
jmp    1206 <main+0xd6>
mov    %rsp,%rdi
mov    %r12d,%esi
call   1030 <selection_sort@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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