#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*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ shell_sort(int *, int);
int main(int argc, char *argv[]) {
  int n = 10, i, j;
  int temp = 0, gap = 0;
  int *a;
  a = (int *)malloc((argc - 1) * sizeof(int));
  for (i = 0; i < argc - 1; i++)
    a[i] = atoi(argv[i + 1]);
  for (i = 0; i < argc - 1; i++)
    printf("%d ", a[i]);
  printf("\n");
  shell_sort(a, argc - 1);
  for (i = 0; i < argc - 1; i++)
    printf("%d ", a[i]);
  printf("\n");
  free(a);
}


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)
movl   $0xa,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11db <main+0x8b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atoi@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x49>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    121a <main+0xca>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e2 <main+0x92>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <shell_sort@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1276 <main+0x126>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123e <main+0xee>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%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),%ebx
lea    -0x4(,%r15,4),%edi
ff
call   1060 <malloc@plt>
mov    %rax,%r12
cmp    $0x2,%r15d
jl     1229 <main+0xc9>
mov    %ebx,0x4(%rsp)
mov    %ebx,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%rbp
mov    0x8(%r13,%rbx,8),%rdi
call   1080 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
mov    %rbp,%rbx
cmp    %rbp,%r14
jne    11a0 <main+0x40>
cmp    $0x2,%r15d
mov    0x4(%rsp),%ebx
jl     1229 <main+0xc9>
lea    0xe35(%rip),%r13
xor    %ebp,%ebp
nopl   (%rax)
mov    (%r12,%rbp,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11d0 <main+0x70>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1070 <shell_sort@plt>
cmp    $0x2,%r15d
jl     123d <main+0xdd>
lea    0xdf8(%rip),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r12,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1210 <main+0xb0>
jmp    123d <main+0xdd>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1070 <shell_sort@plt>
mov    $0xa,%edi
call   1040 <putchar@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 = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %6
store i32 0, i32* %9
store i32 0, i32* %10
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %11
store i32 0, i32* %7
br label %19
19: ; preds = %36, %2
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %39
24: ; preds = %19
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %25, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = load i32*, i32** %11
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
store i32 %31, i32* %35
br label %36
36: ; preds = %24
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %19
39: ; preds = %19
store i32 0, i32* %7
br label %40
40: ; preds = %52, %39
%41 = load i32, i32* %7
%42 = load i32, i32* %4
%43 = sub nsw i32 %42, 1
%44 = icmp slt i32 %41, %43
br i1 %44, label %45, label %55
45: ; preds = %40
%46 = load i32*, i32** %11
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %45
%53 = load i32, i32* %7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %7
br label %40
55: ; preds = %40
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32*, i32** %11
%58 = load i32, i32* %4
%59 = sub nsw i32 %58, 1
%60 = call i32 @shell_sort(i32* %57, i32 %59)
store i32 0, i32* %7
br label %61
61: ; preds = %73, %55
%62 = load i32, i32* %7
%63 = load i32, i32* %4
%64 = sub nsw i32 %63, 1
%65 = icmp slt i32 %62, %64
br i1 %65, label %66, label %76
66: ; preds = %61
%67 = load i32*, i32** %11
%68 = load i32, i32* %7
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %7
%75 = add nsw i32 %74, 1
store i32 %75, i32* %7
br label %61
76: ; preds = %61
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%78 = load i32*, i32** %11
%79 = call i32 @free(i32* %78)
%80 = load i32, i32* %3
ret i32 %80
}

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