#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);
int isFullHouse(const int wDeck[][13], 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) {
      count++;
      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    11cc <isFullHouse+0xbc>
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    11b1 <isFullHouse+0xa1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jne    1195 <isFullHouse+0x85>
movl   $0x1,-0x30(%rbp)
cmpl   $0x3,-0x24(%rbp)
jne    11ac <isFullHouse+0x9c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
jmp    11b8 <isFullHouse+0xa8>
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     11eb <isFullHouse+0xdb>
cmpl   $0x0,-0x2c(%rbp)
jl     11eb <isFullHouse+0xdb>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f2 <isFullHouse+0xe2>
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 = %48, %2
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 5
br i1 %20, label %21, label %51
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 %45
33: ; preds = %21
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 2
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 1, i32* %11
br label %39
39: ; preds = %38, %33
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 3
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = load i32, i32* %7
store i32 %43, i32* %10
store i32 -1, i32* %11
br label %44
44: ; preds = %42, %39
br label %46
45: ; preds = %21
store i32 1, i32* %8
br label %46
46: ; preds = %45, %44
%47 = load i32, i32* %7
store i32 %47, i32* %9
br label %48
48: ; preds = %46
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %18
51: ; preds = %18
%52 = load i32, i32* %11
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = load i32, i32* %10
%56 = icmp sge i32 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32, i32* %10
store i32 %58, i32* %3
br label %60
59: ; preds = %54, %51
store i32 -1, i32* %3
br label %60
60: ; preds = %59, %57
%61 = load i32, i32* %3
ret i32 %61
}

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
}