#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*/ get_highest_score_in_hand(int **, int *, int *);
size_t get_max_id(int *);
int max(int *);
const char *compare_poker_hands(int l_hand[5][2], int r_hand[5][2]) {
  int l_score[2], r_score[2], l_num_seq[5], r_num_seq[5], types;
  int max_l, max_r;
  get_highest_score_in_hand(l_hand, l_score, l_num_seq);
  get_highest_score_in_hand(r_hand, r_score, r_num_seq);
  if (l_score[0] > r_score[0])
    return ("left");
  else if (r_score[0] > l_score[0])
    return ("right");
  else {
    if (l_score[1] > r_score[1])
      return ("left");
    else if (r_score[1] > l_score[1])
      return ("right");
    else {
      while (max(l_num_seq) != 0) {
        max_l = max(l_num_seq);
        max_r = max(r_num_seq);
        if (max_l > max_r)
          return ("left");
        else if (max_r > max_l)
          return ("right");
        else {
          l_num_seq[get_max_id(l_num_seq)] = 0;
          r_num_seq[get_max_id(r_num_seq)] = 0;
        }
      }
      return ("none");
    }
  }
}


x86 assembly (clang, -O0):
<compare_poker_hands>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1050 <get_highest_score_in_hand@plt>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1050 <get_highest_score_in_hand@plt>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jle    117e <compare_poker_hands+0x4e>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    119a <compare_poker_hands+0x6a>
lea    0xe74(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    11b6 <compare_poker_hands+0x86>
lea    0xe53(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    11d2 <compare_poker_hands+0xa2>
lea    0xe3c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
jmp    11d7 <compare_poker_hands+0xa7>
lea    -0x40(%rbp),%rdi
call   1040 <max@plt>
cmp    $0x0,%eax
je     1265 <compare_poker_hands+0x135>
lea    -0x40(%rbp),%rdi
call   1040 <max@plt>
mov    %eax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <max@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jle    121d <compare_poker_hands+0xed>
lea    0xdec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
mov    -0x6c(%rbp),%eax
cmp    -0x68(%rbp),%eax
jle    1239 <compare_poker_hands+0x109>
lea    0xdd5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <compare_poker_hands+0x140>
lea    -0x40(%rbp),%rdi
call   1030 <get_max_id@plt>
movl   $0x0,-0x40(%rbp,%rax,4)
lea    -0x60(%rbp),%rdi
call   1030 <get_max_id@plt>
movl   $0x0,-0x60(%rbp,%rax,4)
jmp    1260 <compare_poker_hands+0x130>
jmp    11d7 <compare_poker_hands+0xa7>
lea    0xd9f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_poker_hands>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1050 <get_highest_score_in_hand@plt>
mov    %rsp,%rsi
lea    0x30(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <get_highest_score_in_hand@plt>
mov    0x8(%rsp),%eax
mov    (%rsp),%ecx
lea    0xe92(%rip),%rbx
cmp    %ecx,%eax
jg     118c <compare_poker_hands+0x5c>
lea    0xe8c(%rip),%r12
jl     1189 <compare_poker_hands+0x59>
mov    0xc(%rsp),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
jg     118c <compare_poker_hands+0x5c>
jge    119e <compare_poker_hands+0x6e>
mov    %r12,%rbx
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rdi
call   1040 <max@plt>
lea    0xe5c(%rip),%r13
test   %eax,%eax
je     1204 <compare_poker_hands+0xd4>
lea    0x10(%rsp),%r14
lea    0x30(%rsp),%r15
nopl   (%rax)
mov    %r14,%rdi
call   1040 <max@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <max@plt>
cmp    %eax,%ebp
jg     118c <compare_poker_hands+0x5c>
jl     1189 <compare_poker_hands+0x59>
mov    %r14,%rdi
call   1030 <get_max_id@plt>
movl   $0x0,0x10(%rsp,%rax,4)
mov    %r15,%rdi
call   1030 <get_max_id@plt>
movl   $0x0,0x30(%rsp,%rax,4)
mov    %r14,%rdi
call   1040 <max@plt>
test   %eax,%eax
jne    11c0 <compare_poker_hands+0x90>
mov    %r13,%rbx
jmp    118c <compare_poker_hands+0x5c>

LLVM IR (-O0):
@.str = [5 x i8] c"left\00"
@.str.1 = [6 x i8] c"right\00"
@.str.2 = [5 x i8] c"none\00"
define i8* @compare_poker_hands([2 x i32]* %0, [2 x i32]* %1) {
%3 = alloca i8*
%4 = alloca [2 x i32]*
%5 = alloca [2 x i32]*
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca [5 x i32]
%9 = alloca [5 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store [2 x i32]* %0, [2 x i32]** %4
store [2 x i32]* %1, [2 x i32]** %5
%13 = load [2 x i32]*, [2 x i32]** %4
%14 = bitcast [2 x i32]* %13 to i32**
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%17 = call i32 @get_highest_score_in_hand(i32** %14, i32* %15, i32* %16)
%18 = load [2 x i32]*, [2 x i32]** %5
%19 = bitcast [2 x i32]* %18 to i32**
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
%22 = call i32 @get_highest_score_in_hand(i32** %19, i32* %20, i32* %21)
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%24 = load i32, i32* %23
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%26 = load i32, i32* %25
%27 = icmp sgt i32 %24, %26
br i1 %27, label %28, label %29
28: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
br label %79
29: ; preds = %2
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%31 = load i32, i32* %30
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%33 = load i32, i32* %32
%34 = icmp sgt i32 %31, %33
br i1 %34, label %35, label %36
35: ; preds = %29
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %79
36: ; preds = %29
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%38 = load i32, i32* %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%40 = load i32, i32* %39
%41 = icmp sgt i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %36
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
br label %79
43: ; preds = %36
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%45 = load i32, i32* %44
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%47 = load i32, i32* %46
%48 = icmp sgt i32 %45, %47
br i1 %48, label %49, label %50
49: ; preds = %43
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %79
50: ; preds = %43
br label %51
51: ; preds = %77, %50
%52 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%53 = call i32 @max(i32* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %78
55: ; preds = %51
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%57 = call i32 @max(i32* %56)
store i32 %57, i32* %11
%58 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
%59 = call i32 @max(i32* %58)
store i32 %59, i32* %12
%60 = load i32, i32* %11
%61 = load i32, i32* %12
%62 = icmp sgt i32 %60, %61
br i1 %62, label %63, label %64
63: ; preds = %55
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
br label %79
64: ; preds = %55
%65 = load i32, i32* %12
%66 = load i32, i32* %11
%67 = icmp sgt i32 %65, %66
br i1 %67, label %68, label %69
68: ; preds = %64
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %79
69: ; preds = %64
%70 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 0
%71 = call i64 @get_max_id(i32* %70)
%72 = getelementptr inbounds [5 x i32], [5 x i32]* %8, i64 0, i64 %71
store i32 0, i32* %72
%73 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 0
%74 = call i64 @get_max_id(i32* %73)
%75 = getelementptr inbounds [5 x i32], [5 x i32]* %9, i64 0, i64 %74
store i32 0, i32* %75
br label %76
76: ; preds = %69
br label %77
77: ; preds = %76
br label %51
78: ; preds = %51
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %79
79: ; preds = %78, %68, %63, %49, %42, %35, %28
%80 = load i8*, i8** %3
ret i8* %80
}

LLVM IR (-O2):
@.str = [5 x i8] c"left\00"
@.str.1 = [6 x i8] c"right\00"
@.str.2 = [5 x i8] c"none\00"
define i8* @compare_poker_hands([2 x i32]* %0, [2 x i32]* %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [5 x i32]
%6 = alloca [5 x i32]
%7 = bitcast [2 x i32]* %3 to i8*
%8 = bitcast [2 x i32]* %4 to i8*
%9 = bitcast [5 x i32]* %5 to i8*
%10 = bitcast [5 x i32]* %6 to i8*
%11 = bitcast [2 x i32]* %0 to i32**
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%14 = call i32 @get_highest_score_in_hand(i32** %11, i32* %12, i32* %13)
%15 = bitcast [2 x i32]* %1 to i32**
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%18 = call i32 @get_highest_score_in_hand(i32** %15, i32* %16, i32* %17)
%19 = load i32, i32* %12
%20 = load i32, i32* %16
%21 = icmp sgt i32 %19, %20
br i1 %21, label %48, label %22
22: ; preds = %2
%23 = icmp sgt i32 %20, %19
br i1 %23, label %48, label %24
24: ; preds = %22
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%26 = load i32, i32* %25
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%28 = load i32, i32* %27
%29 = icmp sgt i32 %26, %28
br i1 %29, label %48, label %30
30: ; preds = %24
%31 = icmp sgt i32 %28, %26
br i1 %31, label %48, label %32
32: ; preds = %30
%33 = call i32 @max(i32* %13)
%34 = icmp eq i32 %33, 0
br i1 %34, label %48, label %35
35: ; preds = %32, %41
%36 = call i32 @max(i32* %13)
%37 = call i32 @max(i32* %17)
%38 = icmp sgt i32 %36, %37
br i1 %38, label %48, label %39
39: ; preds = %35
%40 = icmp sgt i32 %37, %36
br i1 %40, label %48, label %41
41: ; preds = %39
%42 = call i64 @get_max_id(i32* %13)
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %42
store i32 0, i32* %43
%44 = call i64 @get_max_id(i32* %17)
%45 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 %44
store i32 0, i32* %45
%46 = call i32 @max(i32* %13)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %35
48: ; preds = %35, %39, %41, %32, %30, %24, %22, %2
%49 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %22 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %24 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %30 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %32 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %35 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %39 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %41 ]
ret i8* %49
}