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


x86 assembly (clang, -O0):
<print_in_middle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1172 <print_in_middle+0x32>
mov    0x2e7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1040 <getyx@plt>
cmpl   $0x0,-0x10(%rbp)
je     1191 <print_in_middle+0x51>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a1 <print_in_middle+0x61>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11b2 <print_in_middle+0x72>
movl   $0x50,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%eax
cvttss2si -0x30(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%r8
lea    0xe09(%rip),%rcx
call   1060 <mvwprintw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
add    $0x30,%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    %r8,%r12
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%rbp
test   %rdi,%rdi
jne    1169 <print_in_middle+0x29>
mov    0x2e82(%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,%edx
add    %r15d,%edx
lea    0xe5e(%rip),%rcx
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r12,%r8
call   1060 <mvwprintw@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) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca float
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%15 = load i32*, i32** %6
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %5
%18 = load i32*, i32** @stdscr
store i32* %18, i32** %6
br label %19
19: ; preds = %17, %5
%20 = load i32*, i32** %6
%21 = load i32, i32* %13
%22 = load i32, i32* %12
%23 = call i32 @getyx(i32* %20, i32 %21, i32 %22)
%24 = load i32, i32* %8
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = load i32, i32* %8
store i32 %27, i32* %12
br label %28
28: ; preds = %26, %19
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = load i32, i32* %7
store i32 %32, i32* %13
br label %33
33: ; preds = %31, %28
%34 = load i32, i32* %9
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 80, i32* %9
br label %37
37: ; preds = %36, %33
%38 = load i8*, i8** %10
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %11
%40 = load i32, i32* %9
%41 = load i32, i32* %11
%42 = sub nsw i32 %40, %41
%43 = sdiv i32 %42, 2
%44 = sitofp i32 %43 to float
store float %44, float* %14
%45 = load i32, i32* %8
%46 = load float, float* %14
%47 = fptosi float %46 to i32
%48 = add nsw i32 %45, %47
store i32 %48, i32* %12
%49 = load i32*, i32** %6
%50 = load i32, i32* %13
%51 = load i32, i32* %12
%52 = load i8*, i8** %10
%53 = call i32 @mvwprintw(i32* %49, i32 %50, i32 %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %52)
%54 = 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) {
%6 = icmp eq i32* %0, null
%7 = load i32*, i32** @stdscr
%8 = select i1 %6, i32* %7, i32* %0
%9 = tail call i32 @getyx(i32* %8, i32 undef, i32 undef)
%10 = icmp eq i32 %3, 0
%11 = select i1 %10, i32 80, i32 %3
%12 = tail call i32 @strlen(i8* %4)
%13 = sub nsw i32 %11, %12
%14 = sdiv i32 %13, 2
%15 = sitofp i32 %14 to float
%16 = fptosi float %15 to i32
%17 = add nsw i32 %16, %2
%18 = tail call i32 @mvwprintw(i32* %8, i32 %1, i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%19 = tail call i32 (...) @refresh()
ret void
}