#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 */
struct poker_hand {
  int dummy;
};

/* Variables and functions */
int find_pair(struct poker_hand const *, int *);
int find_three(struct poker_hand const *, int *);
int full_house(const struct poker_hand *h) {
  int selected_cards = 0;
  int val = find_three(h, &selected_cards);
  if (val < 0)
    return val;
  int val2 = find_pair(h, &selected_cards);
  if (val2 < 0)
    return val2;
  return val * 0x100000 + val2 * 0x10000;
}


x86 assembly (clang, -O0):
<full_house>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <find_three@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1158 <full_house+0x38>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <full_house+0x6e>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <find_pair@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    117d <full_house+0x5d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <full_house+0x6e>
mov    -0x18(%rbp),%eax
shl    $0x14,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<full_house>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rsi
call   1030 <find_three@plt>
mov    %eax,%ebx
test   %eax,%eax
js     115d <full_house+0x3d>
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1040 <find_pair@plt>
shl    $0x14,%ebx
mov    %eax,%ecx
shl    $0x10,%ecx
add    %ebx,%ecx
test   %eax,%eax
cmovs  %eax,%ecx
mov    %ecx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.poker_hand = type { i32 }
define i32 @full_house(%struct.poker_hand* %0) {
%2 = alloca i32
%3 = alloca %struct.poker_hand*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.poker_hand* %0, %struct.poker_hand** %3
store i32 0, i32* %4
%7 = load %struct.poker_hand*, %struct.poker_hand** %3
%8 = call i32 @find_three(%struct.poker_hand* %7, i32* %4)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i32, i32* %5
store i32 %12, i32* %2
br label %26
13: ; preds = %1
%14 = load %struct.poker_hand*, %struct.poker_hand** %3
%15 = call i32 @find_pair(%struct.poker_hand* %14, i32* %4)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* %6
store i32 %19, i32* %2
br label %26
20: ; preds = %13
%21 = load i32, i32* %5
%22 = mul nsw i32 %21, 1048576
%23 = load i32, i32* %6
%24 = mul nsw i32 %23, 65536
%25 = add nsw i32 %22, %24
store i32 %25, i32* %2
br label %26
26: ; preds = %20, %18, %11
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
%struct.poker_hand = type { i32 }
define i32 @full_house(%struct.poker_hand* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = call i32 @find_three(%struct.poker_hand* %0, i32* %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %1
%7 = call i32 @find_pair(%struct.poker_hand* %0, i32* %2)
%8 = icmp slt i32 %7, 0
%9 = shl nsw i32 %4, 20
%10 = shl nsw i32 %7, 16
%11 = add nsw i32 %10, %9
%12 = select i1 %8, i32 %7, i32 %11
br label %13
13: ; preds = %1, %6
%14 = phi i32 [ %12, %6 ], [ %4, %1 ]
ret i32 %14
}