#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 */
typedef int /*<<< orphan*/ chtype;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int getmaxx(int /*<<< orphan*/ *);
int /*<<< orphan*/ move(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *,
                             char const *);
int /*<<< orphan*/ *stdscr;
int strlen(char const *);
int /*<<< orphan*/ wattroff(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wattron(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
void print_xcenter(WINDOW *win, int y_pos, const char *string, chtype color) {
  int length, x_pos, win_w;
  float temp;
  if (win == NULL)
    win = stdscr;
  win_w = getmaxx(win);
  length = strlen(string);
  temp = (win_w - length) / 2;
  x_pos = (int)temp;
  wattron(win, color);
  mvwprintw(win, y_pos, x_pos, "%s", string);
  wattroff(win, color);
  move(0, 0);
  wrefresh(win);
}


x86 assembly (clang, -O0):
<print_xcenter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    119f <print_xcenter+0x2f>
mov    0x2e50(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getmaxx@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
cvttss2si -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <wattron@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%r8
lea    0xe09(%rip),%rcx
call   1060 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1070 <wattroff@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1090 <move@plt>
mov    -0x8(%rbp),%rdi
call   1040 <wrefresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_xcenter>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,%r15d
mov    %rdi,%rbx
test   %rdi,%rdi
jne    1193 <print_xcenter+0x23>
mov    0x2e58(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1050 <getmaxx@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebp
mov    %ebp,%eax
shr    $0x1f,%eax
add    %ebp,%eax
sar    %eax
cvtsi2ss %eax,%xmm0
cvttss2si %xmm0,%ebp
mov    %rbx,%rdi
mov    %r14d,%esi
call   1080 <wattron@plt>
lea    0xe36(%rip),%rcx
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r12,%r8
call   1060 <mvwprintw@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1070 <wattroff@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1090 <move@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <wrefresh@plt>

LLVM IR (-O0):
@stdscr = global i32* null
@.str = [3 x i8] c"%s\00"
define void @print_xcenter(i32* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i32*, i32** %5
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = load i32*, i32** @stdscr
store i32* %16, i32** %5
br label %17
17: ; preds = %15, %4
%18 = load i32*, i32** %5
%19 = call i32 @getmaxx(i32* %18)
store i32 %19, i32* %11
%20 = load i8*, i8** %7
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %9
%22 = load i32, i32* %11
%23 = load i32, i32* %9
%24 = sub nsw i32 %22, %23
%25 = sdiv i32 %24, 2
%26 = sitofp i32 %25 to float
store float %26, float* %12
%27 = load float, float* %12
%28 = fptosi float %27 to i32
store i32 %28, i32* %10
%29 = load i32*, i32** %5
%30 = load i32, i32* %8
%31 = call i32 @wattron(i32* %29, i32 %30)
%32 = load i32*, i32** %5
%33 = load i32, i32* %6
%34 = load i32, i32* %10
%35 = load i8*, i8** %7
%36 = call i32 @mvwprintw(i32* %32, i32 %33, i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = load i32*, i32** %5
%38 = load i32, i32* %8
%39 = call i32 @wattroff(i32* %37, i32 %38)
%40 = call i32 @move(i32 0, i32 0)
%41 = load i32*, i32** %5
%42 = call i32 @wrefresh(i32* %41)
ret void
}

LLVM IR (-O2):
@stdscr = global i32* null
@.str = [3 x i8] c"%s\00"
define void @print_xcenter(i32* %0, i32 %1, i8* %2, i32 %3) {
%5 = icmp eq i32* %0, null
%6 = load i32*, i32** @stdscr
%7 = select i1 %5, i32* %6, i32* %0
%8 = tail call i32 @getmaxx(i32* %7)
%9 = tail call i32 @strlen(i8* %2)
%10 = sub nsw i32 %8, %9
%11 = sdiv i32 %10, 2
%12 = sitofp i32 %11 to float
%13 = fptosi float %12 to i32
%14 = tail call i32 @wattron(i32* %7, i32 %3)
%15 = tail call i32 @mvwprintw(i32* %7, i32 %1, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%16 = tail call i32 @wattroff(i32* %7, i32 %3)
%17 = tail call i32 @move(i32 0, i32 0)
%18 = tail call i32 @wrefresh(i32* %7)
ret void
}