#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 isFourOFAKind(const int wDeck[][13], const 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) {
      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    11ac <isFourOFAKind+0x9c>
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    1191 <isFourOFAKind+0x81>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x4,%eax
jne    118c <isFourOFAKind+0x7c>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1198 <isFourOFAKind+0x88>
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 = %41, %2
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 5
br i1 %18, label %19, label %44
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 %38
31: ; preds = %19
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
%34 = icmp eq i32 %33, 4
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %6
store i32 %36, i32* %9
br label %37
37: ; preds = %35, %31
br label %39
38: ; preds = %19
store i32 1, i32* %7
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %6
store i32 %40, i32* %8
br label %41
41: ; preds = %39
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %16
44: ; preds = %16
%45 = load i32, i32* %9
ret i32 %45
}

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
}