#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 eval_5hand_fast(int *);
short eval_6hand_fast(int *hand) {
  int i;
  short best = 9999;
  int perm[][5] = {
      {0, 1, 2, 3, 4}, {0, 1, 2, 3, 5}, {0, 1, 2, 4, 5},
      {0, 1, 3, 4, 5}, {0, 2, 3, 4, 5}, {1, 2, 3, 4, 5},
  };
  for (i = 0; i < 6; i++) {
    int subhand[5];
    int j;
    for (j = 0; j < 5; j++)
      subhand[j] = hand[perm[i][j]];
    int q = eval_5hand_fast(subhand);
    if (q < best)
      best = q;
  }
  return best;
}


x86 assembly (clang, -O0):
<eval_6hand_fast>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x270f,-0xe(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x78,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x6,-0xc(%rbp)
jge    11fc <eval_6hand_fast+0xdc>
movl   $0x0,-0xb4(%rbp)
cmpl   $0x5,-0xb4(%rbp)
jge    11bb <eval_6hand_fast+0x9b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rdx
lea    -0x90(%rbp),%rcx
imul   $0x14,%rdx,%rdx
add    %rdx,%rcx
movslq -0xb4(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1168 <eval_6hand_fast+0x48>
lea    -0xb0(%rbp),%rdi
call   1040 <eval_5hand_fast@plt>
mov    %eax,-0xb8(%rbp)
mov    -0xb8(%rbp),%eax
movswl -0xe(%rbp),%ecx
cmp    %ecx,%eax
jge    11e9 <eval_6hand_fast+0xc9>
mov    -0xb8(%rbp),%eax
mov    %ax,-0xe(%rbp)
jmp    11ee <eval_6hand_fast+0xce>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <eval_6hand_fast+0x34>
movswl -0xe(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_6hand_fast>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
mov    $0x270f,%bx
xor    %r12d,%r12d
lea    0xed2(%rip),%r13
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq (%r12,%r13,1),%rax
mov    (%r14,%rax,4),%eax
mov    %eax,(%rsp)
movslq 0x4(%r12,%r13,1),%rax
mov    (%r14,%rax,4),%eax
mov    %eax,0x4(%rsp)
movslq 0x8(%r12,%r13,1),%rax
mov    (%r14,%rax,4),%eax
mov    %eax,0x8(%rsp)
movslq 0xc(%r12,%r13,1),%rax
mov    (%r14,%rax,4),%eax
mov    %eax,0xc(%rsp)
movslq 0x10(%r12,%r13,1),%rax
mov    (%r14,%rax,4),%eax
mov    %eax,0x10(%rsp)
mov    %r15,%rdi
call   1030 <eval_5hand_fast@plt>
movswl %bx,%ebx
cmp    %ebx,%eax
cmovl  %eax,%ebx
add    $0x14,%r12
cmp    $0x78,%r12
jne    1140 <eval_6hand_fast+0x30>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.eval_6hand_fast.perm = [6 x [5 x i32]] [[5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4], [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 5], [5 x i32] [i32 0, i32 1, i32 2, i32 4, i32 5], [5 x i32] [i32 0, i32 1, i32 3, i32 4, i32 5], [5 x i32] [i32 0, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]]
define signext i16 @eval_6hand_fast(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i16
%5 = alloca [6 x [5 x i32]]
%6 = alloca [5 x i32]
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %2
store i16 9999, i16* %4
%9 = bitcast [6 x [5 x i32]]* %5 to i8*
store i32 0, i32* %3
br label %10
10: ; preds = %46, %1
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 6
br i1 %12, label %13, label %49
13: ; preds = %10
store i32 0, i32* %7
br label %14
14: ; preds = %32, %13
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %35
17: ; preds = %14
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* %5, i64 0, i64 %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [5 x i32], [5 x i32]* %21, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %18, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %30
store i32 %28, i32* %31
br label %32
32: ; preds = %17
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %14
35: ; preds = %14
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%37 = call i32 @eval_5hand_fast(i32* %36)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = load i16, i16* %4
%40 = sext i16 %39 to i32
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %45
42: ; preds = %35
%43 = load i32, i32* %8
%44 = trunc i32 %43 to i16
store i16 %44, i16* %4
br label %45
45: ; preds = %42, %35
br label %46
46: ; preds = %45
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %10
49: ; preds = %10
%50 = load i16, i16* %4
ret i16 %50
}

LLVM IR (-O2):
@__const.eval_6hand_fast.perm = [6 x [5 x i32]] [[5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4], [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 5], [5 x i32] [i32 0, i32 1, i32 2, i32 4, i32 5], [5 x i32] [i32 0, i32 1, i32 3, i32 4, i32 5], [5 x i32] [i32 0, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]]
define signext i16 @eval_6hand_fast(i32* nocapture %0) {
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %2 to i8*
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 1
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 2
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 3
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 4
br label %9
9: ; preds = %1, %9
%10 = phi i64 [ 0, %1 ], [ %42, %9 ]
%11 = phi i16 [ 9999, %1 ], [ %41, %9 ]
%12 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* @__const.eval_6hand_fast.perm, i64 0, i64 %10, i64 0
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %4
%17 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* @__const.eval_6hand_fast.perm, i64 0, i64 %10, i64 1
%18 = load i32, i32* %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %5
%22 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* @__const.eval_6hand_fast.perm, i64 0, i64 %10, i64 2
%23 = load i32, i32* %22
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %0, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %6
%27 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* @__const.eval_6hand_fast.perm, i64 0, i64 %10, i64 3
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %0, i64 %29
%31 = load i32, i32* %30
store i32 %31, i32* %7
%32 = getelementptr inbounds [6 x [5 x i32]], [6 x [5 x i32]]* @__const.eval_6hand_fast.perm, i64 0, i64 %10, i64 4
%33 = load i32, i32* %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %0, i64 %34
%36 = load i32, i32* %35
store i32 %36, i32* %8
%37 = call i32 @eval_5hand_fast(i32* %4)
%38 = sext i16 %11 to i32
%39 = icmp slt i32 %37, %38
%40 = trunc i32 %37 to i16
%41 = select i1 %39, i16 %40, i16 %11
%42 = add nuw nsw i64 %10, 1
%43 = icmp eq i64 %42, 6
br i1 %43, label %44, label %9
44: ; preds = %9
ret i16 %41
}