int *TranspositionGetSequence(int key_columns) {
  int *key_seq = malloc((key_columns) * sizeof(int));
  if (!key_seq)
    exit(1);
  int i, j;
  for (i = 0; i < key_columns; ++i) {
    scanf("%d", &key_seq[i]);
    for (j = i - 1; j >= 0; --j)
      if (key_seq[i] == key_seq[j]) {
        printf("Double entry, please re-enter!\n");
        --i;
        break;
      }
  }
  for (i = 0; i < key_columns; ++i)
    if (key_seq[i] < 1 || key_seq[i] > key_columns) {
      printf("Row sequence out of bounds...quiting\n");
      exit(1);
    }
  return (key_seq);
}


x86 assembly (clang, -O0):
<TranspositionGetSequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1171 <TranspositionGetSequence+0x31>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1212 <TranspositionGetSequence+0xd2>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11ff <TranspositionGetSequence+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    11ec <TranspositionGetSequence+0xac>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <TranspositionGetSequence+0xbf>
jmp    11f1 <TranspositionGetSequence+0xb1>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11aa <TranspositionGetSequence+0x6a>
jmp    1204 <TranspositionGetSequence+0xc4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1178 <TranspositionGetSequence+0x38>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1276 <TranspositionGetSequence+0x136>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jl     124b <TranspositionGetSequence+0x10b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x4(%rbp),%eax
jle    1263 <TranspositionGetSequence+0x123>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1268 <TranspositionGetSequence+0x128>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1219 <TranspositionGetSequence+0xd9>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TranspositionGetSequence>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
movslq %edi,%rdi
shl    $0x2,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     1203 <TranspositionGetSequence+0xc3>
mov    %rax,%rbx
test   %r12d,%r12d
jle    11e5 <TranspositionGetSequence+0xa5>
lea    0xe8e(%rip),%r14
xor    %r13d,%r13d
jmp    1189 <TranspositionGetSequence+0x49>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    %r12d,%r13d
jge    11c6 <TranspositionGetSequence+0x86>
movslq %r13d,%r15
lea    (%rbx,%r15,4),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15d,%eax
test   %eax,%eax
jle    1180 <TranspositionGetSequence+0x40>
mov    0x0(%rbp),%ecx
lea    -0x1(%rax),%rdx
cmp    -0x4(%rbx,%rax,4),%ecx
mov    %rdx,%rax
jne    11a0 <TranspositionGetSequence+0x60>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
add    $0xffffffff,%r13d
jmp    1180 <TranspositionGetSequence+0x40>
test   %r12d,%r12d
jle    11e5 <TranspositionGetSequence+0xa5>
mov    %r12d,%eax
xor    %ecx,%ecx
mov    (%rbx,%rcx,4),%edx
test   %edx,%edx
jle    11f7 <TranspositionGetSequence+0xb7>
cmp    %r12d,%edx
jg     11f7 <TranspositionGetSequence+0xb7>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    11d0 <TranspositionGetSequence+0x90>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [32 x i8] c"Double entry, please re-enter!\0A\00"
@.str.2 = [38 x i8] c"Row sequence out of bounds...quiting\0A\00"
define i32* @TranspositionGetSequence(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 %7, 4
%9 = call i8* @malloc(i64 %8)
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp ne i32* %11, null
br i1 %12, label %14, label %13
13: ; preds = %1
unreachable
14: ; preds = %1
store i32 0, i32* %4
br label %15
15: ; preds = %51, %14
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %54
19: ; preds = %15
%20 = load i32*, i32** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %4
%26 = sub nsw i32 %25, 1
store i32 %26, i32* %5
br label %27
27: ; preds = %47, %19
%28 = load i32, i32* %5
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %50
30: ; preds = %27
%31 = load i32*, i32** %3
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %35, %40
br i1 %41, label %42, label %46
42: ; preds = %30
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
br label %50
46: ; preds = %30
br label %47
47: ; preds = %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, -1
store i32 %49, i32* %5
br label %27
50: ; preds = %42, %27
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %15
54: ; preds = %15
store i32 0, i32* %4
br label %55
55: ; preds = %77, %54
%56 = load i32, i32* %4
%57 = load i32, i32* %2
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %80
59: ; preds = %55
%60 = load i32*, i32** %3
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
%64 = load i32, i32* %63
%65 = icmp slt i32 %64, 1
br i1 %65, label %74, label %66
66: ; preds = %59
%67 = load i32*, i32** %3
%68 = load i32, i32* %4
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = load i32, i32* %2
%73 = icmp sgt i32 %71, %72
br i1 %73, label %74, label %76
74: ; preds = %66, %59
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
unreachable
76: ; preds = %66
br label %77
77: ; preds = %76
%78 = load i32, i32* %4
%79 = add nsw i32 %78, 1
store i32 %79, i32* %4
br label %55
80: ; preds = %55
%81 = load i32*, i32** %3
ret i32* %81
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [37 x i8] c"Row sequence out of bounds...quiting\00"
@str.3 = [31 x i8] c"Double entry, please re-enter!\00"
define i32* @TranspositionGetSequence(i32 %0) {
%2 = sext i32 %0 to i64
%3 = shl nsw i64 %2, 2
%4 = tail call i8* @malloc(i64 %3)
%5 = bitcast i8* %4 to i32*
%6 = icmp eq i8* %4, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = icmp sgt i32 %0, 0
br i1 %8, label %13, label %48
9: ; preds = %1
tail call void @exit(i32 1)
unreachable
10: ; preds = %32
br i1 %8, label %11, label %48
11: ; preds = %10
%12 = zext i32 %0 to i64
br label %38
13: ; preds = %7, %32
%14 = phi i32 [ %34, %32 ], [ 0, %7 ]
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %5, i64 %15
%17 = tail call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %16)
%18 = zext i32 %14 to i64
br label %19
19: ; preds = %24, %13
%20 = phi i64 [ %21, %24 ], [ %18, %13 ]
%21 = add nsw i64 %20, -1
%22 = trunc i64 %20 to i32
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i32, i32* %16
%26 = getelementptr inbounds i32, i32* %5, i64 %21
%27 = load i32, i32* %26
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %19
29: ; preds = %24
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.3, i64 0, i64 0))
%31 = add nsw i32 %14, -1
br label %32
32: ; preds = %19, %29
%33 = phi i32 [ %31, %29 ], [ %14, %19 ]
%34 = add nsw i32 %33, 1
%35 = icmp slt i32 %34, %0
br i1 %35, label %13, label %10
36: ; preds = %38
%37 = icmp eq i64 %45, %12
br i1 %37, label %48, label %38
38: ; preds = %11, %36
%39 = phi i64 [ 0, %11 ], [ %45, %36 ]
%40 = getelementptr inbounds i32, i32* %5, i64 %39
%41 = load i32, i32* %40
%42 = icmp slt i32 %41, 1
%43 = icmp sgt i32 %41, %0
%44 = or i1 %42, %43
%45 = add nuw nsw i64 %39, 1
br i1 %44, label %46, label %36
46: ; preds = %38
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
48: ; preds = %36, %7, %10
ret i32* %5
}