#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_STANDOUT;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ refresh();
void draw_menu(char *options[], int current_highlight, int start_row,
               int start_col) {
  int current_row = 0;
  char **option_ptr;
  char *txt_ptr;
  option_ptr = options;
  while (*option_ptr) {
    if (current_row == current_highlight)
      attron(A_STANDOUT);
    txt_ptr = options[current_row];
    txt_ptr++;
    mvprintw(start_row + current_row, start_col, "%s", txt_ptr);
    if (current_row == current_highlight)
      attroff(A_STANDOUT);
    current_row++;
    option_ptr++;
  }
  mvprintw(start_row + current_row + 3, start_col,
           "Move highlight then press Return ");
  refresh();
}


x86 assembly (clang, -O0):
<draw_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f7 <draw_menu+0xb7>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    118c <draw_menu+0x4c>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1040 <attron@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%rcx
lea    0xe44(%rip),%rdx
mov    $0x0,%al
call   1060 <mvprintw@plt>
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11dd <draw_menu+0x9d>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1164 <draw_menu+0x24>
mov    -0x10(%rbp),%edi
add    -0x18(%rbp),%edi
add    $0x3,%edi
mov    -0x14(%rbp),%esi
lea    0xdf9(%rip),%rdx
mov    $0x0,%al
call   1060 <mvprintw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r13d
cmpq   $0x0,(%rdi)
je     11f6 <draw_menu+0xb6>
mov    %esi,%r15d
mov    %rdi,%rbp
mov    %esi,%ebx
add    %edx,%r15d
mov    %rdx,0x8(%rsp)
mov    %edx,%eax
mov    %rax,0x10(%rsp)
xor    %r14d,%r14d
jmp    11b2 <draw_menu+0x72>
nopw   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rcx
add    $0x1,%rcx
mov    0x10(%rsp),%rax
lea    (%rax,%r14,1),%edi
mov    %r13d,%esi
lea    0xe64(%rip),%rdx
xor    %eax,%eax
call   1060 <mvprintw@plt>
lea    0x1(%r14),%rax
cmpq   $0x0,0x8(%rbp,%r14,8)
mov    %rax,%r14
je     11ef <draw_menu+0xaf>
cmp    %r14,%rbx
jne    1180 <draw_menu+0x40>
mov    0x2e22(%rip),%r12
mov    (%r12),%edi
call   1040 <attron@plt>
mov    0x0(%rbp,%rbx,8),%rcx
add    $0x1,%rcx
mov    %r15d,%edi
mov    %r13d,%esi
lea    0xe23(%rip),%rdx
xor    %eax,%eax
call   1060 <mvprintw@plt>
mov    (%r12),%edi
call   1030 <attroff@plt>
jmp    11a3 <draw_menu+0x63>
mov    0x8(%rsp),%rdx
jmp    11f8 <draw_menu+0xb8>
xor    %eax,%eax
lea    (%rax,%rdx,1),%edi
add    $0x3,%edi
lea    0xdfe(%rip),%rdx
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <mvprintw@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <refresh@plt>

LLVM IR (-O0):
@A_STANDOUT = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [34 x i8] c"Move highlight then press Return \00"
define void @draw_menu(i8** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i8*
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%12 = load i8**, i8*** %5
store i8** %12, i8*** %10
br label %13
13: ; preds = %44, %4
%14 = load i8**, i8*** %10
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %49
17: ; preds = %13
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* @A_STANDOUT
%23 = call i32 @attron(i32 %22)
br label %24
24: ; preds = %21, %17
%25 = load i8**, i8*** %5
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %11
%30 = load i8*, i8** %11
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %11
%32 = load i32, i32* %7
%33 = load i32, i32* %9
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %8
%36 = load i8*, i8** %11
%37 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %34, i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %9
%39 = load i32, i32* %6
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %44
41: ; preds = %24
%42 = load i32, i32* @A_STANDOUT
%43 = call i32 @attroff(i32 %42)
br label %44
44: ; preds = %41, %24
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
%47 = load i8**, i8*** %10
%48 = getelementptr inbounds i8*, i8** %47, i32 1
store i8** %48, i8*** %10
br label %13
49: ; preds = %13
%50 = load i32, i32* %7
%51 = load i32, i32* %9
%52 = add nsw i32 %50, %51
%53 = add nsw i32 %52, 3
%54 = load i32, i32* %8
%55 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %53, i32 %54, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%56 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@A_STANDOUT = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [34 x i8] c"Move highlight then press Return \00"
define void @draw_menu(i8** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %37, label %7
7: ; preds = %4
%8 = zext i32 %1 to i64
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = add nsw i32 %1, %2
br label %11
11: ; preds = %7, %30
%12 = phi i64 [ 0, %7 ], [ %31, %30 ]
%13 = phi i8** [ %0, %7 ], [ %32, %30 ]
%14 = icmp eq i64 %12, %8
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* @A_STANDOUT
%17 = tail call i32 @attron(i32 %16)
%18 = load i8*, i8** %9
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %10, i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @A_STANDOUT
%22 = tail call i32 @attroff(i32 %21)
br label %30
23: ; preds = %11
%24 = getelementptr inbounds i8*, i8** %0, i64 %12
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = trunc i64 %12 to i32
%28 = add nsw i32 %27, %2
%29 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %28, i32 %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %30
30: ; preds = %23, %15
%31 = add nuw i64 %12, 1
%32 = getelementptr inbounds i8*, i8** %13, i64 1
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %11
35: ; preds = %30
%36 = trunc i64 %31 to i32
br label %37
37: ; preds = %35, %4
%38 = phi i32 [ 0, %4 ], [ %36, %35 ]
%39 = add nsw i32 %38, %2
%40 = add nsw i32 %39, 3
%41 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %40, i32 %3, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%42 = tail call i32 (...) @refresh()
ret void
}