#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 getCardFace(int const **, int const);
int isFullHouse(const int wDeck[][13], const int *hand) {
  int i, card, count = 1;
  int prevCard = getCardFace(wDeck, hand[0]);
  int hasThreeOfKind = -1;
  int hasPair = -1;
  for (i = 1; i < 5; i++) {
    card = getCardFace(wDeck, hand[i]);
    if (card == prevCard) {
      if (++count == 2) {
        hasPair = 1;
      }
      if (count == 3) {
        hasThreeOfKind = card;
        hasPair = -1;
      }
    } else
      count = 1;
    prevCard = card;
  }
  if (hasPair >= 0 && hasThreeOfKind >= 0)
    return hasThreeOfKind;
  else
    return -1;
}


x86 assembly (clang, -O0):
<isFullHouse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <getCardFace@plt>
mov    %eax,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    11cb <isFullHouse+0xbb>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <getCardFace@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    11b0 <isFullHouse+0xa0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmp    $0x2,%eax
jne    1194 <isFullHouse+0x84>
movl   $0x1,-0x30(%rbp)
cmpl   $0x3,-0x24(%rbp)
jne    11ab <isFullHouse+0x9b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
jmp    11b7 <isFullHouse+0xa7>
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <isFullHouse+0x3e>
cmpl   $0x0,-0x30(%rbp)
jl     11ea <isFullHouse+0xda>
cmpl   $0x0,-0x2c(%rbp)
jl     11ea <isFullHouse+0xda>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f1 <isFullHouse+0xe1>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isFullHouse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%esi
call   1030 <getCardFace@plt>
mov    %eax,%ebp
mov    0x4(%r15),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
mov    %eax,%ebx
mov    0x8(%r15),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
mov    %eax,%r13d
cmp    %ebp,%ebx
jne    115d <isFullHouse+0x4d>
cmp    %ebx,%r13d
jne    1179 <isFullHouse+0x69>
mov    $0xffffffff,%ebp
mov    $0x4,%r12d
jmp    1189 <isFullHouse+0x79>
xor    %r12d,%r12d
cmp    %ebx,%r13d
sete   %r12b
lea    (%r12,%r12,1),%ebp
add    $0xffffffff,%ebp
or     $0x2,%r12d
mov    $0xffffffff,%ebx
jmp    1189 <isFullHouse+0x79>
mov    $0x1,%ebp
mov    $0xffffffff,%ebx
mov    $0x2,%r12d
mov    0xc(%r15),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
cmp    %r13d,%eax
jne    11c1 <isFullHouse+0xb1>
mov    %r13d,%ecx
mov    %eax,%r13d
cmp    $0x2,%r12d
mov    $0x1,%eax
cmove  %eax,%ebp
cmp    $0x3,%r12d
jne    11ca <isFullHouse+0xba>
mov    $0xffffffff,%ebp
mov    $0x3,%r12d
mov    %ecx,%ebx
jmp    11ca <isFullHouse+0xba>
mov    %eax,%r13d
mov    $0x1,%r12d
mov    0x10(%r15),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
cmp    %r13d,%eax
jne    11fb <isFullHouse+0xeb>
add    $0x1,%r12d
cmp    $0x2,%r12d
mov    $0x1,%eax
cmove  %eax,%ebp
cmp    $0x3,%r12d
cmove  %r13d,%ebx
mov    $0xffffffff,%eax
cmove  %eax,%ebp
or     %ebx,%ebp
mov    $0xffffffff,%eax
cmovns %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @isFullHouse([13 x i32]* %0, i32* nocapture %1) {
%3 = bitcast [13 x i32]* %0 to i32**
%4 = load i32, i32* %1
%5 = tail call i32 @getCardFace(i32** %3, i32 %4)
%6 = getelementptr inbounds i32, i32* %1, i64 1
%7 = load i32, i32* %6
%8 = tail call i32 @getCardFace(i32** %3, i32 %7)
%9 = icmp eq i32 %8, %5
%10 = getelementptr inbounds i32, i32* %1, i64 2
%11 = load i32, i32* %10
%12 = tail call i32 @getCardFace(i32** %3, i32 %11)
%13 = icmp eq i32 %12, %8
br i1 %9, label %14, label %15
14: ; preds = %2
br i1 %13, label %18, label %19
15: ; preds = %2
%16 = select i1 %13, i32 1, i32 -1
%17 = select i1 %13, i32 3, i32 2
br label %19
18: ; preds = %14
br label %19
19: ; preds = %15, %18, %14
%20 = phi i32 [ 4, %18 ], [ 2, %14 ], [ %17, %15 ]
%21 = phi i32 [ %8, %18 ], [ -1, %14 ], [ -1, %15 ]
%22 = phi i32 [ -1, %18 ], [ 1, %14 ], [ %16, %15 ]
%23 = getelementptr inbounds i32, i32* %1, i64 3
%24 = load i32, i32* %23
%25 = tail call i32 @getCardFace(i32** %3, i32 %24)
%26 = icmp eq i32 %25, %12
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = icmp eq i32 %20, 2
%29 = select i1 %28, i32 1, i32 %22
%30 = icmp eq i32 %20, 3
br i1 %30, label %31, label %32
31: ; preds = %27
br label %32
32: ; preds = %31, %27, %19
%33 = phi i32 [ 3, %31 ], [ %20, %27 ], [ 1, %19 ]
%34 = phi i32 [ %12, %31 ], [ %21, %27 ], [ %21, %19 ]
%35 = phi i32 [ -1, %31 ], [ %29, %27 ], [ %22, %19 ]
%36 = getelementptr inbounds i32, i32* %1, i64 4
%37 = load i32, i32* %36
%38 = tail call i32 @getCardFace(i32** %3, i32 %37)
%39 = icmp eq i32 %38, %25
br i1 %39, label %40, label %47
40: ; preds = %32
%41 = add nuw nsw i32 %33, 1
%42 = icmp eq i32 %41, 2
%43 = select i1 %42, i32 1, i32 %35
%44 = icmp eq i32 %41, 3
%45 = select i1 %44, i32 %25, i32 %34
%46 = select i1 %44, i32 -1, i32 %43
br label %47
47: ; preds = %40, %32
%48 = phi i32 [ %34, %32 ], [ %45, %40 ]
%49 = phi i32 [ %35, %32 ], [ %46, %40 ]
%50 = icmp sgt i32 %49, -1
%51 = icmp sgt i32 %48, -1
%52 = select i1 %50, i1 %51, i1 false
%53 = select i1 %52, i32 %48, i32 -1
ret i32 %53
}