#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 *);
scalar_t__ calloc(size_t, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ isort(int *, size_t);
int /*<<< orphan*/ printArray(int *, size_t);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("isort : Usage is 'isort [array]'\n");
    return 1;
  }
  size_t size = argc - 1;
  int *array = (int *)calloc(size, sizeof(int));
  for (size_t i = 0; i < size; i++)
    array[i] = atoi(argv[i + 1]);
  printf("Array before sorting :-\n");
  printArray(array, size);
  isort(array, size);
  printf("\nArray after sorting :-\n");
  printArray(array, size);
  free(array);
  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    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124b <main+0xeb>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11fc <main+0x9c>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    0x8(%rax,%rcx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11be <main+0x5e>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <printArray@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <isort@plt>
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <printArray@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
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
cmp    $0x1,%edi
jg     1181 <main+0x21>
lea    0xebb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    11fd <main+0x9d>
mov    %rsi,%r12
mov    %edi,%r14d
add    $0xffffffff,%r14d
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopl   (%rax)
lea    0x1(%rbx),%r13
mov    0x8(%r12,%rbx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r15,%rbx,4)
mov    %r13,%rbx
cmp    %r13,%r14
jne    11a0 <main+0x40>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <printArray@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <isort@plt>
lea    0xe35(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <printArray@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"isort : Usage is 'isort [array]'\0A\00"
@.str.1 = [25 x i8] c"Array before sorting :-\0A\00"
@.str.2 = [25 x i8] c"\0AArray after sorting :-\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%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 %13
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %51
13: ; preds = %2
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = call i64 @calloc(i64 %17, i32 4)
%19 = inttoptr i64 %18 to i32*
store i32* %19, i32** %7
store i64 0, i64* %8
br label %20
20: ; preds = %34, %13
%21 = load i64, i64* %8
%22 = load i64, i64* %6
%23 = icmp ult i64 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = load i64, i64* %8
%27 = add i64 %26, 1
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
%31 = load i32*, i32** %7
%32 = load i64, i64* %8
%33 = getelementptr inbounds i32, i32* %31, i64 %32
store i32 %30, i32* %33
br label %34
34: ; preds = %24
%35 = load i64, i64* %8
%36 = add i64 %35, 1
store i64 %36, i64* %8
br label %20
37: ; preds = %20
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32*, i32** %7
%40 = load i64, i64* %6
%41 = call i32 @printArray(i32* %39, i64 %40)
%42 = load i32*, i32** %7
%43 = load i64, i64* %6
%44 = call i32 @isort(i32* %42, i64 %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32*, i32** %7
%47 = load i64, i64* %6
%48 = call i32 @printArray(i32* %46, i64 %47)
%49 = load i32*, i32** %7
%50 = call i32 @free(i32* %49)
store i32 0, i32* %3
br label %51
51: ; preds = %37, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@str = [24 x i8] c"Array before sorting :-\00"
@str.3 = [24 x i8] c"\0AArray after sorting :-\00"
@str.4 = [33 x i8] c"isort : Usage is 'isort [array]'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.4, i64 0, i64 0))
br label %26
6: ; preds = %2
%7 = add nsw i32 %0, -1
%8 = zext i32 %7 to i64
%9 = tail call i64 @calloc(i64 %8, i32 4)
%10 = inttoptr i64 %9 to i32*
br label %18
11: ; preds = %18
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @printArray(i32* %10, i64 %8)
%14 = tail call i32 @isort(i32* %10, i64 %8)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
%16 = tail call i32 @printArray(i32* %10, i64 %8)
%17 = tail call i32 @free(i32* %10)
br label %26
18: ; preds = %6, %18
%19 = phi i64 [ %20, %18 ], [ 0, %6 ]
%20 = add nuw nsw i64 %19, 1
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i32, i32* %10, i64 %19
store i32 %23, i32* %24
%25 = icmp eq i64 %20, %8
br i1 %25, label %11, label %18
26: ; preds = %11, %4
%27 = phi i32 [ 1, %4 ], [ 0, %11 ]
ret i32 %27
}