#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*/ printf(char *, ...);
int Sort(int argc, char **argv) {
  short k;
  printf("%s:\n", argv[0]);
  for (k = 1; k < argc; ++k)
    printf("\targv[%d] = %s\n", k, argv[k]);
  printf("Sort \n");
  return (0);
}


x86 assembly (clang, -O0):
<Sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x1,-0x12(%rbp)
movswl -0x12(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1177 <Sort+0x67>
movswl -0x12(%rbp),%esi
mov    -0x10(%rbp),%rax
movswq -0x12(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    113a <Sort+0x2a>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rsi
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%ebp
jl     116d <Sort+0x4d>
mov    $0x1,%eax
lea    0xeb7(%rip),%r14
xchg   %ax,%ax
movslq %eax,%rbx
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
movswl %bx,%eax
cmp    %ebp,%eax
jl     1150 <Sort+0x30>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [16 x i8] c"\09argv[%d] = %s\0A\00"
@.str.2 = [7 x i8] c"Sort \0A\00"
define i32 @Sort(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i16
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %4
%7 = getelementptr inbounds i8*, i8** %6, i64 0
%8 = load i8*, i8** %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
store i16 1, i16* %5
br label %10
10: ; preds = %24, %2
%11 = load i16, i16* %5
%12 = sext i16 %11 to i32
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %10
%16 = load i16, i16* %5
%17 = sext i16 %16 to i32
%18 = load i8**, i8*** %4
%19 = load i16, i16* %5
%20 = sext i16 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %22)
br label %24
24: ; preds = %15
%25 = load i16, i16* %5
%26 = add i16 %25, 1
store i16 %26, i16* %5
br label %10
27: ; preds = %10
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [16 x i8] c"\09argv[%d] = %s\0A\00"
@str = [6 x i8] c"Sort \00"
define i32 @Sort(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %16
6: ; preds = %2, %6
%7 = phi i32 [ %14, %6 ], [ 1, %2 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %7, i8* %10)
%12 = shl nsw i32 %7, 16
%13 = add i32 %12, 65536
%14 = ashr exact i32 %13, 16
%15 = icmp slt i32 %14, %0
br i1 %15, label %6, label %16
16: ; preds = %6, %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret i32 0
}