#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 isFourOFAKind(const int wDeck[][13], int hand[]) {
  int i, card, count = 1;
  int prevCard = getCardFace(wDeck, hand[0]);
  int hasFourOfKind = -1;
  for (i = 1; i < 5; i++) {
    card = getCardFace(wDeck, hand[i]);
    if (card == prevCard) {
      count++;
      if (count == 4)
        hasFourOfKind = card;
    } else
      count = 1;
    prevCard = card;
  }
  return hasFourOfKind;
}


x86 assembly (clang, -O0):
<isFourOFAKind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <getCardFace@plt>
mov    %eax,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11ad <isFourOFAKind+0x9d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <getCardFace@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1192 <isFourOFAKind+0x82>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jne    118d <isFourOFAKind+0x7d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1199 <isFourOFAKind+0x89>
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <isFourOFAKind+0x37>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isFourOFAKind>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r14
mov    (%rsi),%esi
call   1030 <getCardFace@plt>
mov    %eax,%r15d
mov    0x4(%r13),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
mov    %eax,%ebp
xor    %ebx,%ebx
cmp    %r15d,%eax
sete   %bl
mov    0x8(%r13),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
mov    %eax,%r12d
mov    0xc(%r13),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
mov    %eax,%r15d
add    $0x3,%ebx
cmp    %ebp,%r12d
mov    $0x2,%ebp
cmove  %ebx,%ebp
cmp    $0x4,%ebp
mov    $0xffffffff,%eax
mov    $0xffffffff,%ebx
cmove  %r15d,%ebx
cmp    %r12d,%r15d
cmovne %eax,%ebx
mov    0x10(%r13),%esi
mov    %r14,%rdi
call   1030 <getCardFace@plt>
cmp    $0x3,%ebp
mov    %ebx,%ecx
cmove  %eax,%ecx
cmp    %r12d,%r15d
cmovne %ebx,%ecx
cmp    %r15d,%eax
cmovne %ebx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @isFourOFAKind([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
%14 = getelementptr inbounds i32, i32* %1, i64 3
%15 = load i32, i32* %14
%16 = tail call i32 @getCardFace(i32** %3, i32 %15)
%17 = icmp eq i32 %16, %12
%18 = select i1 %9, i32 4, i32 3
%19 = select i1 %13, i32 %18, i32 2
%20 = icmp eq i32 %19, 4
%21 = select i1 %17, i1 %20, i1 false
%22 = select i1 %21, i32 %16, i32 -1
%23 = getelementptr inbounds i32, i32* %1, i64 4
%24 = load i32, i32* %23
%25 = tail call i32 @getCardFace(i32** %3, i32 %24)
%26 = icmp eq i32 %25, %16
%27 = icmp eq i32 %19, 3
%28 = select i1 %26, i1 %17, i1 false
%29 = select i1 %28, i1 %27, i1 false
%30 = select i1 %29, i32 %25, i32 %22
ret i32 %30
}