#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*/ accepttrade(int *, int, int, int *);
int data_vps(int);
int /*<<< orphan*/ doTrade(int *, int, int);
int /*<<< orphan*/ gethand(int, int *);
int rate_hand(int *, int);
int ai_playertrade(int player, int *trade, int minRating) {
  static int trades[4][6];
  int p, i;
  for (i = 0; i < 6; i++)
    trades[player][i] = 0;
  for (p = 1; p < 4; p++) {
    if (data_vps((player + p) % 4) < 7) {
      int t[6];
      accepttrade(trade, (player + p) % 4, player, t);
      for (i = 0; i < 6; i++)
        trades[(player + p) % 4][i] = t[i];
    } else {
      trades[(player + p) % 4][5] = 0;
    }
  }
  int max, maxp;
  int hand[5];
  max = minRating;
  maxp = player;
  for (p = 1; p < 4; p++) {
    if (trades[(player + p) % 4][5] > 0) {
      gethand(player, hand);
      for (i = 0; i < 5; i++)
        hand[i] -= trades[(player + p) % 4][i];
      if (rate_hand(hand, player) > max) {
        max = rate_hand(hand, player);
        maxp = (player + p) % 4;
      }
    }
  }
  doTrade(trades[maxp], player, maxp);
  return (maxp != player);
}


x86 assembly (clang, -O0):
<ai_playertrade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jge    119e <ai_playertrade+0x4e>
movslq -0x4(%rbp),%rcx
lea    0x2ee2(%rip),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1169 <ai_playertrade+0x19>
movl   $0x1,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1280 <ai_playertrade+0x130>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1060 <data_vps@plt>
cmp    $0x7,%eax
jge    1247 <ai_playertrade+0xf7>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x4(%rbp),%edx
lea    -0x40(%rbp),%rcx
call   1030 <accepttrade@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jge    1242 <ai_playertrade+0xf2>
movslq -0x1c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x64(%rbp)
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x64(%rbp),%edx
movslq %eax,%rcx
lea    0x2e3a(%rip),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f4 <ai_playertrade+0xa4>
jmp    126d <ai_playertrade+0x11d>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2e01(%rip),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movl   $0x0,0x14(%rax)
jmp    1272 <ai_playertrade+0x122>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a5 <ai_playertrade+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1372 <ai_playertrade+0x222>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2dab(%rip),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
cmpl   $0x0,0x14(%rax)
jle    135f <ai_playertrade+0x20f>
mov    -0x4(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   1040 <gethand@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x5,-0x1c(%rbp)
jge    1325 <ai_playertrade+0x1d5>
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2d65(%rip),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
movslq -0x1c(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%ecx
sub    %edx,%ecx
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12d9 <ai_playertrade+0x189>
lea    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <rate_hand@plt>
cmp    -0x44(%rbp),%eax
jle    135a <ai_playertrade+0x20a>
lea    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1070 <rate_hand@plt>
mov    %eax,-0x44(%rbp)
mov    -0x4(%rbp),%eax
add    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x48(%rbp)
jmp    135f <ai_playertrade+0x20f>
jmp    1364 <ai_playertrade+0x214>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1293 <ai_playertrade+0x143>
movslq -0x48(%rbp),%rax
lea    0x2ce3(%rip),%rdi
imul   $0x18,%rax,%rax
add    %rax,%rdi
mov    -0x4(%rbp),%esi
mov    -0x48(%rbp),%edx
call   1050 <doTrade@plt>
mov    -0x48(%rbp),%eax
cmp    -0x4(%rbp),%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_playertrade>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,%r14
mov    %edi,%ebx
movslq %edi,%rax
lea    0x1(%rax),%ecx
lea    0x4(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
lea    (%rax,%rax,2),%rcx
lea    0x2ee0(%rip),%r12
pxor   %xmm0,%xmm0
movdqu %xmm0,(%r12,%rcx,8)
movq   $0x0,0x10(%r12,%rcx,8)
and    $0xfffffffc,%edx
neg    %edx
lea    (%rax,%rdx,1),%ebp
add    $0x1,%ebp
mov    %ebp,%edi
call   1060 <data_vps@plt>
movslq %ebp,%r15
cmp    $0x6,%eax
mov    %r14,0x40(%rsp)
jg     11e0 <ai_playertrade+0x90>
lea    0x10(%rsp),%rcx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1030 <accepttrade@plt>
lea    (%r15,%r15,2),%rax
movdqa 0x10(%rsp),%xmm0
movdqu %xmm0,(%r12,%rax,8)
mov    0x20(%rsp),%rcx
mov    %rcx,0x10(%r12,%rax,8)
jmp    11ed <ai_playertrade+0x9d>
lea    (%r15,%r15,2),%rax
movl   $0x0,0x14(%r12,%rax,8)
lea    0x2(%rbx),%eax
lea    0x5(%rbx),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
neg    %ecx
lea    (%rbx,%rcx,1),%r14d
add    $0x2,%r14d
mov    %r14d,%edi
call   1060 <data_vps@plt>
movslq %r14d,%r13
cmp    $0x7,%eax
mov    %ebp,0x34(%rsp)
jge    1250 <ai_playertrade+0x100>
lea    0x10(%rsp),%rcx
mov    0x40(%rsp),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1030 <accepttrade@plt>
lea    0x0(,%r13,2),%rax
add    %r13,%rax
movdqa 0x10(%rsp),%xmm0
movdqu %xmm0,(%r12,%rax,8)
mov    0x20(%rsp),%rcx
mov    %rcx,0x10(%r12,%rax,8)
jmp    1264 <ai_playertrade+0x114>
lea    0x0(,%r13,2),%rax
add    %r13,%rax
movl   $0x0,0x14(%r12,%rax,8)
lea    0x3(%rbx),%eax
lea    0x6(%rbx),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
neg    %ecx
lea    (%rbx,%rcx,1),%ebp
add    $0x3,%ebp
mov    %ebp,%edi
call   1060 <data_vps@plt>
mov    %ebp,0x38(%rsp)
movslq %ebp,%rbp
cmp    $0x7,%eax
mov    %r14d,0x3c(%rsp)
jge    12cb <ai_playertrade+0x17b>
lea    0x10(%rsp),%rcx
mov    0x40(%rsp),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <accepttrade@plt>
mov    %rbp,%r14
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
movdqa 0x10(%rsp),%xmm0
movdqu %xmm0,(%r12,%rax,8)
mov    0x20(%rsp),%rcx
mov    %rcx,0x10(%r12,%rax,8)
jmp    12e2 <ai_playertrade+0x192>
mov    %rbp,%r14
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
movl   $0x0,0x14(%r12,%rax,8)
lea    (%r15,%r15,2),%rbp
cmpl   $0x0,0x14(%r12,%rbp,8)
jle    1346 <ai_playertrade+0x1f6>
lea    0x10(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
call   1040 <gethand@plt>
movdqu (%r12,%rbp,8),%xmm0
movdqa 0x10(%rsp),%xmm1
psubd  %xmm0,%xmm1
movdqa %xmm1,0x10(%rsp)
mov    0x10(%r12,%rbp,8),%eax
sub    %eax,0x20(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
mov    %ebx,%r15d
cmp    0xc(%rsp),%eax
jle    1349 <ai_playertrade+0x1f9>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
mov    %eax,0xc(%rsp)
mov    0x34(%rsp),%r15d
jmp    1349 <ai_playertrade+0x1f9>
mov    %ebx,%r15d
lea    0x0(,%r13,2),%rbp
add    %r13,%rbp
cmpl   $0x0,0x14(%r12,%rbp,8)
jle    13af <ai_playertrade+0x25f>
lea    0x10(%rsp),%r13
mov    %ebx,%edi
mov    %r13,%rsi
call   1040 <gethand@plt>
movdqu (%r12,%rbp,8),%xmm0
movdqa 0x10(%rsp),%xmm1
psubd  %xmm0,%xmm1
movdqa %xmm1,0x10(%rsp)
mov    0x10(%r12,%rbp,8),%eax
sub    %eax,0x20(%rsp)
mov    %r13,%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
cmp    0xc(%rsp),%eax
jle    13af <ai_playertrade+0x25f>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
mov    %eax,0xc(%rsp)
mov    0x3c(%rsp),%r15d
lea    (%r14,%r14,2),%rbp
cmpl   $0x0,0x14(%r12,%rbp,8)
jle    140a <ai_playertrade+0x2ba>
lea    0x10(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <gethand@plt>
movdqu (%r12,%rbp,8),%xmm0
movdqa 0x10(%rsp),%xmm1
psubd  %xmm0,%xmm1
movdqa %xmm1,0x10(%rsp)
mov    0x10(%r12,%rbp,8),%eax
sub    %eax,0x20(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
cmp    0xc(%rsp),%eax
jle    140a <ai_playertrade+0x2ba>
lea    0x10(%rsp),%rdi
mov    %ebx,%esi
call   1070 <rate_hand@plt>
mov    0x38(%rsp),%r15d
movslq %r15d,%rbp
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
lea    (%r12,%rax,8),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <doTrade@plt>
xor    %eax,%eax
cmp    %ebx,%ebp
setne  %al
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ai_playertrade.trades = internal global [4 x [6 x i32]] zeroinitializer
define i32 @ai_playertrade(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [6 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca [5 x i32]
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %8
br label %13
13: ; preds = %23, %3
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %18
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6 x i32], [6 x i32]* %19, i64 0, i64 %21
store i32 0, i32* %22
br label %23
23: ; preds = %16
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %13
26: ; preds = %13
store i32 1, i32* %7
br label %27
27: ; preds = %76, %26
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 4
br i1 %29, label %30, label %79
30: ; preds = %27
%31 = load i32, i32* %4
%32 = load i32, i32* %7
%33 = add nsw i32 %31, %32
%34 = srem i32 %33, 4
%35 = call i32 @data_vps(i32 %34)
%36 = icmp slt i32 %35, 7
br i1 %36, label %37, label %67
37: ; preds = %30
%38 = load i32*, i32** %5
%39 = load i32, i32* %4
%40 = load i32, i32* %7
%41 = add nsw i32 %39, %40
%42 = srem i32 %41, 4
%43 = load i32, i32* %4
%44 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 0
%45 = call i32 @accepttrade(i32* %38, i32 %42, i32 %43, i32* %44)
store i32 0, i32* %8
br label %46
46: ; preds = %63, %37
%47 = load i32, i32* %8
%48 = icmp slt i32 %47, 6
br i1 %48, label %49, label %66
49: ; preds = %46
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [6 x i32], [6 x i32]* %9, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = load i32, i32* %4
%55 = load i32, i32* %7
%56 = add nsw i32 %54, %55
%57 = srem i32 %56, 4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %58
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [6 x i32], [6 x i32]* %59, i64 0, i64 %61
store i32 %53, i32* %62
br label %63
63: ; preds = %49
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %46
66: ; preds = %46
br label %75
67: ; preds = %30
%68 = load i32, i32* %4
%69 = load i32, i32* %7
%70 = add nsw i32 %68, %69
%71 = srem i32 %70, 4
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %72
%74 = getelementptr inbounds [6 x i32], [6 x i32]* %73, i64 0, i64 5
store i32 0, i32* %74
br label %75
75: ; preds = %67, %66
br label %76
76: ; preds = %75
%77 = load i32, i32* %7
%78 = add nsw i32 %77, 1
store i32 %78, i32* %7
br label %27
79: ; preds = %27
%80 = load i32, i32* %6
store i32 %80, i32* %10
%81 = load i32, i32* %4
store i32 %81, i32* %11
store i32 1, i32* %7
br label %82
82: ; preds = %137, %79
%83 = load i32, i32* %7
%84 = icmp slt i32 %83, 4
br i1 %84, label %85, label %140
85: ; preds = %82
%86 = load i32, i32* %4
%87 = load i32, i32* %7
%88 = add nsw i32 %86, %87
%89 = srem i32 %88, 4
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %90
%92 = getelementptr inbounds [6 x i32], [6 x i32]* %91, i64 0, i64 5
%93 = load i32, i32* %92
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %136
95: ; preds = %85
%96 = load i32, i32* %4
%97 = getelementptr inbounds [5 x i32], [5 x i32]* %12, i64 0, i64 0
%98 = call i32 @gethand(i32 %96, i32* %97)
store i32 0, i32* %8
br label %99
99: ; preds = %118, %95
%100 = load i32, i32* %8
%101 = icmp slt i32 %100, 5
br i1 %101, label %102, label %121
102: ; preds = %99
%103 = load i32, i32* %4
%104 = load i32, i32* %7
%105 = add nsw i32 %103, %104
%106 = srem i32 %105, 4
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %107
%109 = load i32, i32* %8
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [6 x i32], [6 x i32]* %108, i64 0, i64 %110
%112 = load i32, i32* %111
%113 = load i32, i32* %8
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [5 x i32], [5 x i32]* %12, i64 0, i64 %114
%116 = load i32, i32* %115
%117 = sub nsw i32 %116, %112
store i32 %117, i32* %115
br label %118
118: ; preds = %102
%119 = load i32, i32* %8
%120 = add nsw i32 %119, 1
store i32 %120, i32* %8
br label %99
121: ; preds = %99
%122 = getelementptr inbounds [5 x i32], [5 x i32]* %12, i64 0, i64 0
%123 = load i32, i32* %4
%124 = call i32 @rate_hand(i32* %122, i32 %123)
%125 = load i32, i32* %10
%126 = icmp sgt i32 %124, %125
br i1 %126, label %127, label %135
127: ; preds = %121
%128 = getelementptr inbounds [5 x i32], [5 x i32]* %12, i64 0, i64 0
%129 = load i32, i32* %4
%130 = call i32 @rate_hand(i32* %128, i32 %129)
store i32 %130, i32* %10
%131 = load i32, i32* %4
%132 = load i32, i32* %7
%133 = add nsw i32 %131, %132
%134 = srem i32 %133, 4
store i32 %134, i32* %11
br label %135
135: ; preds = %127, %121
br label %136
136: ; preds = %135, %85
br label %137
137: ; preds = %136
%138 = load i32, i32* %7
%139 = add nsw i32 %138, 1
store i32 %139, i32* %7
br label %82
140: ; preds = %82
%141 = load i32, i32* %11
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %142
%144 = getelementptr inbounds [6 x i32], [6 x i32]* %143, i64 0, i64 0
%145 = load i32, i32* %4
%146 = load i32, i32* %11
%147 = call i32 @doTrade(i32* %144, i32 %145, i32 %146)
%148 = load i32, i32* %11
%149 = load i32, i32* %4
%150 = icmp ne i32 %148, %149
%151 = zext i1 %150 to i32
ret i32 %151
}

LLVM IR (-O2):
@ai_playertrade.trades = internal global [4 x [6 x i32]] zeroinitializer
define i32 @ai_playertrade(i32 %0, i32* %1, i32 %2) {
%4 = alloca [6 x i32]
%5 = bitcast [6 x i32]* %4 to i8*
%6 = alloca [5 x i32]
%7 = sext i32 %0 to i64
%8 = getelementptr [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %7, i64 0
%9 = bitcast i32* %8 to i8*
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%11 = add nsw i32 %0, 1
%12 = srem i32 %11, 4
%13 = call i32 @data_vps(i32 %12)
%14 = icmp slt i32 %13, 7
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = call i32 @accepttrade(i32* %1, i32 %12, i32 %0, i32* %10)
%17 = sext i32 %12 to i64
%18 = getelementptr [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %17, i64 0
%19 = bitcast i32* %18 to i8*
br label %23
20: ; preds = %3
%21 = sext i32 %12 to i64
%22 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %21, i64 5
store i32 0, i32* %22
br label %23
23: ; preds = %15, %20
%24 = add nsw i32 %0, 2
%25 = srem i32 %24, 4
%26 = call i32 @data_vps(i32 %25)
%27 = icmp slt i32 %26, 7
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = sext i32 %25 to i64
%30 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %29, i64 5
store i32 0, i32* %30
br label %36
31: ; preds = %23
%32 = call i32 @accepttrade(i32* %1, i32 %25, i32 %0, i32* %10)
%33 = sext i32 %25 to i64
%34 = getelementptr [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %33, i64 0
%35 = bitcast i32* %34 to i8*
br label %36
36: ; preds = %31, %28
%37 = add nsw i32 %0, 3
%38 = srem i32 %37, 4
%39 = call i32 @data_vps(i32 %38)
%40 = icmp slt i32 %39, 7
br i1 %40, label %44, label %41
41: ; preds = %36
%42 = sext i32 %38 to i64
%43 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %42, i64 5
store i32 0, i32* %43
br label %49
44: ; preds = %36
%45 = call i32 @accepttrade(i32* %1, i32 %38, i32 %0, i32* %10)
%46 = sext i32 %38 to i64
%47 = getelementptr [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %46, i64 0
%48 = bitcast i32* %47 to i8*
br label %49
49: ; preds = %44, %41
%50 = bitcast [5 x i32]* %6 to i8*
%51 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%52 = sext i32 %12 to i64
%53 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %52, i64 5
%54 = load i32, i32* %53
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %74
56: ; preds = %49
%57 = call i32 @gethand(i32 %0, i32* %51)
%58 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %52, i64 0
%59 = bitcast i32* %58 to <4 x i32>*
%60 = load <4 x i32>, <4 x i32>* %59
%61 = bitcast [5 x i32]* %6 to <4 x i32>*
%62 = load <4 x i32>, <4 x i32>* %61
%63 = sub nsw <4 x i32> %62, %60
%64 = bitcast [5 x i32]* %6 to <4 x i32>*
store <4 x i32> %63, <4 x i32>* %64
%65 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %52, i64 4
%66 = load i32, i32* %65
%67 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 4
%68 = load i32, i32* %67
%69 = sub nsw i32 %68, %66
store i32 %69, i32* %67
%70 = call i32 @rate_hand(i32* %51, i32 %0)
%71 = icmp sgt i32 %70, %2
br i1 %71, label %72, label %74
72: ; preds = %56
%73 = call i32 @rate_hand(i32* %51, i32 %0)
br label %74
74: ; preds = %49, %72, %56
%75 = phi i32 [ %73, %72 ], [ %2, %56 ], [ %2, %49 ]
%76 = phi i32 [ %12, %72 ], [ %0, %56 ], [ %0, %49 ]
%77 = sext i32 %25 to i64
%78 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %77, i64 5
%79 = load i32, i32* %78
%80 = icmp sgt i32 %79, 0
br i1 %80, label %81, label %99
81: ; preds = %74
%82 = call i32 @gethand(i32 %0, i32* %51)
%83 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %77, i64 0
%84 = bitcast i32* %83 to <4 x i32>*
%85 = load <4 x i32>, <4 x i32>* %84
%86 = bitcast [5 x i32]* %6 to <4 x i32>*
%87 = load <4 x i32>, <4 x i32>* %86
%88 = sub nsw <4 x i32> %87, %85
%89 = bitcast [5 x i32]* %6 to <4 x i32>*
store <4 x i32> %88, <4 x i32>* %89
%90 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %77, i64 4
%91 = load i32, i32* %90
%92 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 4
%93 = load i32, i32* %92
%94 = sub nsw i32 %93, %91
store i32 %94, i32* %92
%95 = call i32 @rate_hand(i32* %51, i32 %0)
%96 = icmp sgt i32 %95, %75
br i1 %96, label %97, label %99
97: ; preds = %81
%98 = call i32 @rate_hand(i32* %51, i32 %0)
br label %99
99: ; preds = %97, %81, %74
%100 = phi i32 [ %98, %97 ], [ %75, %81 ], [ %75, %74 ]
%101 = phi i32 [ %25, %97 ], [ %76, %81 ], [ %76, %74 ]
%102 = sext i32 %38 to i64
%103 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %102, i64 5
%104 = load i32, i32* %103
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %124
106: ; preds = %99
%107 = call i32 @gethand(i32 %0, i32* %51)
%108 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %102, i64 0
%109 = bitcast i32* %108 to <4 x i32>*
%110 = load <4 x i32>, <4 x i32>* %109
%111 = bitcast [5 x i32]* %6 to <4 x i32>*
%112 = load <4 x i32>, <4 x i32>* %111
%113 = sub nsw <4 x i32> %112, %110
%114 = bitcast [5 x i32]* %6 to <4 x i32>*
store <4 x i32> %113, <4 x i32>* %114
%115 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %102, i64 4
%116 = load i32, i32* %115
%117 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 4
%118 = load i32, i32* %117
%119 = sub nsw i32 %118, %116
store i32 %119, i32* %117
%120 = call i32 @rate_hand(i32* %51, i32 %0)
%121 = icmp sgt i32 %120, %100
br i1 %121, label %122, label %124
122: ; preds = %106
%123 = call i32 @rate_hand(i32* %51, i32 %0)
br label %124
124: ; preds = %122, %106, %99
%125 = phi i32 [ %38, %122 ], [ %101, %106 ], [ %101, %99 ]
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [4 x [6 x i32]], [4 x [6 x i32]]* @ai_playertrade.trades, i64 0, i64 %126, i64 0
%128 = call i32 @doTrade(i32* %127, i32 %0, i32 %125)
%129 = icmp ne i32 %125, %0
%130 = zext i1 %129 to i32
ret i32 %130
}