#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_numplayers();
int /*<<< orphan*/ io_clearscreen();
int io_printcard(int, int, int, int, int);
int io_printdiscards(int, int /*<<< orphan*/, int, int);
int io_printhand(int, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ view_printwonders(int, int, int, int *);
int view_refresh(int focus, int cursor, int player, int mode) {
  int ret;
  int card[2];
  io_clearscreen();
  if (focus == data_numplayers()) {
    view_printwonders(player, -1, player, card);
  } else {
    view_printwonders((focus + player) % data_numplayers(), cursor, player,
                      card);
    cursor = -1;
  }
  if (mode)
    ret = io_printdiscards(61, 0, player, cursor);
  else
    ret = io_printhand(61, 0, player, cursor);
  if (card[0] != -1)
    ret = io_printcard(61, ret - 1, card[0], card[1], player);
  return ret;
}


x86 assembly (clang, -O0):
<view_refresh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0x0,%al
call   1070 <io_clearscreen@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1080 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jne    11ae <view_refresh+0x4e>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
lea    -0x1c(%rbp),%rcx
mov    $0xffffffff,%esi
call   1050 <view_printwonders@plt>
jmp    11de <view_refresh+0x7e>
mov    -0x4(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1080 <data_numplayers@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x1c(%rbp),%rcx
call   1050 <view_printwonders@plt>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1202 <view_refresh+0xa2>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0x3d,%edi
xor    %esi,%esi
call   1030 <io_printdiscards@plt>
mov    %eax,-0x14(%rbp)
jmp    1217 <view_refresh+0xb7>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    $0x3d,%edi
xor    %esi,%esi
call   1040 <io_printhand@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     123e <view_refresh+0xde>
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x3d,%edi
call   1060 <io_printcard@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<view_refresh>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebx
mov    %esi,%r15d
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <io_clearscreen@plt>
xor    %eax,%eax
call   1080 <data_numplayers@plt>
cmp    %ebp,%eax
jne    1196 <view_refresh+0x36>
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0xffffffff,%esi
mov    %ebx,%edx
call   1050 <view_printwonders@plt>
jmp    11bb <view_refresh+0x5b>
add    %ebx,%ebp
xor    %eax,%eax
call   1080 <data_numplayers@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%edi
mov    %rsp,%rcx
mov    %r15d,%esi
mov    %ebx,%edx
call   1050 <view_printwonders@plt>
mov    $0xffffffff,%r15d
mov    $0x3d,%edi
xor    %esi,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
test   %r14d,%r14d
je     11d3 <view_refresh+0x73>
call   1030 <io_printdiscards@plt>
jmp    11d8 <view_refresh+0x78>
call   1040 <io_printhand@plt>
mov    (%rsp),%edx
cmp    $0xffffffff,%edx
je     11f6 <view_refresh+0x96>
add    $0xffffffff,%eax
mov    0x4(%rsp),%ecx
mov    $0x3d,%edi
mov    %eax,%esi
mov    %ebx,%r8d
call   1060 <io_printcard@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @view_refresh(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 [2 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = call i32 (...) @io_clearscreen()
%12 = load i32, i32* %5
%13 = call i32 (...) @data_numplayers()
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = load i32, i32* %7
%17 = load i32, i32* %7
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%19 = call i32 @view_printwonders(i32 %16, i32 -1, i32 %17, i32* %18)
br label %30
20: ; preds = %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = add nsw i32 %21, %22
%24 = call i32 (...) @data_numplayers()
%25 = srem i32 %23, %24
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%29 = call i32 @view_printwonders(i32 %25, i32 %26, i32 %27, i32* %28)
store i32 -1, i32* %6
br label %30
30: ; preds = %20, %15
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %7
%35 = load i32, i32* %6
%36 = call i32 @io_printdiscards(i32 61, i32 0, i32 %34, i32 %35)
store i32 %36, i32* %9
br label %41
37: ; preds = %30
%38 = load i32, i32* %7
%39 = load i32, i32* %6
%40 = call i32 @io_printhand(i32 61, i32 0, i32 %38, i32 %39)
store i32 %40, i32* %9
br label %41
41: ; preds = %37, %33
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%43 = load i32, i32* %42
%44 = icmp ne i32 %43, -1
br i1 %44, label %45, label %54
45: ; preds = %41
%46 = load i32, i32* %9
%47 = sub nsw i32 %46, 1
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 1
%51 = load i32, i32* %50
%52 = load i32, i32* %7
%53 = call i32 @io_printcard(i32 61, i32 %47, i32 %49, i32 %51, i32 %52)
store i32 %53, i32* %9
br label %54
54: ; preds = %45, %41
%55 = load i32, i32* %9
ret i32 %55
}

LLVM IR (-O2):
define i32 @view_refresh(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [2 x i32]
%6 = bitcast [2 x i32]* %5 to i8*
%7 = tail call i32 (...) @io_clearscreen()
%8 = tail call i32 (...) @data_numplayers()
%9 = icmp eq i32 %8, %0
br i1 %9, label %10, label %13
10: ; preds = %4
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%12 = call i32 @view_printwonders(i32 %2, i32 -1, i32 %2, i32* %11)
br label %19
13: ; preds = %4
%14 = add nsw i32 %2, %0
%15 = tail call i32 (...) @data_numplayers()
%16 = srem i32 %14, %15
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%18 = call i32 @view_printwonders(i32 %16, i32 %1, i32 %2, i32* %17)
br label %19
19: ; preds = %13, %10
%20 = phi i32 [ %1, %10 ], [ -1, %13 ]
%21 = icmp eq i32 %3, 0
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @io_printdiscards(i32 61, i32 0, i32 %2, i32 %20)
br label %26
24: ; preds = %19
%25 = call i32 @io_printhand(i32 61, i32 0, i32 %2, i32 %20)
br label %26
26: ; preds = %24, %22
%27 = phi i32 [ %23, %22 ], [ %25, %24 ]
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, -1
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = add nsw i32 %27, -1
%33 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%34 = load i32, i32* %33
%35 = call i32 @io_printcard(i32 61, i32 %32, i32 %29, i32 %34, i32 %2)
br label %36
36: ; preds = %31, %26
%37 = phi i32 [ %35, %31 ], [ %27, %26 ]
ret i32 %37
}