#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 data_vps(int);
int /*<<< orphan*/ gethand(int, int *);
int rate_hand(int *, int);
int ai_accepttrade(int *trade, int player, int playerTrading) {
  if (data_vps(playerTrading) >= 7)
    return 0;
  int hand[5];
  gethand(player, hand);
  int rating = rate_hand(hand, player);
  int i;
  for (i = 0; i < 5; i++)
    hand[i] += trade[i];
  if (rate_hand(hand, player) > rating)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<ai_accepttrade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <data_vps@plt>
cmp    $0x7,%eax
jl     115f <ai_accepttrade+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <ai_accepttrade+0xa8>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1030 <gethand@plt>
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <rate_hand@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x5,-0x38(%rbp)
jge    11b0 <ai_accepttrade+0x80>
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x38(%rbp),%rax
add    -0x30(%rbp,%rax,4),%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1181 <ai_accepttrade+0x51>
lea    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <rate_hand@plt>
cmp    -0x34(%rbp),%eax
jle    11d1 <ai_accepttrade+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11d8 <ai_accepttrade+0xa8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_accepttrade>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
mov    %edx,%edi
call   1040 <data_vps@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x6,%ecx
jg     1192 <ai_accepttrade+0x62>
mov    %rsp,%r15
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <gethand@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <rate_hand@plt>
mov    %eax,%ebp
movdqu (%r14),%xmm0
paddd  (%rsp),%xmm0
movdqa %xmm0,(%rsp)
mov    0x10(%r14),%eax
add    %eax,0x10(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <rate_hand@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
setg   %al
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @ai_accepttrade(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [5 x i32]
%5 = tail call i32 @data_vps(i32 %2)
%6 = icmp sgt i32 %5, 6
br i1 %6, label %26, label %7
7: ; preds = %3
%8 = bitcast [5 x i32]* %4 to i8*
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%10 = call i32 @gethand(i32 %1, i32* %9)
%11 = call i32 @rate_hand(i32* %9, i32 %1)
%12 = bitcast i32* %0 to <4 x i32>*
%13 = load <4 x i32>, <4 x i32>* %12
%14 = bitcast [5 x i32]* %4 to <4 x i32>*
%15 = load <4 x i32>, <4 x i32>* %14
%16 = add nsw <4 x i32> %15, %13
%17 = bitcast [5 x i32]* %4 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %0, i64 4
%19 = load i32, i32* %18
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 4
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %19
store i32 %22, i32* %20
%23 = call i32 @rate_hand(i32* %9, i32 %1)
%24 = icmp sgt i32 %23, %11
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %3, %7
%27 = phi i32 [ %25, %7 ], [ 0, %3 ]
ret i32 %27
}