void combination_sort(char *combinations[512][22], int variation_number) {
  char temp[22];
  int i, j;
  for (i = 0; i < variation_number; i++) {
    for (j = 0; j < variation_number - j; j++) {
      if (strcmp(combinations[i], combinations[i + 1]) < 0) {
        strcpy(temp, combinations[i]);
        strcpy(combinations[i], combinations[i + 1]);
        strcpy(combinations[i + 1], temp);
      }
    }
  }
}


x86 assembly (clang, -O0):
<combination_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    121d <combination_sort+0xfd>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    120a <combination_sort+0xea>
mov    -0x8(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   $0xb0,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0xb0,%rax,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jge    11f7 <combination_sort+0xd7>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x34(%rbp),%rax
imul   $0xb0,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   $0xb0,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0xb0,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0xb0,%rax,%rax
add    %rax,%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11fc <combination_sort+0xdc>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1149 <combination_sort+0x29>
jmp    120f <combination_sort+0xef>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <combination_sort+0x16>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<combination_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x18(%rsp)
test   %esi,%esi
jle    11e2 <combination_sort+0xc2>
mov    %esi,%eax
mov    %esi,%ecx
mov    %rcx,0x10(%rsp)
add    $0xffffffff,%eax
mov    %eax,0xc(%rsp)
xor    %r13d,%r13d
lea    0x20(%rsp),%r12
jmp    1167 <combination_sort+0x47>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    0x10(%rsp),%r13
je     11e2 <combination_sort+0xc2>
imul   $0xb0,%r13,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,1),%rbx
add    $0x1,%r13
lea    (%rcx,%rax,1),%rbp
add    $0xb0,%rbp
mov    0xc(%rsp),%eax
mov    %eax,%r15d
xor    %r14d,%r14d
jmp    11b0 <combination_sort+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14d
lea    -0x1(%r15),%eax
cmp    %r15d,%r14d
mov    %eax,%r15d
jge    1160 <combination_sort+0x40>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jns    11a0 <combination_sort+0x80>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
jmp    11a0 <combination_sort+0x80>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @combination_sort([22 x i8*]* %0, i32 %1) {
%3 = alloca [22 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %29
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %27, %6
%9 = phi i64 [ 0, %6 ], [ %12, %27 ]
%10 = getelementptr inbounds [22 x i8*], [22 x i8*]* %0, i64 %9, i64 0
%11 = bitcast i8** %10 to i8*
%12 = add nuw nsw i64 %9, 1
%13 = getelementptr inbounds [22 x i8*], [22 x i8*]* %0, i64 %12, i64 0
%14 = bitcast i8** %13 to i8*
br label %15
15: ; preds = %8, %23
%16 = phi i32 [ 0, %8 ], [ %24, %23 ]
%17 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* %14)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %11)
%21 = call i8* @strcpy(i8* dereferenceable(1) %11, i8* %14)
%22 = call i8* @strcpy(i8* %14, i8* %4)
br label %23
23: ; preds = %15, %19
%24 = add nuw nsw i32 %16, 1
%25 = sub nsw i32 %1, %24
%26 = icmp slt i32 %24, %25
br i1 %26, label %15, label %27
27: ; preds = %23
%28 = icmp eq i64 %12, %7
br i1 %28, label %29, label %8
29: ; preds = %27, %2
ret void
}