#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_geteast(int);
int data_getwest(int);
int data_numplayers();
int /*<<< orphan*/ print_wonder(int, int /*<<< orphan*/, int, int, int *);
int print_wondersmall(int, int, int, int, int);
int /*<<< orphan*/ printmessage(int /*<<< orphan*/, int, int);
int write_history(int, int /*<<< orphan*/, int);
int *view_printwonders(int focus, int cursor, int player, int card[2]) {
  int num = data_numplayers();
  int x, y, i, dir, p;
  x = y = 0;
  for (i = 0; i < num; i++) {
    p = (player + i) % num;
    dir = 0;
    if (p == data_geteast(player))
      dir = 1;
    if (p == data_getwest(player))
      dir = 2;
    if (focus == p)
      print_wonder(34, 0, p, cursor, card);
    y = print_wondersmall(x, y, p, focus == p, dir);
  }
  y = write_history(focus, 0, y);
  printmessage(0, y + 2, 35);
  return card;
}


x86 assembly (clang, -O0):
<view_printwonders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    $0x0,%al
call   1090 <data_numplayers@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125b <view_printwonders+0xeb>
mov    -0xc(%rbp),%eax
add    -0x28(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <data_geteast@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jne    11e6 <view_printwonders+0x76>
movl   $0x1,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <data_getwest@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jne    1208 <view_printwonders+0x98>
movl   $0x2,-0x2c(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    122a <view_printwonders+0xba>
mov    -0x30(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8
mov    $0x22,%edi
xor    %esi,%esi
call   1040 <print_wonder@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x4(%rbp),%eax
cmp    -0x30(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x2c(%rbp),%r8d
call   1050 <print_wondersmall@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a4 <view_printwonders+0x34>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%edx
xor    %esi,%esi
call   1030 <write_history@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
add    $0x2,%esi
xor    %edi,%edi
mov    $0x23,%edx
call   1060 <printmessage@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_printwonders>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %esi,(%rsp)
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1090 <data_numplayers@plt>
test   %eax,%eax
jle    122a <view_printwonders+0xba>
mov    %eax,%r12d
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    11d4 <view_printwonders+0x64>
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    %ebx,%r14d
sete   %cl
xor    %edi,%edi
mov    0x4(%rsp),%esi
mov    %r14d,%edx
mov    %r15d,%r8d
call   1050 <print_wondersmall@plt>
mov    %eax,%ebp
add    $0x1,%r13d
cmp    %r13d,%r12d
je     122a <view_printwonders+0xba>
mov    %ebp,0x4(%rsp)
mov    0x10(%rsp),%rbp
lea    0x0(%rbp,%r13,1),%eax
cltd
idiv   %r12d
mov    %edx,%r14d
mov    %ebp,%edi
call   1080 <data_geteast@plt>
xor    %r15d,%r15d
cmp    %eax,%r14d
sete   %r15b
mov    %ebp,%edi
call   1070 <data_getwest@plt>
cmp    %eax,%r14d
mov    $0x2,%eax
cmove  %eax,%r15d
cmp    %ebx,%r14d
jne    11b0 <view_printwonders+0x40>
mov    $0x22,%edi
xor    %esi,%esi
mov    %ebx,%edx
mov    (%rsp),%ecx
mov    0x8(%rsp),%r8
call   1040 <print_wonder@plt>
jmp    11b0 <view_printwonders+0x40>
mov    %ebx,%edi
xor    %esi,%esi
mov    %ebp,%edx
call   1030 <write_history@plt>
lea    0x2(%rax),%esi
xor    %edi,%edi
mov    $0x23,%edx
call   1060 <printmessage@plt>
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @view_printwonders(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%15 = call i32 (...) @data_numplayers()
store i32 %15, i32* %9
store i32 0, i32* %11
store i32 0, i32* %10
store i32 0, i32* %12
br label %16
16: ; preds = %56, %4
%17 = load i32, i32* %12
%18 = load i32, i32* %9
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %59
20: ; preds = %16
%21 = load i32, i32* %7
%22 = load i32, i32* %12
%23 = add nsw i32 %21, %22
%24 = load i32, i32* %9
%25 = srem i32 %23, %24
store i32 %25, i32* %14
store i32 0, i32* %13
%26 = load i32, i32* %14
%27 = load i32, i32* %7
%28 = call i32 @data_geteast(i32 %27)
%29 = icmp eq i32 %26, %28
br i1 %29, label %30, label %31
30: ; preds = %20
store i32 1, i32* %13
br label %31
31: ; preds = %30, %20
%32 = load i32, i32* %14
%33 = load i32, i32* %7
%34 = call i32 @data_getwest(i32 %33)
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %31
store i32 2, i32* %13
br label %37
37: ; preds = %36, %31
%38 = load i32, i32* %5
%39 = load i32, i32* %14
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32, i32* %14
%43 = load i32, i32* %6
%44 = load i32*, i32** %8
%45 = call i32 @print_wonder(i32 34, i32 0, i32 %42, i32 %43, i32* %44)
br label %46
46: ; preds = %41, %37
%47 = load i32, i32* %10
%48 = load i32, i32* %11
%49 = load i32, i32* %14
%50 = load i32, i32* %5
%51 = load i32, i32* %14
%52 = icmp eq i32 %50, %51
%53 = zext i1 %52 to i32
%54 = load i32, i32* %13
%55 = call i32 @print_wondersmall(i32 %47, i32 %48, i32 %49, i32 %53, i32 %54)
store i32 %55, i32* %11
br label %56
56: ; preds = %46
%57 = load i32, i32* %12
%58 = add nsw i32 %57, 1
store i32 %58, i32* %12
br label %16
59: ; preds = %16
%60 = load i32, i32* %5
%61 = load i32, i32* %11
%62 = call i32 @write_history(i32 %60, i32 0, i32 %61)
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 2
%65 = call i32 @printmessage(i32 0, i32 %64, i32 35)
%66 = load i32*, i32** %8
ret i32* %66
}

LLVM IR (-O2):
define i32* @view_printwonders(i32 %0, i32 %1, i32 %2, i32* returned %3) {
%5 = tail call i32 (...) @data_numplayers()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %4, %21
%8 = phi i32 [ %23, %21 ], [ 0, %4 ]
%9 = phi i32 [ %24, %21 ], [ 0, %4 ]
%10 = add nsw i32 %9, %2
%11 = srem i32 %10, %5
%12 = tail call i32 @data_geteast(i32 %2)
%13 = icmp eq i32 %11, %12
%14 = zext i1 %13 to i32
%15 = tail call i32 @data_getwest(i32 %2)
%16 = icmp eq i32 %11, %15
%17 = select i1 %16, i32 2, i32 %14
%18 = icmp eq i32 %11, %0
br i1 %18, label %19, label %21
19: ; preds = %7
%20 = tail call i32 @print_wonder(i32 34, i32 0, i32 %0, i32 %1, i32* %3)
br label %21
21: ; preds = %19, %7
%22 = zext i1 %18 to i32
%23 = tail call i32 @print_wondersmall(i32 0, i32 %8, i32 %11, i32 %22, i32 %17)
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, %5
br i1 %25, label %26, label %7
26: ; preds = %21, %4
%27 = phi i32 [ 0, %4 ], [ %23, %21 ]
%28 = tail call i32 @write_history(i32 %0, i32 0, i32 %27)
%29 = add nsw i32 %28, 2
%30 = tail call i32 @printmessage(i32 0, i32 %29, i32 35)
ret i32* %3
}