#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*/ erase();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ mvaddstr(int, int, char const *);
int /*<<< orphan*/ refresh();
void showhelp(void) {
  static char const *helptext[][2] = {
      {"Move", "Arrows or H J K L"},
      {
          "Undo previous move",
          "-",
      },
      {"Redo next move", "+ or ="},
      {"Undo 10 moves", "PageUp"},
      {"Redo 10 moves", "PageDown"},
      {"Redo to next branch point", "Tab"},
      {"Undo to previous branch point", "Backspace"},
      {"Undo to the starting position", "Home"},
      {"Redo to the shorter solution", "End"},
      {"Undo and delete previous move", "X"},
      {"Switch to \"better\" position", "B"},
      {"Copy moves from \"better\" position", "C"},
      {"Redraw the screen", "Ctrl-L"},
      {"Display this help", "? or F1"},
      {"Quit the program", "Q"}};
  int i;
  erase();
  mvaddstr(0, 0, "KEY COMMANDS");
  for (i = 0; i < (int)(sizeof helptext / sizeof *helptext); ++i) {
    mvaddstr(i + 2, 4, helptext[i][0]);
    mvaddstr(i + 2, 40, helptext[i][1]);
  }
  mvaddstr(i + 3, 0, "Press any key to resume.");
  refresh();
  getch();
}


x86 assembly (clang, -O0):
<showhelp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <erase@plt>
xor    %esi,%esi
lea    0x1048(%rip),%rdx
mov    %esi,%edi
call   1060 <mvaddstr@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xf,-0x4(%rbp)
jge    11c9 <showhelp+0x89>
mov    -0x4(%rbp),%edi
add    $0x2,%edi
movslq -0x4(%rbp),%rcx
lea    0x2ecf(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdx
mov    $0x4,%esi
call   1060 <mvaddstr@plt>
mov    -0x4(%rbp),%edi
add    $0x2,%edi
movslq -0x4(%rbp),%rcx
lea    0x2eaa(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
mov    $0x28,%esi
call   1060 <mvaddstr@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1166 <showhelp+0x26>
mov    -0x4(%rbp),%edi
add    $0x3,%edi
xor    %esi,%esi
lea    0xfd5(%rip),%rdx
call   1060 <mvaddstr@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x0,%al
call   1050 <getch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showhelp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <erase@plt>
lea    0x104b(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   1060 <mvaddstr@plt>
mov    $0x2,%ebp
mov    $0x8,%ebx
lea    0x2bc1(%rip),%r15
nop
mov    -0x8(%rbx,%r15,1),%rdx
mov    (%rbx,%r15,1),%r14
mov    %ebp,%edi
mov    $0x4,%esi
call   1060 <mvaddstr@plt>
mov    %ebp,%edi
mov    $0x28,%esi
mov    %r14,%rdx
call   1060 <mvaddstr@plt>
add    $0x1,%ebp
add    $0x10,%rbx
cmp    $0xf8,%rbx
jne    1170 <showhelp+0x30>
lea    0x1002(%rip),%rdx
mov    $0x12,%edi
xor    %esi,%esi
call   1060 <mvaddstr@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <getch@plt>

LLVM IR (-O0):
@showhelp.helptext = internal global [15 x [2 x i8*]] [[2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.29, i32 0, i32 0)]]
@.str = [5 x i8] c"Move\00"
@.str.1 = [18 x i8] c"Arrows or H J K L\00"
@.str.2 = [19 x i8] c"Undo previous move\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"Redo next move\00"
@.str.5 = [7 x i8] c"+ or =\00"
@.str.6 = [14 x i8] c"Undo 10 moves\00"
@.str.7 = [7 x i8] c"PageUp\00"
@.str.8 = [14 x i8] c"Redo 10 moves\00"
@.str.9 = [9 x i8] c"PageDown\00"
@.str.10 = [26 x i8] c"Redo to next branch point\00"
@.str.11 = [4 x i8] c"Tab\00"
@.str.12 = [30 x i8] c"Undo to previous branch point\00"
@.str.13 = [10 x i8] c"Backspace\00"
@.str.14 = [30 x i8] c"Undo to the starting position\00"
@.str.15 = [5 x i8] c"Home\00"
@.str.16 = [29 x i8] c"Redo to the shorter solution\00"
@.str.17 = [4 x i8] c"End\00"
@.str.18 = [30 x i8] c"Undo and delete previous move\00"
@.str.19 = [2 x i8] c"X\00"
@.str.20 = [28 x i8] c"Switch to \22better\22 position\00"
@.str.21 = [2 x i8] c"B\00"
@.str.22 = [34 x i8] c"Copy moves from \22better\22 position\00"
@.str.23 = [2 x i8] c"C\00"
@.str.24 = [18 x i8] c"Redraw the screen\00"
@.str.25 = [7 x i8] c"Ctrl-L\00"
@.str.26 = [18 x i8] c"Display this help\00"
@.str.27 = [8 x i8] c"? or F1\00"
@.str.28 = [17 x i8] c"Quit the program\00"
@.str.29 = [2 x i8] c"Q\00"
@.str.30 = [13 x i8] c"KEY COMMANDS\00"
@.str.31 = [25 x i8] c"Press any key to resume.\00"
define void @showhelp() {
%1 = alloca i32
%2 = call i32 (...) @erase()
%3 = call i32 @mvaddstr(i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.30, i64 0, i64 0))
store i32 0, i32* %1
br label %4
4: ; preds = %24, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 15
br i1 %6, label %7, label %27
7: ; preds = %4
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 2
%10 = load i32, i32* %1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [15 x [2 x i8*]], [15 x [2 x i8*]]* @showhelp.helptext, i64 0, i64 %11
%13 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @mvaddstr(i32 %9, i32 4, i8* %14)
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 2
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [15 x [2 x i8*]], [15 x [2 x i8*]]* @showhelp.helptext, i64 0, i64 %19
%21 = getelementptr inbounds [2 x i8*], [2 x i8*]* %20, i64 0, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @mvaddstr(i32 %17, i32 40, i8* %22)
br label %24
24: ; preds = %7
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %4
27: ; preds = %4
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 3
%30 = call i32 @mvaddstr(i32 %29, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.31, i64 0, i64 0))
%31 = call i32 (...) @refresh()
%32 = call i32 (...) @getch()
ret void
}

LLVM IR (-O2):
@showhelp.helptext = internal unnamed_addr constant [15 x [2 x i8*]] [[2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.17, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.19, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.21, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i32 0, i32 0)], [2 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.29, i32 0, i32 0)]]
@.str = [5 x i8] c"Move\00"
@.str.1 = [18 x i8] c"Arrows or H J K L\00"
@.str.2 = [19 x i8] c"Undo previous move\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"Redo next move\00"
@.str.5 = [7 x i8] c"+ or =\00"
@.str.6 = [14 x i8] c"Undo 10 moves\00"
@.str.7 = [7 x i8] c"PageUp\00"
@.str.8 = [14 x i8] c"Redo 10 moves\00"
@.str.9 = [9 x i8] c"PageDown\00"
@.str.10 = [26 x i8] c"Redo to next branch point\00"
@.str.11 = [4 x i8] c"Tab\00"
@.str.12 = [30 x i8] c"Undo to previous branch point\00"
@.str.13 = [10 x i8] c"Backspace\00"
@.str.14 = [30 x i8] c"Undo to the starting position\00"
@.str.15 = [5 x i8] c"Home\00"
@.str.16 = [29 x i8] c"Redo to the shorter solution\00"
@.str.17 = [4 x i8] c"End\00"
@.str.18 = [30 x i8] c"Undo and delete previous move\00"
@.str.19 = [2 x i8] c"X\00"
@.str.20 = [28 x i8] c"Switch to \22better\22 position\00"
@.str.21 = [2 x i8] c"B\00"
@.str.22 = [34 x i8] c"Copy moves from \22better\22 position\00"
@.str.23 = [2 x i8] c"C\00"
@.str.24 = [18 x i8] c"Redraw the screen\00"
@.str.25 = [7 x i8] c"Ctrl-L\00"
@.str.26 = [18 x i8] c"Display this help\00"
@.str.27 = [8 x i8] c"? or F1\00"
@.str.28 = [17 x i8] c"Quit the program\00"
@.str.29 = [2 x i8] c"Q\00"
@.str.30 = [13 x i8] c"KEY COMMANDS\00"
@.str.31 = [25 x i8] c"Press any key to resume.\00"
define void @showhelp() {
%1 = tail call i32 (...) @erase()
%2 = tail call i32 @mvaddstr(i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.30, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %13, %3 ]
%5 = getelementptr inbounds [15 x [2 x i8*]], [15 x [2 x i8*]]* @showhelp.helptext, i64 0, i64 %4, i64 0
%6 = load i8*, i8** %5
%7 = trunc i64 %4 to i32
%8 = add i32 %7, 2
%9 = tail call i32 @mvaddstr(i32 %8, i32 4, i8* %6)
%10 = getelementptr inbounds [15 x [2 x i8*]], [15 x [2 x i8*]]* @showhelp.helptext, i64 0, i64 %4, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @mvaddstr(i32 %8, i32 40, i8* %11)
%13 = add nuw nsw i64 %4, 1
%14 = icmp eq i64 %13, 15
br i1 %14, label %15, label %3
15: ; preds = %3
%16 = tail call i32 @mvaddstr(i32 18, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.31, i64 0, i64 0))
%17 = tail call i32 (...) @refresh()
%18 = tail call i32 (...) @getch()
ret void
}