#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 /*<<< orphan*/ printf(char *, ...);
void compareAndPrintResult(const int pScore[]) {
  int tmpMax = 0, maxPerson = -1, i;
  for (i = 0; i < 4; i++) {
    if (pScore[i] > tmpMax) {
      maxPerson = i;
      tmpMax = pScore[i];
    }
  }
  printf("Winner : P%d — ", maxPerson + 1);
  switch (pScore[maxPerson] / 1000) {
  case 9:
    printf("straight flush\n");
    break;
  case 8:
    printf("four-of-a-kind\n");
    break;
  case 7:
    printf("full house\n");
    break;
  case 6:
    printf("flush\n");
    break;
  case 5:
    printf("straight\n");
    break;
  case 4:
    printf("three-of-a-kind\n");
    break;
  case 3:
    printf("two pairs\n");
    break;
  case 2:
    printf("pair\n");
    break;
  case 1:
    printf("high card\n");
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<compareAndPrintResult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    1176 <compareAndPrintResult+0x66>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
jle    1163 <compareAndPrintResult+0x53>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <compareAndPrintResult+0x58>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <compareAndPrintResult+0x21>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movslq (%rax,%rcx,4),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
sar    $0x26,%rcx
mov    %ecx,%edx
shr    $0x3f,%rax
mov    %eax,%ecx
mov    %edx,%eax
lea    -0x1(%rax,%rcx,1),%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x8,%eax
ja     1280 <compareAndPrintResult+0x170>
mov    -0x20(%rbp),%rax
lea    0xe34(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1285 <compareAndPrintResult+0x175>
jmp    1285 <compareAndPrintResult+0x175>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareAndPrintResult>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
xor    %edx,%edx
xor    %esi,%esi
test   %eax,%eax
setle  %sil
cmovs  %edx,%eax
neg    %esi
cmp    %eax,%ecx
cmovg  %ecx,%eax
mov    $0x1,%ecx
cmovle %esi,%ecx
mov    0x8(%rdi),%edx
cmp    %eax,%edx
cmovg  %edx,%eax
mov    $0x2,%edx
cmovle %ecx,%edx
cmp    %eax,0xc(%rdi)
mov    $0x3,%ebx
cmovle %edx,%ebx
lea    0x1(%rbx),%esi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%rax
movslq (%r14,%rax,4),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
sar    $0x26,%rcx
shr    $0x3f,%rax
add    %ecx,%eax
add    $0xffffffff,%eax
cmp    $0x8,%eax
ja     11b3 <compareAndPrintResult+0x93>
cltq
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Winner : P%d \E2\80\94 \00"
@.str.1 = [16 x i8] c"straight flush\0A\00"
@.str.2 = [16 x i8] c"four-of-a-kind\0A\00"
@.str.3 = [12 x i8] c"full house\0A\00"
@.str.4 = [7 x i8] c"flush\0A\00"
@.str.5 = [10 x i8] c"straight\0A\00"
@.str.6 = [17 x i8] c"three-of-a-kind\0A\00"
@.str.7 = [11 x i8] c"two pairs\0A\00"
@.str.8 = [6 x i8] c"pair\0A\00"
@.str.9 = [11 x i8] c"high card\0A\00"
define void @compareAndPrintResult(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 -1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %25, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = load i32*, i32** %2
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32, i32* %13
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %9
%18 = load i32, i32* %5
store i32 %18, i32* %4
%19 = load i32*, i32** %2
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
store i32 %23, i32* %3
br label %24
24: ; preds = %17, %9
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %6
28: ; preds = %6
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = load i32*, i32** %2
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = sdiv i32 %36, 1000
switch i32 %37, label %56 [
i32 9, label %38
i32 8, label %40
i32 7, label %42
i32 6, label %44
i32 5, label %46
i32 4, label %48
i32 3, label %50
i32 2, label %52
i32 1, label %54
]
38: ; preds = %28
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %57
40: ; preds = %28
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %57
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %57
44: ; preds = %28
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %57
46: ; preds = %28
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %57
48: ; preds = %28
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %57
50: ; preds = %28
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %57
52: ; preds = %28
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
br label %57
54: ; preds = %28
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %57
56: ; preds = %28
br label %57
57: ; preds = %56, %54, %52, %50, %48, %46, %44, %42, %40, %38
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Winner : P%d \E2\80\94 \00"
@str = [10 x i8] c"high card\00"
@str.10 = [5 x i8] c"pair\00"
@str.11 = [10 x i8] c"two pairs\00"
@str.12 = [16 x i8] c"three-of-a-kind\00"
@str.13 = [9 x i8] c"straight\00"
@str.14 = [6 x i8] c"flush\00"
@str.15 = [11 x i8] c"full house\00"
@str.16 = [15 x i8] c"four-of-a-kind\00"
@str.17 = [15 x i8] c"straight flush\00"
@reltable.compareAndPrintResult = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @str.10 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.11 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @str.12 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.13 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @str.14 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.15 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.16 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.17 to i64), i64 ptrtoint ([9 x i32]* @reltable.compareAndPrintResult to i64)) to i32)]
define void @compareAndPrintResult(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp sgt i32 %2, 0
%4 = select i1 %3, i32 %2, i32 0
%5 = xor i1 %3, true
%6 = sext i1 %5 to i32
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, %4
%10 = select i1 %9, i32 %8, i32 %4
%11 = select i1 %9, i32 1, i32 %6
%12 = getelementptr inbounds i32, i32* %0, i64 2
%13 = load i32, i32* %12
%14 = icmp sgt i32 %13, %10
%15 = select i1 %14, i32 %13, i32 %10
%16 = select i1 %14, i32 2, i32 %11
%17 = getelementptr inbounds i32, i32* %0, i64 3
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, %15
%20 = select i1 %19, i32 3, i32 %16
%21 = add nsw i32 %20, 1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = sext i32 %20 to i64
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = sdiv i32 %25, 1000
%27 = add nsw i32 %26, -1
%28 = icmp ult i32 %27, 9
br i1 %28, label %29, label %34
29: ; preds = %1
%30 = sext i32 %27 to i64
%31 = shl i64 %30, 2
%32 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.compareAndPrintResult to i8*), i64 %31)
%33 = tail call i32 @puts(i8* dereferenceable(1) %32)
br label %34
34: ; preds = %1, %29
ret void
}