#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*/ clearmessage();
int data_numbuilt(int);
int data_numcards(int);
int data_numplayers();
int /*<<< orphan*/ halt();
int io_getkey();
int /*<<< orphan*/ player_build(int, int, int, int);
int /*<<< orphan*/ posthelp();
int /*<<< orphan*/ postyn(int, int, char *);
int /*<<< orphan*/ trade_commit(int);
scalar_t__ trade_routine(int, int, int);
int view_refresh(int, int, int, int /*<<< orphan*/);
int wonder_numstages(int);
void player_turn(int player) {
  int numcards, tradey;
  int cursor = 0;
  int focus = data_numplayers();
  while (1) {
    numcards = data_numcards(player) + 1;
    tradey = view_refresh(focus, cursor, player, 0);
    switch (io_getkey()) {
    case 2:
      cursor--;
      break;
    case 3:
      cursor++;
      break;
    case 1:
      focus++;
      cursor = 0;
      break;
    case 0:
      focus--;
      cursor = 0;
      break;
    case 4:
      if (player_build(focus, cursor, player, tradey)) {
        trade_commit(player);
        clearmessage();
        return;
      }
      break;
    case '\t':
      focus = (focus + 1) % (data_numplayers() + 1);
      cursor = 0;
      break;
    case 'h':
      posthelp();
      break;
    case 'q':
      if (postyn(61, tradey, "Are you sure you want to quit?"))
        halt();
      break;
    default:
      break;
    }
    if (focus < 0)
      focus = data_numplayers();
    focus = focus % (data_numplayers() + 1);
    if (focus == data_numplayers()) {
      if (cursor < 0)
        cursor = numcards - 2;
      if (cursor >= numcards - 1) {
        if (trade_routine(61, view_refresh(focus, cursor, player, 0), player))
          cursor = 0;
        else
          cursor = numcards - 2;
      }
    } else {
      if (cursor < 0)
        cursor = wonder_numstages((player + focus) % data_numplayers()) +
                 data_numbuilt(player + focus % data_numplayers()) - 1;
      cursor =
          cursor % (wonder_numstages((player + focus) % data_numplayers()) +
                    data_numbuilt(player + focus % data_numplayers()));
    }
  }
}


x86 assembly (clang, -O0):
<player_turn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
call   1090 <data_numcards@plt>
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
xor    %ecx,%ecx
mov    %ecx,-0x1c(%rbp)
call   10c0 <view_refresh@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
mov    %ecx,-0xc(%rbp)
call   1060 <io_getkey@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
test   %eax,%eax
je     12d4 <player_turn+0x104>
jmp    122c <player_turn+0x5c>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     12bf <player_turn+0xef>
jmp    123d <player_turn+0x6d>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     12a3 <player_turn+0xd3>
jmp    124e <player_turn+0x7e>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     12b1 <player_turn+0xe1>
jmp    125f <player_turn+0x8f>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     12e9 <player_turn+0x119>
jmp    1270 <player_turn+0xa0>
mov    -0x18(%rbp),%eax
sub    $0x9,%eax
je     131d <player_turn+0x14d>
jmp    1281 <player_turn+0xb1>
mov    -0x18(%rbp),%eax
sub    $0x68,%eax
je     1347 <player_turn+0x177>
jmp    1292 <player_turn+0xc2>
mov    -0x18(%rbp),%eax
sub    $0x71,%eax
je     1353 <player_turn+0x183>
jmp    137c <player_turn+0x1ac>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1381 <player_turn+0x1b1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1381 <player_turn+0x1b1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1381 <player_turn+0x1b1>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1381 <player_turn+0x1b1>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <player_build@plt>
cmp    $0x0,%eax
je     1318 <player_turn+0x148>
mov    -0x4(%rbp),%edi
call   1030 <trade_commit@plt>
mov    $0x0,%al
call   10d0 <clearmessage@plt>
add    $0x50,%rsp
pop    %rbp
ret
jmp    1381 <player_turn+0x1b1>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1381 <player_turn+0x1b1>
mov    $0x0,%al
call   1070 <posthelp@plt>
jmp    1381 <player_turn+0x1b1>
mov    -0xc(%rbp),%esi
mov    $0x3d,%edi
lea    0xc9e(%rip),%rdx
call   10b0 <postyn@plt>
cmp    $0x0,%eax
je     1377 <player_turn+0x1a7>
mov    $0x0,%al
call   10a0 <halt@plt>
jmp    1381 <player_turn+0x1b1>
jmp    1381 <player_turn+0x1b1>
cmpl   $0x0,-0x14(%rbp)
jge    1395 <player_turn+0x1c5>
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    $0x1,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jne    1436 <player_turn+0x266>
cmpl   $0x0,-0x10(%rbp)
jge    13dd <player_turn+0x20d>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1431 <player_turn+0x261>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x4(%rbp),%edx
xor    %ecx,%ecx
call   10c0 <view_refresh@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
mov    $0x3d,%edi
call   10e0 <trade_routine@plt>
cmp    $0x0,%rax
je     1423 <player_turn+0x253>
movl   $0x0,-0x10(%rbp)
jmp    142c <player_turn+0x25c>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1431 <player_turn+0x261>
jmp    14f1 <player_turn+0x321>
cmpl   $0x0,-0x10(%rbp)
jge    1494 <player_turn+0x2c4>
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <wonder_numstages@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cltd
idiv   %ecx
add    %edx,%edi
call   1080 <data_numbuilt@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x4(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <wonder_numstages@plt>
mov    %eax,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    $0x0,%al
call   10f0 <data_numplayers@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cltd
idiv   %ecx
add    %edx,%edi
call   1080 <data_numbuilt@plt>
mov    -0x40(%rbp),%ecx
mov    %eax,%edx
mov    -0x3c(%rbp),%eax
add    %edx,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
jmp    11ec <player_turn+0x1c>

x86 assembly (clang, -O2):
<player_turn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ebx
lea    0xe12(%rip),%r14
xor    %r13d,%r13d
jmp    1249 <player_turn+0x79>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%ebp
add    %r15d,%ebp
test   %r13d,%r13d
js     12d1 <player_turn+0x101>
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <wonder_numstages@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
lea    (%rdx,%r15,1),%edi
call   1080 <data_numbuilt@plt>
mov    %eax,%ecx
add    %ebp,%ecx
mov    %r13d,%eax
cltd
idiv   %ecx
mov    %edx,%r13d
mov    %r15d,%edi
call   1090 <data_numcards@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r15d,%edx
xor    %ecx,%ecx
call   10c0 <view_refresh@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <io_getkey@plt>
cmp    $0x9,%eax
ja     1290 <player_turn+0xc0>
mov    %eax,%eax
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
add    $0xffffffff,%ebx
jmp    1310 <player_turn+0x140>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x68,%eax
je     13eb <player_turn+0x21b>
cmp    $0x71,%eax
jne    1350 <player_turn+0x180>
mov    $0x3d,%edi
mov    %ebp,%esi
lea    0xd78(%rip),%rdx
call   10b0 <postyn@plt>
test   %eax,%eax
je     1350 <player_turn+0x180>
xor    %eax,%eax
call   10a0 <halt@plt>
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%edi
call   1050 <wonder_numstages@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
lea    (%rdx,%r15,1),%edi
call   1080 <data_numbuilt@plt>
lea    (%r12,%rax,1),%r13d
add    $0xffffffff,%r13d
jmp    120e <player_turn+0x3e>
add    $0x1,%ebx
xor    %r13d,%r13d
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
add    $0x1,%r13d
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
add    $0xffffffff,%r13d
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
call   1040 <player_build@plt>
test   %eax,%eax
jne    13ff <player_turn+0x22f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %edx,%ebx
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
cmp    %eax,%ebx
jne    1200 <player_turn+0x30>
lea    -0x1(%r12),%ebp
test   %r13d,%r13d
cmovs  %ebp,%r13d
cmp    %r12d,%r13d
jl     1249 <player_turn+0x79>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r15d,%edx
xor    %ecx,%ecx
call   10c0 <view_refresh@plt>
mov    $0x3d,%edi
mov    %eax,%esi
mov    %r15d,%edx
call   10e0 <trade_routine@plt>
test   %rax,%rax
mov    $0x0,%eax
cmovne %eax,%ebp
mov    %ebp,%r13d
jmp    1249 <player_turn+0x79>
add    $0x1,%ebx
xor    %r13d,%r13d
xor    %eax,%eax
call   10f0 <data_numplayers@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %edx,%ebx
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
xor    %eax,%eax
call   1070 <posthelp@plt>
test   %ebx,%ebx
jns    135d <player_turn+0x18d>
jmp    1354 <player_turn+0x184>
mov    %r15d,%edi
call   1030 <trade_commit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <clearmessage@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Are you sure you want to quit?\00"
define void @player_turn(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %5
%7 = call i32 (...) @data_numplayers()
store i32 %7, i32* %6
br label %8
8: ; preds = %1, %129
%9 = load i32, i32* %2
%10 = call i32 @data_numcards(i32 %9)
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = call i32 @view_refresh(i32 %12, i32 %13, i32 %14, i32 0)
store i32 %15, i32* %4
%16 = call i32 (...) @io_getkey()
switch i32 %16, label %56 [
i32 2, label %17
i32 3, label %20
i32 1, label %23
i32 0, label %26
i32 4, label %29
i32 9, label %41
i32 104, label %47
i32 113, label %49
]
17: ; preds = %8
%18 = load i32, i32* %5
%19 = add nsw i32 %18, -1
store i32 %19, i32* %5
br label %57
20: ; preds = %8
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %57
23: ; preds = %8
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
store i32 0, i32* %5
br label %57
26: ; preds = %8
%27 = load i32, i32* %6
%28 = add nsw i32 %27, -1
store i32 %28, i32* %6
store i32 0, i32* %5
br label %57
29: ; preds = %8
%30 = load i32, i32* %6
%31 = load i32, i32* %5
%32 = load i32, i32* %2
%33 = load i32, i32* %4
%34 = call i32 @player_build(i32 %30, i32 %31, i32 %32, i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = load i32, i32* %2
%38 = call i32 @trade_commit(i32 %37)
%39 = call i32 (...) @clearmessage()
ret void
40: ; preds = %29
br label %57
41: ; preds = %8
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
%44 = call i32 (...) @data_numplayers()
%45 = add nsw i32 %44, 1
%46 = srem i32 %43, %45
store i32 %46, i32* %6
store i32 0, i32* %5
br label %57
47: ; preds = %8
%48 = call i32 (...) @posthelp()
br label %57
49: ; preds = %8
%50 = load i32, i32* %4
%51 = call i32 @postyn(i32 61, i32 %50, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = call i32 (...) @halt()
br label %55
55: ; preds = %53, %49
br label %57
56: ; preds = %8
br label %57
57: ; preds = %56, %55, %47, %41, %40, %26, %23, %20, %17
%58 = load i32, i32* %6
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = call i32 (...) @data_numplayers()
store i32 %61, i32* %6
br label %62
62: ; preds = %60, %57
%63 = load i32, i32* %6
%64 = call i32 (...) @data_numplayers()
%65 = add nsw i32 %64, 1
%66 = srem i32 %63, %65
store i32 %66, i32* %6
%67 = load i32, i32* %6
%68 = call i32 (...) @data_numplayers()
%69 = icmp eq i32 %67, %68
br i1 %69, label %70, label %95
70: ; preds = %62
%71 = load i32, i32* %5
%72 = icmp slt i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* %3
%75 = sub nsw i32 %74, 2
store i32 %75, i32* %5
br label %76
76: ; preds = %73, %70
%77 = load i32, i32* %5
%78 = load i32, i32* %3
%79 = sub nsw i32 %78, 1
%80 = icmp sge i32 %77, %79
br i1 %80, label %81, label %94
81: ; preds = %76
%82 = load i32, i32* %6
%83 = load i32, i32* %5
%84 = load i32, i32* %2
%85 = call i32 @view_refresh(i32 %82, i32 %83, i32 %84, i32 0)
%86 = load i32, i32* %2
%87 = call i64 @trade_routine(i32 61, i32 %85, i32 %86)
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %81
store i32 0, i32* %5
br label %93
90: ; preds = %81
%91 = load i32, i32* %3
%92 = sub nsw i32 %91, 2
store i32 %92, i32* %5
br label %93
93: ; preds = %90, %89
br label %94
94: ; preds = %93, %76
br label %129
95: ; preds = %62
%96 = load i32, i32* %5
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %113
98: ; preds = %95
%99 = load i32, i32* %2
%100 = load i32, i32* %6
%101 = add nsw i32 %99, %100
%102 = call i32 (...) @data_numplayers()
%103 = srem i32 %101, %102
%104 = call i32 @wonder_numstages(i32 %103)
%105 = load i32, i32* %2
%106 = load i32, i32* %6
%107 = call i32 (...) @data_numplayers()
%108 = srem i32 %106, %107
%109 = add nsw i32 %105, %108
%110 = call i32 @data_numbuilt(i32 %109)
%111 = add nsw i32 %104, %110
%112 = sub nsw i32 %111, 1
store i32 %112, i32* %5
br label %113
113: ; preds = %98, %95
%114 = load i32, i32* %5
%115 = load i32, i32* %2
%116 = load i32, i32* %6
%117 = add nsw i32 %115, %116
%118 = call i32 (...) @data_numplayers()
%119 = srem i32 %117, %118
%120 = call i32 @wonder_numstages(i32 %119)
%121 = load i32, i32* %2
%122 = load i32, i32* %6
%123 = call i32 (...) @data_numplayers()
%124 = srem i32 %122, %123
%125 = add nsw i32 %121, %124
%126 = call i32 @data_numbuilt(i32 %125)
%127 = add nsw i32 %120, %126
%128 = srem i32 %114, %127
store i32 %128, i32* %5
br label %129
129: ; preds = %113, %94
br label %8
}

LLVM IR (-O2):
@.str = [31 x i8] c"Are you sure you want to quit?\00"
define void @player_turn(i32 %0) {
%2 = tail call i32 (...) @data_numplayers()
br label %3
3: ; preds = %58, %1
%4 = phi i32 [ 0, %1 ], [ %59, %58 ]
%5 = phi i32 [ %2, %1 ], [ %45, %58 ]
%6 = tail call i32 @data_numcards(i32 %0)
%7 = tail call i32 @view_refresh(i32 %5, i32 %4, i32 %0, i32 0)
%8 = tail call i32 (...) @io_getkey()
switch i32 %8, label %35 [
i32 2, label %9
i32 3, label %11
i32 1, label %13
i32 0, label %15
i32 4, label %17
i32 9, label %23
i32 104, label %28
i32 113, label %30
]
9: ; preds = %3
%10 = add nsw i32 %4, -1
br label %35
11: ; preds = %3
%12 = add nsw i32 %4, 1
br label %35
13: ; preds = %3
%14 = add nsw i32 %5, 1
br label %35
15: ; preds = %3
%16 = add nsw i32 %5, -1
br label %35
17: ; preds = %3
%18 = tail call i32 @player_build(i32 %5, i32 %4, i32 %0, i32 %7)
%19 = icmp eq i32 %18, 0
br i1 %19, label %35, label %20
20: ; preds = %17
%21 = tail call i32 @trade_commit(i32 %0)
%22 = tail call i32 (...) @clearmessage()
ret void
23: ; preds = %3
%24 = add nsw i32 %5, 1
%25 = tail call i32 (...) @data_numplayers()
%26 = add nsw i32 %25, 1
%27 = srem i32 %24, %26
br label %35
28: ; preds = %3
%29 = tail call i32 (...) @posthelp()
br label %35
30: ; preds = %3
%31 = tail call i32 @postyn(i32 61, i32 %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 (...) @halt()
br label %35
35: ; preds = %3, %30, %33, %17, %28, %23, %15, %13, %11, %9
%36 = phi i32 [ %4, %3 ], [ %4, %33 ], [ %4, %30 ], [ %4, %28 ], [ 0, %23 ], [ %4, %17 ], [ 0, %15 ], [ 0, %13 ], [ %12, %11 ], [ %10, %9 ]
%37 = phi i32 [ %5, %3 ], [ %5, %33 ], [ %5, %30 ], [ %5, %28 ], [ %27, %23 ], [ %5, %17 ], [ %16, %15 ], [ %14, %13 ], [ %5, %11 ], [ %5, %9 ]
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = tail call i32 (...) @data_numplayers()
br label %41
41: ; preds = %39, %35
%42 = phi i32 [ %40, %39 ], [ %37, %35 ]
%43 = tail call i32 (...) @data_numplayers()
%44 = add nsw i32 %43, 1
%45 = srem i32 %42, %44
%46 = tail call i32 (...) @data_numplayers()
%47 = icmp eq i32 %45, %46
%48 = icmp slt i32 %36, 0
br i1 %47, label %49, label %60
49: ; preds = %41
%50 = add nsw i32 %6, -1
%51 = select i1 %48, i32 %50, i32 %36
%52 = icmp slt i32 %51, %6
br i1 %52, label %58, label %53
53: ; preds = %49
%54 = tail call i32 @view_refresh(i32 %45, i32 %51, i32 %0, i32 0)
%55 = tail call i64 @trade_routine(i32 61, i32 %54, i32 %0)
%56 = icmp eq i64 %55, 0
%57 = select i1 %56, i32 %50, i32 0
br label %58
58: ; preds = %53, %49, %72
%59 = phi i32 [ %51, %49 ], [ %82, %72 ], [ %57, %53 ]
br label %3
60: ; preds = %41
%61 = add nsw i32 %45, %0
br i1 %48, label %62, label %72
62: ; preds = %60
%63 = tail call i32 (...) @data_numplayers()
%64 = srem i32 %61, %63
%65 = tail call i32 @wonder_numstages(i32 %64)
%66 = tail call i32 (...) @data_numplayers()
%67 = srem i32 %45, %66
%68 = add nsw i32 %67, %0
%69 = tail call i32 @data_numbuilt(i32 %68)
%70 = add i32 %65, -1
%71 = add i32 %70, %69
br label %72
72: ; preds = %60, %62
%73 = phi i32 [ %71, %62 ], [ %36, %60 ]
%74 = tail call i32 (...) @data_numplayers()
%75 = srem i32 %61, %74
%76 = tail call i32 @wonder_numstages(i32 %75)
%77 = tail call i32 (...) @data_numplayers()
%78 = srem i32 %45, %77
%79 = add nsw i32 %78, %0
%80 = tail call i32 @data_numbuilt(i32 %79)
%81 = add nsw i32 %80, %76
%82 = srem i32 %73, %81
br label %58
}