#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 */
char *cards_getname(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int data_getgold(int);
int data_gettotvps(int);
int /*<<< orphan*/ data_getwonder(int);
int /*<<< orphan*/ io_printborder(int, int, int);
int /*<<< orphan*/ io_printplain(int, int, char *);
int io_printtext(int, int, int, char *);
int military_might(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int print_wondersmall(int x, int y, int player, int selected, int dir) {
  char s[28];
  io_printborder(x, y++, 28);
  if (selected)
    io_printplain(28, y, "*");
  if (dir == 1)
    io_printplain(29, y, "East");
  if (dir == 2)
    io_printplain(29, y, "West");
  char array[40];
  y = io_printtext(x, y, 28, cards_getname(data_getwonder(player), 0, array));
  sprintf(s, "army: %-2d vps: %-2d gold: %-2d", military_might(player),
          data_gettotvps(player), data_getgold(player));
  y = io_printtext(x, y, 28, s);
  io_printborder(x, y, 28);
  return y;
}


x86 assembly (clang, -O0):
<print_wondersmall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
cmpl   $0x0,-0x10(%rbp)
je     11e1 <print_wondersmall+0x51>
mov    -0x8(%rbp),%esi
mov    $0x1c,%edi
lea    0xe24(%rip),%rdx
call   1080 <io_printplain@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11ff <print_wondersmall+0x6f>
mov    -0x8(%rbp),%esi
mov    $0x1d,%edi
lea    0xe08(%rip),%rdx
call   1080 <io_printplain@plt>
cmpl   $0x2,-0x14(%rbp)
jne    121d <print_wondersmall+0x8d>
mov    -0x8(%rbp),%esi
mov    $0x1d,%edi
lea    0xdef(%rip),%rdx
call   1080 <io_printplain@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <data_getwonder@plt>
mov    %eax,%edi
lea    -0x60(%rbp),%rdx
xor    %esi,%esi
call   1090 <cards_getname@plt>
mov    -0x78(%rbp),%edi
mov    -0x74(%rbp),%esi
mov    %rax,%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <military_might@plt>
mov    %eax,-0x68(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <data_gettotvps@plt>
mov    %eax,-0x64(%rbp)
mov    -0xc(%rbp),%edi
call   10a0 <data_getgold@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%edx
mov    -0x64(%rbp),%ecx
mov    %eax,%r8d
lea    0xd7e(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x30(%rbp),%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
mov    -0x8(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_wondersmall>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %edi,%r15d
lea    0x1(%rsi),%r14d
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
test   %ebp,%ebp
je     11cd <print_wondersmall+0x3d>
lea    0xe40(%rip),%rdx
mov    $0x1c,%edi
mov    %r14d,%esi
call   1080 <io_printplain@plt>
cmp    $0x1,%ebx
je     11e0 <print_wondersmall+0x50>
cmp    $0x2,%ebx
jne    11f4 <print_wondersmall+0x64>
lea    0xe29(%rip),%rdx
jmp    11e7 <print_wondersmall+0x57>
lea    0xe1b(%rip),%rdx
mov    $0x1d,%edi
mov    %r14d,%esi
call   1080 <io_printplain@plt>
mov    %r12d,%edi
call   1050 <data_getwonder@plt>
lea    0x20(%rsp),%rdx
mov    %eax,%edi
xor    %esi,%esi
call   1090 <cards_getname@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r14d
mov    %r12d,%edi
call   1060 <military_might@plt>
mov    %eax,%ebp
mov    %r12d,%edi
call   1070 <data_gettotvps@plt>
mov    %eax,%ebx
mov    %r12d,%edi
call   10a0 <data_getgold@plt>
lea    0xdc9(%rip),%rsi
mov    %rsp,%r12
mov    %r12,%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
call   10b0 <sprintf@plt>
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x1c,%edx
mov    %r12,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %eax,%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [5 x i8] c"East\00"
@.str.2 = [5 x i8] c"West\00"
@.str.3 = [32 x i8] c"army: %-2d vps: %-2d gold: %-2d\00"
define i32 @print_wondersmall(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [28 x i8]
%12 = alloca [40 x i8]
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = add nsw i32 %14, 1
store i32 %15, i32* %7
%16 = call i32 @io_printborder(i32 %13, i32 %14, i32 28)
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %5
%20 = load i32, i32* %7
%21 = call i32 @io_printplain(i32 28, i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %19, %5
%23 = load i32, i32* %10
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %7
%27 = call i32 @io_printplain(i32 29, i32 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %22
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %7
%33 = call i32 @io_printplain(i32 29, i32 %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call i32 @data_getwonder(i32 %37)
%39 = getelementptr inbounds [40 x i8], [40 x i8]* %12, i64 0, i64 0
%40 = call i8* @cards_getname(i32 %38, i32 0, i8* %39)
%41 = call i32 @io_printtext(i32 %35, i32 %36, i32 28, i8* %40)
store i32 %41, i32* %7
%42 = getelementptr inbounds [28 x i8], [28 x i8]* %11, i64 0, i64 0
%43 = load i32, i32* %8
%44 = call i32 @military_might(i32 %43)
%45 = load i32, i32* %8
%46 = call i32 @data_gettotvps(i32 %45)
%47 = load i32, i32* %8
%48 = call i32 @data_getgold(i32 %47)
%49 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %46, i32 %48)
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = getelementptr inbounds [28 x i8], [28 x i8]* %11, i64 0, i64 0
%53 = call i32 @io_printtext(i32 %50, i32 %51, i32 28, i8* %52)
store i32 %53, i32* %7
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = call i32 @io_printborder(i32 %54, i32 %55, i32 28)
%57 = load i32, i32* %7
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@.str.1 = [5 x i8] c"East\00"
@.str.2 = [5 x i8] c"West\00"
@.str.3 = [32 x i8] c"army: %-2d vps: %-2d gold: %-2d\00"
define i32 @print_wondersmall(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [28 x i8]
%7 = alloca [40 x i8]
%8 = getelementptr inbounds [28 x i8], [28 x i8]* %6, i64 0, i64 0
%9 = add nsw i32 %1, 1
%10 = tail call i32 @io_printborder(i32 %0, i32 %1, i32 28)
%11 = icmp eq i32 %3, 0
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = tail call i32 @io_printplain(i32 28, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
switch i32 %4, label %19 [
i32 1, label %16
i32 2, label %15
]
15: ; preds = %14
br label %16
16: ; preds = %14, %15
%17 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %14 ]
%18 = tail call i32 @io_printplain(i32 29, i32 %9, i8* %17)
br label %19
19: ; preds = %16, %14
%20 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%21 = tail call i32 @data_getwonder(i32 %2)
%22 = call i8* @cards_getname(i32 %21, i32 0, i8* %20)
%23 = call i32 @io_printtext(i32 %0, i32 %9, i32 28, i8* %22)
%24 = call i32 @military_might(i32 %2)
%25 = call i32 @data_gettotvps(i32 %2)
%26 = call i32 @data_getgold(i32 %2)
%27 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
%28 = call i32 @io_printtext(i32 %0, i32 %23, i32 28, i8* %8)
%29 = call i32 @io_printborder(i32 %0, i32 %28, i32 28)
ret i32 %28
}