#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*/ io_clearscreen();
int /*<<< orphan*/ io_printborder(int /*<<< orphan*/, int /*<<< orphan*/, int);
int io_printtext(int /*<<< orphan*/, int, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char, ...);
void pregame_refresh(int *data, int cursor) {
  io_clearscreen();
  int y = 0;
  int width = 28;
  io_printborder(0, y++, width);
  char s[40];
  sprintf(s, "Number of players: %d  %c", data[7], (cursor == 0) ? '*' : ' ');
  y = io_printtext(0, y, width, s);
  int i;
  for (i = 0; i < data[7]; i++) {
    sprintf(s, "Player %d is: %s    %c", i + 1,
            (data[i] == 1) ? "ai   " : "human", (cursor == i + 1) ? '*' : ' ');
    y = io_printtext(0, y, width, s);
  }
  sprintf(s, "Play                  %c", (cursor == data[7] + 1) ? '*' : ' ');
  y = io_printtext(0, y, width, s);
  io_printborder(0, y++, width);
}


x86 assembly (clang, -O0):
<pregame_refresh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1050 <io_clearscreen@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x1c,-0x14(%rbp)
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1040 <io_printborder@plt>
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%eax
mov    -0xc(%rbp),%esi
mov    $0x20,%ecx
mov    $0x2a,%edx
cmp    $0x0,%esi
cmove  %edx,%ecx
lea    0xe62(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x40(%rbp),%rcx
xor    %edi,%edi
call   1030 <io_printtext@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    0x1c(%rcx),%eax
jge    124d <pregame_refresh+0x10d>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    -0x8(%rbp),%rcx
movslq -0x44(%rbp),%rdx
mov    (%rcx,%rdx,4),%esi
lea    0xe48(%rip),%rcx
lea    0xe3b(%rip),%rdx
cmp    $0x1,%esi
cmove  %rdx,%rcx
mov    -0xc(%rbp),%esi
mov    -0x44(%rbp),%r9d
add    $0x1,%r9d
mov    $0x20,%r8d
mov    $0x2a,%edx
cmp    %r9d,%esi
cmove  %edx,%r8d
lea    0xdf9(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x40(%rbp),%rcx
xor    %edi,%edi
call   1030 <io_printtext@plt>
mov    %eax,-0x10(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c3 <pregame_refresh+0x83>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
add    $0x1,%esi
mov    $0x20,%eax
mov    $0x2a,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
lea    0xdc9(%rip),%rsi
movsbl %al,%edx
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    -0x40(%rbp),%rcx
xor    %edi,%edi
call   1030 <io_printtext@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%edx
xor    %edi,%edi
call   1040 <io_printborder@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pregame_refresh>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <io_clearscreen@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
movsbl 0x1c(%rbx),%edx
test   %r14d,%r14d
mov    $0x2a,%eax
mov    $0x20,%r15d
mov    $0x20,%ecx
cmove  %eax,%ecx
lea    0xe76(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x1c,%edx
mov    %rbp,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%ebp
mov    0x1c(%rbx),%eax
test   %eax,%eax
jle    1247 <pregame_refresh+0x107>
mov    %r14d,0xc(%rsp)
mov    %r14d,%r15d
add    $0xffffffffffffffff,%r15
lea    0xe4d(%rip),%r12
lea    0x10(%rsp),%r13
xor    %edx,%edx
jmp    1222 <pregame_refresh+0xe2>
cs nopw 0x0(%rax,%rax,1)
cmp    %rdx,%r15
mov    $0x20,%r8d
mov    $0x2a,%eax
cmove  %eax,%r8d
movsbl %r14b,%edx
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    $0x1c,%edx
mov    %r13,%rcx
call   1030 <io_printtext@plt>
mov    %eax,%ebp
movslq 0x1c(%rbx),%rax
mov    %r14,%rdx
cmp    %rax,%r14
jge    123c <pregame_refresh+0xfc>
lea    0x1(%rdx),%r14
cmpl   $0x1,(%rbx,%rdx,4)
lea    0xe00(%rip),%rcx
je     11e0 <pregame_refresh+0xa0>
lea    0xdfd(%rip),%rcx
jmp    11e0 <pregame_refresh+0xa0>
mov    0xc(%rsp),%r14d
mov    $0x20,%r15d
add    $0x1,%eax
cmp    %r14d,%eax
mov    $0x2a,%eax
cmove  %eax,%r15d
lea    0xde0(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
xor    %edi,%edi
mov    %ebp,%esi
mov    $0x1c,%edx
mov    %rbx,%rcx
call   1030 <io_printtext@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    $0x1c,%edx
call   1040 <io_printborder@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Number of players: %d %c\00"
@.str.1 = [23 x i8] c"Player %d is: %s %c\00"
@.str.2 = [6 x i8] c"ai \00"
@.str.3 = [6 x i8] c"human\00"
@.str.4 = [25 x i8] c"Play %c\00"
define void @pregame_refresh(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [40 x i8]
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = call i32 (...) @io_clearscreen()
store i32 0, i32* %5
store i32 28, i32* %6
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 1
store i32 %11, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @io_printborder(i32 0, i32 %10, i32 %12)
%14 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 7
%17 = load i32, i32* %16
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 42, i32 32
%23 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8 signext %18, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%27 = call i32 @io_printtext(i32 0, i32 %24, i32 %25, i8* %26)
store i32 %27, i32* %5
store i32 0, i32* %8
br label %28
28: ; preds = %58, %2
%29 = load i32, i32* %8
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 7
%32 = load i32, i32* %31
%33 = icmp slt i32 %29, %32
br i1 %33, label %34, label %61
34: ; preds = %28
%35 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
%38 = trunc i32 %37 to i8
%39 = load i32*, i32** %3
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 1
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%47 = load i32, i32* %4
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
%50 = icmp eq i32 %47, %49
%51 = zext i1 %50 to i64
%52 = select i1 %50, i32 42, i32 32
%53 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %38, i8* %46, i32 %52)
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%57 = call i32 @io_printtext(i32 0, i32 %54, i32 %55, i8* %56)
store i32 %57, i32* %5
br label %58
58: ; preds = %34
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
store i32 %60, i32* %8
br label %28
61: ; preds = %28
%62 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%63 = load i32, i32* %4
%64 = load i32*, i32** %3
%65 = getelementptr inbounds i32, i32* %64, i64 7
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 1
%68 = icmp eq i32 %63, %67
%69 = zext i1 %68 to i64
%70 = select i1 %68, i32 42, i32 32
%71 = trunc i32 %70 to i8
%72 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %62, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8 signext %71)
%73 = load i32, i32* %5
%74 = load i32, i32* %6
%75 = getelementptr inbounds [40 x i8], [40 x i8]* %7, i64 0, i64 0
%76 = call i32 @io_printtext(i32 0, i32 %73, i32 %74, i8* %75)
store i32 %76, i32* %5
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 1
store i32 %78, i32* %5
%79 = load i32, i32* %6
%80 = call i32 @io_printborder(i32 0, i32 %77, i32 %79)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Number of players: %d %c\00"
@.str.1 = [23 x i8] c"Player %d is: %s %c\00"
@.str.2 = [6 x i8] c"ai \00"
@.str.3 = [6 x i8] c"human\00"
@.str.4 = [25 x i8] c"Play %c\00"
define void @pregame_refresh(i32* nocapture %0, i32 %1) {
%3 = alloca [40 x i8]
%4 = tail call i32 (...) @io_clearscreen()
%5 = tail call i32 @io_printborder(i32 0, i32 0, i32 28)
%6 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds i32, i32* %0, i64 7
%8 = load i32, i32* %7
%9 = trunc i32 %8 to i8
%10 = icmp eq i32 %1, 0
%11 = select i1 %10, i32 42, i32 32
%12 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8 signext %9, i32 %11)
%13 = call i32 @io_printtext(i32 0, i32 1, i32 28, i8* %6)
%14 = load i32, i32* %7
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %2
%17 = zext i32 %1 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %21, %18 ]
%20 = phi i32 [ %13, %16 ], [ %30, %18 ]
%21 = add nuw nsw i64 %19, 1
%22 = trunc i64 %21 to i8
%23 = getelementptr inbounds i32, i32* %0, i64 %19
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
%26 = select i1 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%27 = icmp eq i64 %21, %17
%28 = select i1 %27, i32 42, i32 32
%29 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8 signext %22, i8* %26, i32 %28)
%30 = call i32 @io_printtext(i32 0, i32 %20, i32 28, i8* %6)
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %21, %32
br i1 %33, label %18, label %34
34: ; preds = %18, %2
%35 = phi i32 [ %13, %2 ], [ %30, %18 ]
%36 = phi i32 [ %14, %2 ], [ %31, %18 ]
%37 = add nsw i32 %36, 1
%38 = icmp eq i32 %37, %1
%39 = select i1 %38, i8 42, i8 32
%40 = call i32 (i8*, i8*, i8, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8 signext %39)
%41 = call i32 @io_printtext(i32 0, i32 %35, i32 28, i8* %6)
%42 = call i32 @io_printborder(i32 0, i32 %41, i32 28)
ret void
}