#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 /*<<< orphan*/ getyx(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *, char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ *stdscr;
int strlen(char *);
int /*<<< orphan*/ wattroff(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ wattron(int /*<<< orphan*/ *, int /*<<< orphan*/);
void print_in_middle(WINDOW *win, int starty, int startx, int width,
                     char *string, chtype color) {
  int length, x, y;
  float temp;
  if (win == NULL)
    win = stdscr;
  getyx(win, y, x);
  if (startx != 0)
    x = startx;
  if (starty != 0)
    x = starty;
  if (width == 0)
    width = 80;
  length = strlen(string);
  temp = (width - length) / 2;
  x = startx + (int)temp;
  wattron(win, color);
  mvwprintw(win, y, x, "%s", string);
  wattroff(win, color);
  refresh();
}


x86 assembly (clang, -O0):
<print_in_middle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1196 <print_in_middle+0x36>
mov    0x2e59(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1040 <getyx@plt>
cmpl   $0x0,-0x10(%rbp)
je     11b5 <print_in_middle+0x55>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11c5 <print_in_middle+0x65>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11d6 <print_in_middle+0x76>
movl   $0x50,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%eax
cvttss2si -0x34(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1080 <wattron@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x20(%rbp),%r8
lea    0xdd9(%rip),%rcx
call   1060 <mvwprintw@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1070 <wattroff@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_in_middle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8,%r12
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %rdi,%rbp
test   %rdi,%rdi
jne    1189 <print_in_middle+0x29>
mov    0x2e62(%rip),%rax
mov    (%rax),%rbp
mov    %rbp,%rdi
call   1040 <getyx@plt>
test   %r13d,%r13d
mov    $0x50,%ebx
cmovne %r13d,%ebx
mov    %r12,%rdi
call   1030 <strlen@plt>
sub    %eax,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
cvtsi2ss %eax,%xmm0
cvttss2si %xmm0,%ebx
add    %r15d,%ebx
mov    %rbp,%rdi
mov    %r14d,%esi
call   1080 <wattron@plt>
lea    0xe33(%rip),%rcx
mov    %rbp,%rdi
mov    %ebx,%edx
mov    %r12,%r8
call   1060 <mvwprintw@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1070 <wattroff@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <refresh@plt>

LLVM IR (-O0):
@stdscr = global i32* null
@.str = [3 x i8] c"%s\00"
define void @print_in_middle(i32* %0, i32 %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca float
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%17 = load i32*, i32** %7
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = load i32*, i32** @stdscr
store i32* %20, i32** %7
br label %21
21: ; preds = %19, %6
%22 = load i32*, i32** %7
%23 = load i32, i32* %15
%24 = load i32, i32* %14
%25 = call i32 @getyx(i32* %22, i32 %23, i32 %24)
%26 = load i32, i32* %9
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = load i32, i32* %9
store i32 %29, i32* %14
br label %30
30: ; preds = %28, %21
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32, i32* %8
store i32 %34, i32* %14
br label %35
35: ; preds = %33, %30
%36 = load i32, i32* %10
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 80, i32* %10
br label %39
39: ; preds = %38, %35
%40 = load i8*, i8** %11
%41 = call i32 @strlen(i8* %40)
store i32 %41, i32* %13
%42 = load i32, i32* %10
%43 = load i32, i32* %13
%44 = sub nsw i32 %42, %43
%45 = sdiv i32 %44, 2
%46 = sitofp i32 %45 to float
store float %46, float* %16
%47 = load i32, i32* %9
%48 = load float, float* %16
%49 = fptosi float %48 to i32
%50 = add nsw i32 %47, %49
store i32 %50, i32* %14
%51 = load i32*, i32** %7
%52 = load i32, i32* %12
%53 = call i32 @wattron(i32* %51, i32 %52)
%54 = load i32*, i32** %7
%55 = load i32, i32* %15
%56 = load i32, i32* %14
%57 = load i8*, i8** %11
%58 = call i32 @mvwprintw(i32* %54, i32 %55, i32 %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %57)
%59 = load i32*, i32** %7
%60 = load i32, i32* %12
%61 = call i32 @wattroff(i32* %59, i32 %60)
%62 = call i32 (...) @refresh()
ret void
}

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