#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 const *);
int *calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ shellsort(int *, int);
int main(int argc, char const *argv[]) {
  int *nums = calloc(argc - 1, sizeof(int));
  for (int i = 0; i < argc - 1; i++) {
    nums[i] = atoi(argv[i + 1]);
  }
  puts("Your arguments:");
  for (int i = 0; i < argc - 1; i++)
    printf("%d ", nums[i]);
  puts("\n");
  shellsort(nums, argc - 1);
  puts("Your arguments (sorted):");
  for (int i = 0; i < argc - 1; i++)
    printf("%d ", nums[i]);
  free(nums);
  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)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <main+0x31>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121c <main+0xbc>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e6 <main+0x86>
lea    0xdf1(%rip),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1070 <shellsort@plt>
lea    0xdd8(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1280 <main+0x120>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xda3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124a <main+0xea>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r15d
lea    -0x1(%r15),%r14d
mov    %r14d,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r12
cmp    $0x1,%r15d
jle    11f7 <main+0x97>
mov    %r14d,0x4(%rsp)
mov    %r14d,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rbp),%r14
mov    0x8(%r13,%rbp,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r12,%rbp,4)
mov    %r14,%rbp
cmp    %r14,%rbx
jne    11a0 <main+0x40>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r15d
mov    0x4(%rsp),%r14d
jl     1257 <main+0xf7>
xor    %ebp,%ebp
lea    0xe32(%rip),%r13
xchg   %ax,%ax
mov    (%r12,%rbp,4),%esi
mov    %r13,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11e0 <main+0x80>
jmp    1203 <main+0xa3>
lea    0xe02(%rip),%rdi
call   1040 <puts@plt>
lea    0xe0a(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <shellsort@plt>
lea    0xdf5(%rip),%rdi
call   1040 <puts@plt>
cmp    $0x2,%r15d
jl     127a <main+0x11a>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xdd8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,4),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <main+0xe0>
jmp    127a <main+0x11a>
lea    0xdb6(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <shellsort@plt>
lea    0xda1(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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