#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
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    120c <combination_sort+0xec>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    -0x38(%rbp),%ecx
cmp    %ecx,%eax
jge    11f9 <combination_sort+0xd9>
mov    -0x8(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   $0x16,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x16,%rax,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jge    11e6 <combination_sort+0xc6>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x34(%rbp),%rax
imul   $0x16,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
movslq -0x34(%rbp),%rax
imul   $0x16,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x16,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x16,%rax,%rax
add    %rax,%rdi
lea    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11eb <combination_sort+0xcb>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1149 <combination_sort+0x29>
jmp    11fe <combination_sort+0xde>
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    11f3 <combination_sort+0xd3>
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    116b <combination_sort+0x4b>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    0x10(%rsp),%r13
je     11f3 <combination_sort+0xd3>
lea    0x0(,%r13,4),%rax
add    %r13,%rax
lea    0x0(,%rax,4),%rax
add    %r13,%rax
add    %r13,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,1),%rbx
add    $0x1,%r13
lea    (%rcx,%rax,1),%rbp
add    $0x16,%rbp
mov    0xc(%rsp),%eax
mov    %eax,%r15d
xor    %r14d,%r14d
jmp    11c0 <combination_sort+0xa0>
cs nopw 0x0(%rax,%rax,1)
nop
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   %rax,%rax
jns    11b0 <combination_sort+0x90>
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    11b0 <combination_sort+0x90>
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 = %66, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %69
12: ; preds = %8
store i32 0, i32* %7
br label %13
13: ; preds = %62, %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 %65
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 = load [22 x i8]*, [22 x i8]** %3
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [22 x i8], [22 x i8]* %25, i64 %28
%30 = getelementptr inbounds [22 x i8], [22 x i8]* %29, i64 0, i64 0
%31 = call i64 @strcmp(i8* %24, i8* %30)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %61
33: ; preds = %19
%34 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%35 = load [22 x i8]*, [22 x i8]** %3
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [22 x i8], [22 x i8]* %35, i64 %37
%39 = getelementptr inbounds [22 x i8], [22 x i8]* %38, i64 0, i64 0
%40 = call i32 @strcpy(i8* %34, i8* %39)
%41 = load [22 x i8]*, [22 x i8]** %3
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [22 x i8], [22 x i8]* %41, i64 %43
%45 = getelementptr inbounds [22 x i8], [22 x i8]* %44, i64 0, i64 0
%46 = load [22 x i8]*, [22 x i8]** %3
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [22 x i8], [22 x i8]* %46, i64 %49
%51 = getelementptr inbounds [22 x i8], [22 x i8]* %50, i64 0, i64 0
%52 = call i32 @strcpy(i8* %45, i8* %51)
%53 = load [22 x i8]*, [22 x i8]** %3
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [22 x i8], [22 x i8]* %53, i64 %56
%58 = getelementptr inbounds [22 x i8], [22 x i8]* %57, i64 0, i64 0
%59 = getelementptr inbounds [22 x i8], [22 x i8]* %5, i64 0, i64 0
%60 = call i32 @strcpy(i8* %58, i8* %59)
br label %61
61: ; preds = %33, %19
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %13
65: ; preds = %13
br label %66
66: ; preds = %65
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %8
69: ; 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 %27
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %25, %6
%9 = phi i64 [ 0, %6 ], [ %11, %25 ]
%10 = getelementptr inbounds [22 x i8], [22 x i8]* %0, i64 %9, i64 0
%11 = add nuw nsw i64 %9, 1
%12 = getelementptr inbounds [22 x i8], [22 x i8]* %0, i64 %11, i64 0
br label %13
13: ; preds = %8, %21
%14 = phi i32 [ 0, %8 ], [ %22, %21 ]
%15 = call i64 @strcmp(i8* %10, i8* %12)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = call i32 @strcpy(i8* %4, i8* %10)
%19 = call i32 @strcpy(i8* %10, i8* %12)
%20 = call i32 @strcpy(i8* %12, i8* %4)
br label %21
21: ; preds = %13, %17
%22 = add nuw nsw i32 %14, 1
%23 = sub nsw i32 %1, %22
%24 = icmp slt i32 %22, %23
br i1 %24, label %13, label %25
25: ; preds = %21
%26 = icmp eq i64 %11, %7
br i1 %26, label %27, label %8
27: ; preds = %25, %2
ret void
}