#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*/ A_BOLD;
int COLS;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *, char *);
int strlen(char *);
void show_menu_options(char *title, char *options[], int num_options) {
  int i, xpos = 0;
  xpos = (COLS - strlen(title)) / 2;
  attron(A_BOLD);
  mvprintw(2, xpos, "%s", title);
  attroff(A_BOLD);
  for (i = 0; i < num_options; i++) {
    xpos = (COLS - strlen(options[i])) / 2;
    mvprintw(i + 5, xpos, "%s", options[i]);
  }
}


x86 assembly (clang, -O0):
<show_menu_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rcx
mov    $0x2,%edi
lea    0xe5e(%rip),%rdx
call   1060 <mvprintw@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1226 <show_menu_options+0xe6>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
add    $0x5,%edi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xded(%rip),%rdx
call   1060 <mvprintw@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bc <show_menu_options+0x7c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_menu_options>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
mov    0x2e8d(%rip),%rbx
mov    (%rbx),%r13d
call   1040 <strlen@plt>
sub    %eax,%r13d
mov    %r13d,%ebp
shr    $0x1f,%ebp
add    %r13d,%ebp
sar    %ebp
mov    0x2e60(%rip),%r13
mov    0x0(%r13),%edi
call   1050 <attron@plt>
lea    0xe78(%rip),%rdx
mov    $0x2,%edi
mov    %ebp,%esi
mov    %r15,%rcx
call   1060 <mvprintw@plt>
mov    0x0(%r13),%edi
mov    %rbx,%r13
call   1030 <attroff@plt>
test   %r14d,%r14d
jle    11f0 <show_menu_options+0xb0>
mov    %r14d,%r15d
xor    %ebp,%ebp
lea    0xe4c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13),%ebx
mov    (%r12,%rbp,8),%rdi
call   1040 <strlen@plt>
sub    %eax,%ebx
mov    %ebx,%esi
shr    $0x1f,%esi
add    %ebx,%esi
sar    %esi
mov    (%r12,%rbp,8),%rcx
lea    0x5(%rbp),%edi
mov    %r14,%rdx
call   1060 <mvprintw@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    11c0 <show_menu_options+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLS = global i32 0
@A_BOLD = global i32 0
@.str = [3 x i8] c"%s\00"
define void @show_menu_options(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %8
%9 = load i32, i32* @COLS
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %9, %11
%13 = sdiv i32 %12, 2
store i32 %13, i32* %8
%14 = load i32, i32* @A_BOLD
%15 = call i32 @attron(i32 %14)
%16 = load i32, i32* %8
%17 = load i8*, i8** %4
%18 = call i32 @mvprintw(i32 2, i32 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i32, i32* @A_BOLD
%20 = call i32 @attroff(i32 %19)
store i32 0, i32* %7
br label %21
21: ; preds = %44, %3
%22 = load i32, i32* %7
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %47
25: ; preds = %21
%26 = load i32, i32* @COLS
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %26, %32
%34 = sdiv i32 %33, 2
store i32 %34, i32* %8
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 5
%37 = load i32, i32* %8
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @mvprintw(i32 %36, i32 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %25
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %21
47: ; preds = %21
ret void
}

LLVM IR (-O2):
@COLS = global i32 0
@A_BOLD = global i32 0
@.str = [3 x i8] c"%s\00"
define void @show_menu_options(i8* %0, i8** nocapture %1, i32 %2) {
%4 = load i32, i32* @COLS
%5 = tail call i32 @strlen(i8* %0)
%6 = sub nsw i32 %4, %5
%7 = sdiv i32 %6, 2
%8 = load i32, i32* @A_BOLD
%9 = tail call i32 @attron(i32 %8)
%10 = tail call i32 @mvprintw(i32 2, i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = load i32, i32* @A_BOLD
%12 = tail call i32 @attroff(i32 %11)
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %30
14: ; preds = %3
%15 = zext i32 %2 to i64
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %28, %16 ]
%18 = load i32, i32* @COLS
%19 = getelementptr inbounds i8*, i8** %1, i64 %17
%20 = load i8*, i8** %19
%21 = tail call i32 @strlen(i8* %20)
%22 = sub nsw i32 %18, %21
%23 = sdiv i32 %22, 2
%24 = load i8*, i8** %19
%25 = trunc i64 %17 to i32
%26 = add i32 %25, 5
%27 = tail call i32 @mvprintw(i32 %26, i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
%28 = add nuw nsw i64 %17, 1
%29 = icmp eq i64 %28, %15
br i1 %29, label %30, label %16
30: ; preds = %16, %3
ret void
}