#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, int /*<<< orphan*/, char *);
size_t cards_gettype(int, int /*<<< orphan*/);
char *cat(char *, char *);
int *data_getbuilt(int);
int /*<<< orphan*/ data_getdefinites(int, int *);
int data_getgold(int);
int **data_getindefinites(int);
int data_getwonder(int);
int data_getwonderside(int);
int data_getwonderstages(int);
char *getname(int);
int /*<<< orphan*/ io_printborder(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ io_printplain(int, int, char *);
int io_printtext(int, int, int, char *);
char *itoa(int);
int print_cards(int, int, int *, int);
int wonder_numstages(int);
int *print_wonder(int x, int y, int player, int cursor, int ret[2]) {
  int i, j;
  char array[40];
  io_printborder(x, y++, 28);
  y = io_printtext(x, y, 28, cards_getname(data_getwonder(player), 0, array));
  y = io_printtext(
      x, y, 28,
      cat("Produces: 1 ", getname(cards_gettype(data_getwonder(player), 0))));
  y = io_printtext(x, y, 28,
                   cat(cat("Treasury: ", itoa(data_getgold(player))), " gold"));
  io_printborder(x, y++, 28);
  int def[7];
  data_getdefinites(player, def);
  def[cards_gettype(data_getwonder(player), 0)]++;
  int **indef = data_getindefinites(player);
  y = io_printtext(x, y, 28, "Production:");
  for (i = 0; i < 7; i++) {
    if (def[i]) {
      y = io_printtext(x, y, 28,
                       cat(cat(cat(" ", getname(i)), ": "), itoa(def[i])));
    }
  }
  for (i = 0; i < 8; i++) {
    char *text = "";
    for (j = 0; j < 4; j++) {
      if (indef[i][j] != -1)
        text = cat(cat(text, "/"), getname(indef[i][j]));
    }
    if (text[0] != '\0') {
      y = io_printtext(x, y, 28, text);
      io_printplain(x + 2, y - 1, " ");
    }
  }
  io_printborder(x, y++, 28);
  for (i = 0; i < wonder_numstages(player); i++) {
    char *text = cat("Stage ", itoa(i + 1));
    if (data_getwonderstages(player) > i)
      text = cat(text, " (complete)");
    else
      text = cat(text, "           ");
    if (cursor == i)
      text = cat(text, "     *");
    else
      text = cat(text, "  ");
    y = io_printtext(x, y, 28, text);
  }
  io_printborder(x, y++, 28);
  int *built = data_getbuilt(player);
  y = print_cards(x, y, built, cursor - i);
  int print = 2 * (cursor - i);
  ret[0] = ret[1] = -1;
  if (cursor >= 0 && cursor < wonder_numstages(player)) {
    ret[0] = data_getwonder(player);
    ret[1] = cursor + 1 + 3 * data_getwonderside(player);
  }
  if (cursor >= wonder_numstages(player)) {
    ret[0] = built[print];
    ret[1] = built[print + 1];
  }
  return ret;
}


x86 assembly (clang, -O0):
<print_wonder>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <data_getwonder@plt>
mov    %eax,%edi
lea    -0x50(%rbp),%rdx
xor    %esi,%esi
call   10e0 <cards_getname@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%esi
mov    %rax,%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <data_getwonder@plt>
mov    %eax,%edi
xor    %esi,%esi
call   10d0 <cards_gettype@plt>
mov    %eax,%edi
call   10a0 <getname@plt>
mov    %rax,%rsi
lea    0xd46(%rip),%rdi
call   1130 <cat@plt>
mov    -0xa4(%rbp),%edi
mov    -0xa0(%rbp),%esi
mov    %rax,%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0xc(%rbp),%edi
call   10f0 <data_getgold@plt>
mov    %eax,%edi
call   1100 <itoa@plt>
mov    %rax,%rsi
lea    0xd07(%rip),%rdi
call   1130 <cat@plt>
mov    %rax,%rdi
lea    0xd03(%rip),%rsi
call   1130 <cat@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%esi
mov    %rax,%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    -0xc(%rbp),%edi
lea    -0x70(%rbp),%rsi
call   1120 <data_getdefinites@plt>
mov    -0xc(%rbp),%edi
call   1080 <data_getwonder@plt>
mov    %eax,%edi
xor    %esi,%esi
call   10d0 <cards_gettype@plt>
mov    -0x70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0xc(%rbp),%edi
call   10b0 <data_getindefinites@plt>
mov    %rax,-0x78(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1c,%edx
lea    0xc8a(%rip),%rcx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jge    1446 <print_wonder+0x236>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x70(%rbp,%rax,4)
je     1433 <print_wonder+0x223>
mov    -0x4(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <getname@plt>
mov    %rax,%rsi
lea    0xc69(%rip),%rdi
call   1130 <cat@plt>
mov    %rax,%rdi
lea    0xc26(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0xc0(%rbp)
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edi
call   1100 <itoa@plt>
mov    -0xc0(%rbp),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%esi
mov    %rax,%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
jmp    1438 <print_wonder+0x228>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13a3 <print_wonder+0x193>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1534 <print_wonder+0x324>
lea    0xbec(%rip),%rax
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    14e2 <print_wonder+0x2d2>
mov    -0x78(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     14cf <print_wonder+0x2bf>
mov    -0x80(%rbp),%rdi
lea    0xb92(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0xc8(%rbp)
mov    -0x78(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   10a0 <getname@plt>
mov    -0xc8(%rbp),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    %rax,-0x80(%rbp)
jmp    14d4 <print_wonder+0x2c4>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1469 <print_wonder+0x259>
mov    -0x80(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1521 <print_wonder+0x311>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x80(%rbp),%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
lea    0xb2d(%rip),%rdx
call   10c0 <io_printplain@plt>
jmp    1526 <print_wonder+0x316>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    144d <print_wonder+0x23d>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <wonder_numstages@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
cmp    %ecx,%eax
jge    164c <print_wonder+0x43c>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   1100 <itoa@plt>
mov    %rax,%rsi
lea    0xaa3(%rip),%rdi
call   1130 <cat@plt>
mov    %rax,-0x88(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <data_getwonderstages@plt>
cmp    -0x1c(%rbp),%eax
jle    15c5 <print_wonder+0x3b5>
mov    -0x88(%rbp),%rdi
lea    0xa7f(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0x88(%rbp)
jmp    15df <print_wonder+0x3cf>
mov    -0x88(%rbp),%rdi
lea    0xa6c(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    160a <print_wonder+0x3fa>
mov    -0x88(%rbp),%rdi
lea    0xa52(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0x88(%rbp)
jmp    1624 <print_wonder+0x414>
mov    -0x88(%rbp),%rdi
lea    0xa30(%rip),%rsi
call   1130 <cat@plt>
mov    %rax,-0x88(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x88(%rbp),%rcx
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1553 <print_wonder+0x343>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    -0xc(%rbp),%edi
call   1090 <data_getbuilt@plt>
mov    %rax,-0x90(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x90(%rbp),%rdx
mov    -0x10(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
call   1110 <print_cards@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
cmpl   $0x0,-0x10(%rbp)
jl     1713 <print_wonder+0x503>
mov    -0x10(%rbp),%eax
mov    %eax,-0xd0(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <wonder_numstages@plt>
mov    %eax,%ecx
mov    -0xd0(%rbp),%eax
cmp    %ecx,%eax
jge    1713 <print_wonder+0x503>
mov    -0xc(%rbp),%edi
call   1080 <data_getwonder@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <data_getwonderside@plt>
mov    -0xd4(%rbp),%ecx
imul   $0x3,%eax,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%eax
mov    %eax,-0xd8(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <wonder_numstages@plt>
mov    %eax,%ecx
mov    -0xd8(%rbp),%eax
cmp    %ecx,%eax
jl     1768 <print_wonder+0x558>
mov    -0x90(%rbp),%rax
movslq -0x94(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x90(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_wonder>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,0x28(%rsp)
mov    %rcx,0x20(%rsp)
mov    %edx,%ebp
mov    %edi,%ebx
lea    0x1(%rsi),%r15d
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    %ebp,%edi
call   1080 <data_getwonder@plt>
xor    %r14d,%r14d
lea    0x50(%rsp),%rdx
mov    %eax,%edi
xor    %esi,%esi
call   10e0 <cards_getname@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1080 <data_getwonder@plt>
mov    %eax,%edi
xor    %esi,%esi
call   10d0 <cards_gettype@plt>
mov    %eax,%edi
call   10a0 <getname@plt>
lea    0xd7b(%rip),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   10f0 <data_getgold@plt>
mov    %eax,%edi
call   1100 <itoa@plt>
lea    0xd56(%rip),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
lea    0xd52(%rip),%rsi
mov    %rax,%rdi
call   1130 <cat@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
lea    0x1(%rax),%r15d
mov    %ebx,%edi
mov    %eax,%esi
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
lea    0x30(%rsp),%rsi
mov    %ebp,%edi
call   1120 <data_getdefinites@plt>
mov    %ebp,%edi
call   1080 <data_getwonder@plt>
mov    %eax,%edi
xor    %esi,%esi
call   10d0 <cards_gettype@plt>
addl   $0x1,0x30(%rsp,%rax,4)
mov    %ebp,0xc(%rsp)
mov    %ebp,%edi
call   10b0 <data_getindefinites@plt>
mov    %rax,%rbp
lea    0xcf6(%rip),%rcx
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
call   1030 <io_printtext@plt>
mov    %eax,%r13d
lea    0xcd4(%rip),%r12
jmp    135a <print_wonder+0x14a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    $0x7,%r14
je     13b3 <print_wonder+0x1a3>
cmpl   $0x0,0x30(%rsp,%r14,4)
je     1350 <print_wonder+0x140>
mov    %r14d,%edi
call   10a0 <getname@plt>
lea    0xcd8(%rip),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1130 <cat@plt>
mov    %rax,%r15
mov    0x30(%rsp,%r14,4),%edi
call   1100 <itoa@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r13d
jmp    1350 <print_wonder+0x140>
lea    0x2(%rbx),%eax
mov    %eax,0x1c(%rsp)
xor    %r15d,%r15d
lea    0xc86(%rip),%r14
lea    0xc5f(%rip),%r12
mov    %rbx,0x10(%rsp)
jmp    13ee <print_wonder+0x1de>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r15
cmp    $0x8,%r15
je     14f5 <print_wonder+0x2e5>
mov    0x0(%rbp,%r15,8),%rcx
cmpl   $0xffffffff,(%rcx)
mov    %r14,%rax
je     142b <print_wonder+0x21b>
mov    %r14,%rdi
mov    %r12,%rsi
call   1130 <cat@plt>
mov    %r14,%rbx
mov    %rax,%r14
mov    0x0(%rbp,%r15,8),%rax
mov    (%rax),%edi
call   10a0 <getname@plt>
mov    %r14,%rdi
mov    %rbx,%r14
mov    %rax,%rsi
call   1130 <cat@plt>
mov    0x0(%rbp,%r15,8),%rcx
cmpl   $0xffffffff,0x4(%rcx)
je     145c <print_wonder+0x24c>
mov    %rax,%rdi
mov    %r12,%rsi
call   1130 <cat@plt>
mov    %rax,%rbx
mov    0x0(%rbp,%r15,8),%rax
mov    0x4(%rax),%edi
call   10a0 <getname@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    0x0(%rbp,%r15,8),%rcx
cmpl   $0xffffffff,0x8(%rcx)
je     148d <print_wonder+0x27d>
mov    %rax,%rdi
mov    %r12,%rsi
call   1130 <cat@plt>
mov    %rax,%rbx
mov    0x0(%rbp,%r15,8),%rax
mov    0x8(%rax),%edi
call   10a0 <getname@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    0x0(%rbp,%r15,8),%rcx
cmpl   $0xffffffff,0xc(%rcx)
je     14b9 <print_wonder+0x2a9>
mov    %rax,%rdi
mov    %r12,%rsi
call   1130 <cat@plt>
mov    %rax,%rbx
mov    0x0(%rbp,%r15,8),%rax
mov    0xc(%rax),%edi
call   10a0 <getname@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    0x10(%rsp),%rbx
cmpb   $0x0,(%rax)
je     13e0 <print_wonder+0x1d0>
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r13d
lea    -0x1(%r13),%esi
mov    0x1c(%rsp),%edi
lea    0xb5e(%rip),%rdx
call   10c0 <io_printplain@plt>
jmp    13e0 <print_wonder+0x1d0>
lea    0x1(%r13),%r15d
mov    %ebx,%edi
mov    %r13d,%esi
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    0xc(%rsp),%edi
call   1070 <wonder_numstages@plt>
test   %eax,%eax
jle    15bc <print_wonder+0x3ac>
xor    %r13d,%r13d
mov    0xc(%rsp),%r12d
mov    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%r13),%ebx
mov    %ebx,%edi
call   1100 <itoa@plt>
lea    0xaea(%rip),%rdi
mov    %rax,%rsi
call   1130 <cat@plt>
mov    %rax,%rbp
mov    %r12d,%edi
call   1040 <data_getwonderstages@plt>
cmp    %r13d,%eax
lea    0xae0(%rip),%rsi
lea    0xacd(%rip),%rax
cmovg  %rax,%rsi
mov    %rbp,%rdi
call   1130 <cat@plt>
cmp    %r13d,0x20(%rsp)
lea    0xaca(%rip),%rsi
lea    0xac6(%rip),%rcx
cmove  %rcx,%rsi
mov    %rax,%rdi
call   1130 <cat@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
mov    %rax,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%r15d
mov    %r12d,%edi
call   1070 <wonder_numstages@plt>
mov    %ebx,%r13d
cmp    %eax,%ebx
jl     1530 <print_wonder+0x320>
jmp    15c8 <print_wonder+0x3b8>
xor    %ebx,%ebx
mov    0xc(%rsp),%r12d
mov    0x10(%rsp),%r14
lea    0x1(%r15),%r13d
mov    %r14d,%edi
mov    %r15d,%esi
mov    $0x1c,%edx
call   1060 <io_printborder@plt>
mov    %r12d,%edi
call   1090 <data_getbuilt@plt>
mov    0x20(%rsp),%r15
mov    %r15d,%ebp
sub    %ebx,%ebp
mov    %r14d,%edi
mov    %r13d,%esi
mov    %rax,%r13
mov    %rax,%rdx
mov    %ebp,%ecx
call   1110 <print_cards@plt>
mov    0x28(%rsp),%rbx
movq   $0xffffffffffffffff,(%rbx)
test   %r15d,%r15d
js     163d <print_wonder+0x42d>
mov    %r12d,%edi
call   1070 <wonder_numstages@plt>
cmp    %r15d,%eax
jle    163d <print_wonder+0x42d>
mov    %r12d,%edi
call   1080 <data_getwonder@plt>
mov    %eax,(%rbx)
mov    %r12d,%edi
call   1050 <data_getwonderside@plt>
lea    (%rax,%rax,2),%eax
add    %r15d,%eax
add    $0x1,%eax
mov    %eax,0x4(%rbx)
mov    %r12d,%edi
call   1070 <wonder_numstages@plt>
cmp    %r15d,%eax
jg     1663 <print_wonder+0x453>
add    %ebp,%ebp
movslq %ebp,%rax
mov    0x0(%r13,%rax,4),%ecx
mov    %ecx,(%rbx)
or     $0x1,%eax
cltq
mov    0x0(%r13,%rax,4),%eax
mov    %eax,0x4(%rbx)
mov    %rbx,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Produces: 1 \00"
@.str.1 = [11 x i8] c"Treasury: \00"
@.str.2 = [6 x i8] c" gold\00"
@.str.3 = [12 x i8] c"Production:\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c": \00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"/\00"
@.str.8 = [7 x i8] c"Stage \00"
@.str.9 = [12 x i8] c" (complete)\00"
@.str.10 = [12 x i8] c" \00"
@.str.11 = [7 x i8] c" *\00"
@.str.12 = [3 x i8] c" \00"
define i32* @print_wonder(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 i32
%12 = alloca i32
%13 = alloca [40 x i8]
%14 = alloca [7 x i32]
%15 = alloca i32**
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32*
%19 = alloca i32
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
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
%23 = call i32 @io_printborder(i32 %20, i32 %21, i32 28)
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = load i32, i32* %8
%27 = call i32 @data_getwonder(i32 %26)
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %13, i64 0, i64 0
%29 = call i8* @cards_getname(i32 %27, i32 0, i8* %28)
%30 = call i32 @io_printtext(i32 %24, i32 %25, i32 28, i8* %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @data_getwonder(i32 %33)
%35 = call i64 @cards_gettype(i32 %34, i32 0)
%36 = trunc i64 %35 to i32
%37 = call i8* @getname(i32 %36)
%38 = call i8* @cat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = call i32 @io_printtext(i32 %31, i32 %32, i32 28, i8* %38)
store i32 %39, i32* %7
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = call i32 @data_getgold(i32 %42)
%44 = call i8* @itoa(i32 %43)
%45 = call i8* @cat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %44)
%46 = call i8* @cat(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @io_printtext(i32 %40, i32 %41, i32 28, i8* %46)
store i32 %47, i32* %7
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
%51 = call i32 @io_printborder(i32 %48, i32 %49, i32 28)
%52 = load i32, i32* %8
%53 = getelementptr inbounds [7 x i32], [7 x i32]* %14, i64 0, i64 0
%54 = call i32 @data_getdefinites(i32 %52, i32* %53)
%55 = load i32, i32* %8
%56 = call i32 @data_getwonder(i32 %55)
%57 = call i64 @cards_gettype(i32 %56, i32 0)
%58 = getelementptr inbounds [7 x i32], [7 x i32]* %14, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = add nsw i32 %59, 1
store i32 %60, i32* %58
%61 = load i32, i32* %8
%62 = call i32** @data_getindefinites(i32 %61)
store i32** %62, i32*** %15
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = call i32 @io_printtext(i32 %63, i32 %64, i32 28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 %65, i32* %7
store i32 0, i32* %11
br label %66
66: ; preds = %90, %5
%67 = load i32, i32* %11
%68 = icmp slt i32 %67, 7
br i1 %68, label %69, label %93
69: ; preds = %66
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [7 x i32], [7 x i32]* %14, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %89
75: ; preds = %69
%76 = load i32, i32* %6
%77 = load i32, i32* %7
%78 = load i32, i32* %11
%79 = call i8* @getname(i32 %78)
%80 = call i8* @cat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %79)
%81 = call i8* @cat(i8* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [7 x i32], [7 x i32]* %14, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = call i8* @itoa(i32 %85)
%87 = call i8* @cat(i8* %81, i8* %86)
%88 = call i32 @io_printtext(i32 %76, i32 %77, i32 28, i8* %87)
store i32 %88, i32* %7
br label %89
89: ; preds = %75, %69
br label %90
90: ; preds = %89
%91 = load i32, i32* %11
%92 = add nsw i32 %91, 1
store i32 %92, i32* %11
br label %66
93: ; preds = %66
store i32 0, i32* %11
br label %94
94: ; preds = %147, %93
%95 = load i32, i32* %11
%96 = icmp slt i32 %95, 8
br i1 %96, label %97, label %150
97: ; preds = %94
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8** %16
store i32 0, i32* %12
br label %98
98: ; preds = %127, %97
%99 = load i32, i32* %12
%100 = icmp slt i32 %99, 4
br i1 %100, label %101, label %130
101: ; preds = %98
%102 = load i32**, i32*** %15
%103 = load i32, i32* %11
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32*, i32** %102, i64 %104
%106 = load i32*, i32** %105
%107 = load i32, i32* %12
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i32, i32* %106, i64 %108
%110 = load i32, i32* %109
%111 = icmp ne i32 %110, -1
br i1 %111, label %112, label %126
112: ; preds = %101
%113 = load i8*, i8** %16
%114 = call i8* @cat(i8* %113, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%115 = load i32**, i32*** %15
%116 = load i32, i32* %11
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i32*, i32** %115, i64 %117
%119 = load i32*, i32** %118
%120 = load i32, i32* %12
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds i32, i32* %119, i64 %121
%123 = load i32, i32* %122
%124 = call i8* @getname(i32 %123)
%125 = call i8* @cat(i8* %114, i8* %124)
store i8* %125, i8** %16
br label %126
126: ; preds = %112, %101
br label %127
127: ; preds = %126
%128 = load i32, i32* %12
%129 = add nsw i32 %128, 1
store i32 %129, i32* %12
br label %98
130: ; preds = %98
%131 = load i8*, i8** %16
%132 = getelementptr inbounds i8, i8* %131, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %146
136: ; preds = %130
%137 = load i32, i32* %6
%138 = load i32, i32* %7
%139 = load i8*, i8** %16
%140 = call i32 @io_printtext(i32 %137, i32 %138, i32 28, i8* %139)
store i32 %140, i32* %7
%141 = load i32, i32* %6
%142 = add nsw i32 %141, 2
%143 = load i32, i32* %7
%144 = sub nsw i32 %143, 1
%145 = call i32 @io_printplain(i32 %142, i32 %144, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %146
146: ; preds = %136, %130
br label %147
147: ; preds = %146
%148 = load i32, i32* %11
%149 = add nsw i32 %148, 1
store i32 %149, i32* %11
br label %94
150: ; preds = %94
%151 = load i32, i32* %6
%152 = load i32, i32* %7
%153 = add nsw i32 %152, 1
store i32 %153, i32* %7
%154 = call i32 @io_printborder(i32 %151, i32 %152, i32 28)
store i32 0, i32* %11
br label %155
155: ; preds = %190, %150
%156 = load i32, i32* %11
%157 = load i32, i32* %8
%158 = call i32 @wonder_numstages(i32 %157)
%159 = icmp slt i32 %156, %158
br i1 %159, label %160, label %193
160: ; preds = %155
%161 = load i32, i32* %11
%162 = add nsw i32 %161, 1
%163 = call i8* @itoa(i32 %162)
%164 = call i8* @cat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %163)
store i8* %164, i8** %17
%165 = load i32, i32* %8
%166 = call i32 @data_getwonderstages(i32 %165)
%167 = load i32, i32* %11
%168 = icmp sgt i32 %166, %167
br i1 %168, label %169, label %172
169: ; preds = %160
%170 = load i8*, i8** %17
%171 = call i8* @cat(i8* %170, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
store i8* %171, i8** %17
br label %175
172: ; preds = %160
%173 = load i8*, i8** %17
%174 = call i8* @cat(i8* %173, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
store i8* %174, i8** %17
br label %175
175: ; preds = %172, %169
%176 = load i32, i32* %9
%177 = load i32, i32* %11
%178 = icmp eq i32 %176, %177
br i1 %178, label %179, label %182
179: ; preds = %175
%180 = load i8*, i8** %17
%181 = call i8* @cat(i8* %180, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
store i8* %181, i8** %17
br label %185
182: ; preds = %175
%183 = load i8*, i8** %17
%184 = call i8* @cat(i8* %183, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i8* %184, i8** %17
br label %185
185: ; preds = %182, %179
%186 = load i32, i32* %6
%187 = load i32, i32* %7
%188 = load i8*, i8** %17
%189 = call i32 @io_printtext(i32 %186, i32 %187, i32 28, i8* %188)
store i32 %189, i32* %7
br label %190
190: ; preds = %185
%191 = load i32, i32* %11
%192 = add nsw i32 %191, 1
store i32 %192, i32* %11
br label %155
193: ; preds = %155
%194 = load i32, i32* %6
%195 = load i32, i32* %7
%196 = add nsw i32 %195, 1
store i32 %196, i32* %7
%197 = call i32 @io_printborder(i32 %194, i32 %195, i32 28)
%198 = load i32, i32* %8
%199 = call i32* @data_getbuilt(i32 %198)
store i32* %199, i32** %18
%200 = load i32, i32* %6
%201 = load i32, i32* %7
%202 = load i32*, i32** %18
%203 = load i32, i32* %9
%204 = load i32, i32* %11
%205 = sub nsw i32 %203, %204
%206 = call i32 @print_cards(i32 %200, i32 %201, i32* %202, i32 %205)
store i32 %206, i32* %7
%207 = load i32, i32* %9
%208 = load i32, i32* %11
%209 = sub nsw i32 %207, %208
%210 = mul nsw i32 2, %209
store i32 %210, i32* %19
%211 = load i32*, i32** %10
%212 = getelementptr inbounds i32, i32* %211, i64 1
store i32 -1, i32* %212
%213 = load i32*, i32** %10
%214 = getelementptr inbounds i32, i32* %213, i64 0
store i32 -1, i32* %214
%215 = load i32, i32* %9
%216 = icmp sge i32 %215, 0
br i1 %216, label %217, label %235
217: ; preds = %193
%218 = load i32, i32* %9
%219 = load i32, i32* %8
%220 = call i32 @wonder_numstages(i32 %219)
%221 = icmp slt i32 %218, %220
br i1 %221, label %222, label %235
222: ; preds = %217
%223 = load i32, i32* %8
%224 = call i32 @data_getwonder(i32 %223)
%225 = load i32*, i32** %10
%226 = getelementptr inbounds i32, i32* %225, i64 0
store i32 %224, i32* %226
%227 = load i32, i32* %9
%228 = add nsw i32 %227, 1
%229 = load i32, i32* %8
%230 = call i32 @data_getwonderside(i32 %229)
%231 = mul nsw i32 3, %230
%232 = add nsw i32 %228, %231
%233 = load i32*, i32** %10
%234 = getelementptr inbounds i32, i32* %233, i64 1
store i32 %232, i32* %234
br label %235
235: ; preds = %222, %217, %193
%236 = load i32, i32* %9
%237 = load i32, i32* %8
%238 = call i32 @wonder_numstages(i32 %237)
%239 = icmp sge i32 %236, %238
br i1 %239, label %240, label %256
240: ; preds = %235
%241 = load i32*, i32** %18
%242 = load i32, i32* %19
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds i32, i32* %241, i64 %243
%245 = load i32, i32* %244
%246 = load i32*, i32** %10
%247 = getelementptr inbounds i32, i32* %246, i64 0
store i32 %245, i32* %247
%248 = load i32*, i32** %18
%249 = load i32, i32* %19
%250 = add nsw i32 %249, 1
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds i32, i32* %248, i64 %251
%253 = load i32, i32* %252
%254 = load i32*, i32** %10
%255 = getelementptr inbounds i32, i32* %254, i64 1
store i32 %253, i32* %255
br label %256
256: ; preds = %240, %235
%257 = load i32*, i32** %10
ret i32* %257
}

LLVM IR (-O2):
@.str = [13 x i8] c"Produces: 1 \00"
@.str.1 = [11 x i8] c"Treasury: \00"
@.str.2 = [6 x i8] c" gold\00"
@.str.3 = [12 x i8] c"Production:\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c": \00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [2 x i8] c"/\00"
@.str.8 = [7 x i8] c"Stage \00"
@.str.9 = [12 x i8] c" (complete)\00"
@.str.10 = [12 x i8] c" \00"
@.str.11 = [7 x i8] c" *\00"
@.str.12 = [3 x i8] c" \00"
define i32* @print_wonder(i32 %0, i32 %1, i32 %2, i32 %3, i32* returned writeonly %4) {
%6 = alloca [40 x i8]
%7 = alloca [7 x i32]
%8 = getelementptr inbounds [40 x i8], [40 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 = tail call i32 @data_getwonder(i32 %2)
%12 = call i8* @cards_getname(i32 %11, i32 0, i8* %8)
%13 = call i32 @io_printtext(i32 %0, i32 %9, i32 28, i8* %12)
%14 = call i32 @data_getwonder(i32 %2)
%15 = call i64 @cards_gettype(i32 %14, i32 0)
%16 = trunc i64 %15 to i32
%17 = call i8* @getname(i32 %16)
%18 = call i8* @cat(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @io_printtext(i32 %0, i32 %13, i32 28, i8* %18)
%20 = call i32 @data_getgold(i32 %2)
%21 = call i8* @itoa(i32 %20)
%22 = call i8* @cat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i8* @cat(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @io_printtext(i32 %0, i32 %19, i32 28, i8* %23)
%25 = add nsw i32 %24, 1
%26 = call i32 @io_printborder(i32 %0, i32 %24, i32 28)
%27 = bitcast [7 x i32]* %7 to i8*
%28 = getelementptr inbounds [7 x i32], [7 x i32]* %7, i64 0, i64 0
%29 = call i32 @data_getdefinites(i32 %2, i32* %28)
%30 = call i32 @data_getwonder(i32 %2)
%31 = call i64 @cards_gettype(i32 %30, i32 0)
%32 = getelementptr inbounds [7 x i32], [7 x i32]* %7, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
%35 = call i32** @data_getindefinites(i32 %2)
%36 = call i32 @io_printtext(i32 %0, i32 %25, i32 28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %39
37: ; preds = %54
%38 = add nsw i32 %0, 2
br label %58
39: ; preds = %5, %54
%40 = phi i64 [ 0, %5 ], [ %56, %54 ]
%41 = phi i32 [ %36, %5 ], [ %55, %54 ]
%42 = getelementptr inbounds [7 x i32], [7 x i32]* %7, i64 0, i64 %40
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 0
br i1 %44, label %54, label %45
45: ; preds = %39
%46 = trunc i64 %40 to i32
%47 = call i8* @getname(i32 %46)
%48 = call i8* @cat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %47)
%49 = call i8* @cat(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%50 = load i32, i32* %42
%51 = call i8* @itoa(i32 %50)
%52 = call i8* @cat(i8* %49, i8* %51)
%53 = call i32 @io_printtext(i32 %0, i32 %41, i32 28, i8* %52)
br label %54
54: ; preds = %39, %45
%55 = phi i32 [ %53, %45 ], [ %41, %39 ]
%56 = add nuw nsw i64 %40, 1
%57 = icmp eq i64 %56, 7
br i1 %57, label %37, label %39
58: ; preds = %37, %121
%59 = phi i64 [ 0, %37 ], [ %123, %121 ]
%60 = phi i32 [ %55, %37 ], [ %122, %121 ]
%61 = getelementptr inbounds i32*, i32** %35, i64 %59
%62 = load i32*, i32** %61
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, -1
br i1 %64, label %72, label %65
65: ; preds = %58
%66 = call i8* @cat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%67 = load i32*, i32** %61
%68 = load i32, i32* %67
%69 = call i8* @getname(i32 %68)
%70 = call i8* @cat(i8* %66, i8* %69)
%71 = load i32*, i32** %61
br label %72
72: ; preds = %58, %65
%73 = phi i32* [ %71, %65 ], [ %62, %58 ]
%74 = phi i8* [ %70, %65 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), %58 ]
%75 = getelementptr inbounds i32, i32* %73, i64 1
%76 = load i32, i32* %75
%77 = icmp eq i32 %76, -1
br i1 %77, label %86, label %78
78: ; preds = %72
%79 = call i8* @cat(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%80 = load i32*, i32** %61
%81 = getelementptr inbounds i32, i32* %80, i64 1
%82 = load i32, i32* %81
%83 = call i8* @getname(i32 %82)
%84 = call i8* @cat(i8* %79, i8* %83)
%85 = load i32*, i32** %61
br label %86
86: ; preds = %78, %72
%87 = phi i32* [ %85, %78 ], [ %73, %72 ]
%88 = phi i8* [ %84, %78 ], [ %74, %72 ]
%89 = getelementptr inbounds i32, i32* %87, i64 2
%90 = load i32, i32* %89
%91 = icmp eq i32 %90, -1
br i1 %91, label %100, label %92
92: ; preds = %86
%93 = call i8* @cat(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%94 = load i32*, i32** %61
%95 = getelementptr inbounds i32, i32* %94, i64 2
%96 = load i32, i32* %95
%97 = call i8* @getname(i32 %96)
%98 = call i8* @cat(i8* %93, i8* %97)
%99 = load i32*, i32** %61
br label %100
100: ; preds = %92, %86
%101 = phi i32* [ %99, %92 ], [ %87, %86 ]
%102 = phi i8* [ %98, %92 ], [ %88, %86 ]
%103 = getelementptr inbounds i32, i32* %101, i64 3
%104 = load i32, i32* %103
%105 = icmp eq i32 %104, -1
br i1 %105, label %113, label %106
106: ; preds = %100
%107 = call i8* @cat(i8* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%108 = load i32*, i32** %61
%109 = getelementptr inbounds i32, i32* %108, i64 3
%110 = load i32, i32* %109
%111 = call i8* @getname(i32 %110)
%112 = call i8* @cat(i8* %107, i8* %111)
br label %113
113: ; preds = %106, %100
%114 = phi i8* [ %112, %106 ], [ %102, %100 ]
%115 = load i8, i8* %114
%116 = icmp eq i8 %115, 0
br i1 %116, label %121, label %117
117: ; preds = %113
%118 = call i32 @io_printtext(i32 %0, i32 %60, i32 28, i8* %114)
%119 = add nsw i32 %118, -1
%120 = call i32 @io_printplain(i32 %38, i32 %119, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %121
121: ; preds = %117, %113
%122 = phi i32 [ %118, %117 ], [ %60, %113 ]
%123 = add nuw nsw i64 %59, 1
%124 = icmp eq i64 %123, 8
br i1 %124, label %125, label %58
125: ; preds = %121
%126 = add nsw i32 %122, 1
%127 = call i32 @io_printborder(i32 %0, i32 %122, i32 28)
%128 = call i32 @wonder_numstages(i32 %2)
%129 = icmp sgt i32 %128, 0
br i1 %129, label %130, label %146
130: ; preds = %125, %130
%131 = phi i32 [ %143, %130 ], [ %126, %125 ]
%132 = phi i32 [ %133, %130 ], [ 0, %125 ]
%133 = add nuw nsw i32 %132, 1
%134 = call i8* @itoa(i32 %133)
%135 = call i8* @cat(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8* %134)
%136 = call i32 @data_getwonderstages(i32 %2)
%137 = icmp sgt i32 %136, %132
%138 = select i1 %137, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0)
%139 = call i8* @cat(i8* %135, i8* %138)
%140 = icmp eq i32 %132, %3
%141 = select i1 %140, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0)
%142 = call i8* @cat(i8* %139, i8* %141)
%143 = call i32 @io_printtext(i32 %0, i32 %131, i32 28, i8* %142)
%144 = call i32 @wonder_numstages(i32 %2)
%145 = icmp slt i32 %133, %144
br i1 %145, label %130, label %146
146: ; preds = %130, %125
%147 = phi i32 [ 0, %125 ], [ %133, %130 ]
%148 = phi i32 [ %126, %125 ], [ %143, %130 ]
%149 = add nsw i32 %148, 1
%150 = call i32 @io_printborder(i32 %0, i32 %148, i32 28)
%151 = call i32* @data_getbuilt(i32 %2)
%152 = sub nsw i32 %3, %147
%153 = call i32 @print_cards(i32 %0, i32 %149, i32* %151, i32 %152)
%154 = shl nsw i32 %152, 1
%155 = getelementptr inbounds i32, i32* %4, i64 1
store i32 -1, i32* %155
store i32 -1, i32* %4
%156 = icmp sgt i32 %3, -1
br i1 %156, label %157, label %166
157: ; preds = %146
%158 = call i32 @wonder_numstages(i32 %2)
%159 = icmp sgt i32 %158, %3
br i1 %159, label %160, label %166
160: ; preds = %157
%161 = call i32 @data_getwonder(i32 %2)
store i32 %161, i32* %4
%162 = add nuw nsw i32 %3, 1
%163 = call i32 @data_getwonderside(i32 %2)
%164 = mul nsw i32 %163, 3
%165 = add nsw i32 %162, %164
store i32 %165, i32* %155
br label %166
166: ; preds = %160, %157, %146
%167 = call i32 @wonder_numstages(i32 %2)
%168 = icmp sgt i32 %167, %3
br i1 %168, label %177, label %169
169: ; preds = %166
%170 = sext i32 %154 to i64
%171 = getelementptr inbounds i32, i32* %151, i64 %170
%172 = load i32, i32* %171
store i32 %172, i32* %4
%173 = or i32 %154, 1
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i32, i32* %151, i64 %174
%176 = load i32, i32* %175
store i32 %176, i32* %155
br label %177
177: ; preds = %169, %166
ret i32* %4
}