#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*/ gclrline();
int /*<<< orphan*/ gmove(int, int);
int /*<<< orphan*/ gprintf(char *, int);
int /*<<< orphan*/ gputs(char *);
int mode;
void help() {
  static mode = 0;
  gmove(20, 1);
  gprintf("Commands, Page %d  (Press ? for More Help)", mode + 1);
  gclrline();
  switch (mode) {
  case 0:
    gmove(21, 1);
    gputs("  (n)ext group  (p)revious group  (N)last (P)first");
    gclrline();
    gmove(22, 1);
    gputs("  (s)tatus display  (i)nformation mode");
    gputs("  (a)rmy production");
    gclrline();
    gmove(23, 1);
    gputs("  (R)ead news  read (M)ail  (S)end mail  (q)uit");
    gclrline();
    break;
  case 1:
    gmove(21, 1);
    gputs("  (j)pointer down  (k)pointer up  (SPACE)mark  (*)mark all");
    gclrline();
    gmove(22, 1);
    gputs("  (m)ove marked armies  (r)ename hero  (q)uit");
    gclrline();
    gmove(23, 1);
    gclrline();
    break;
  }
  mode++;
  mode %= 2;
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
mov    0x2ee7(%rip),%esi
add    $0x1,%esi
lea    0xe99(%rip),%rdi
call   1030 <gprintf@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    0x2ecb(%rip),%eax
mov    %eax,-0x4(%rbp)
test   %eax,%eax
je     119a <help+0x5a>
jmp    1189 <help+0x49>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
je     1211 <help+0xd1>
jmp    126b <help+0x12b>
mov    $0x15,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xe7b(%rip),%rdi
call   1040 <gputs@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xe8c(%rip),%rdi
call   1040 <gputs@plt>
lea    0xea7(%rip),%rdi
call   1040 <gputs@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xe99(%rip),%rdi
call   1040 <gputs@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
jmp    126b <help+0x12b>
mov    $0x15,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xea2(%rip),%rdi
call   1040 <gputs@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xebb(%rip),%rdi
call   1040 <gputs@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
mov    $0x0,%al
call   1050 <gclrline@plt>
mov    0x2dd3(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2dca(%rip)
mov    0x2dc4(%rip),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,0x2db6(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help>:
push   %rax
mov    $0x14,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
mov    0x2eee(%rip),%esi
add    $0x1,%esi
lea    0xea0(%rip),%rdi
call   1030 <gprintf@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    0x2ed2(%rip),%eax
cmp    $0x1,%eax
je     11ec <help+0xac>
test   %eax,%eax
jne    1246 <help+0x106>
mov    $0x15,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xe96(%rip),%rdi
call   1040 <gputs@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xea7(%rip),%rdi
call   1040 <gputs@plt>
lea    0xec2(%rip),%rdi
call   1040 <gputs@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xeb4(%rip),%rdi
call   1040 <gputs@plt>
jmp    123f <help+0xff>
mov    $0x15,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xec7(%rip),%rdi
call   1040 <gputs@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    $0x16,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
lea    0xee0(%rip),%rdi
call   1040 <gputs@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    $0x17,%edi
mov    $0x1,%esi
call   1060 <gmove@plt>
xor    %eax,%eax
call   1050 <gclrline@plt>
mov    0x2df8(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
add    $0x1,%ecx
and    $0xfffffffe,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,0x2ddb(%rip)
pop    %rax
ret

LLVM IR (-O0):
@help.mode = internal global i32 0
@.str = [43 x i8] c"Commands, Page %d (Press ? for More Help)\00"
@.str.1 = [51 x i8] c" (n)ext group (p)revious group (N)last (P)first\00"
@.str.2 = [39 x i8] c" (s)tatus display (i)nformation mode\00"
@.str.3 = [20 x i8] c" (a)rmy production\00"
@.str.4 = [48 x i8] c" (R)ead news read (M)ail (S)end mail (q)uit\00"
@.str.5 = [59 x i8] c" (j)pointer down (k)pointer up (SPACE)mark (*)mark all\00"
@.str.6 = [46 x i8] c" (m)ove marked armies (r)ename hero (q)uit\00"
@mode = global i32 0
define void @help() {
%1 = call i32 @gmove(i32 20, i32 1)
%2 = load i32, i32* @help.mode
%3 = add nsw i32 %2, 1
%4 = call i32 @gprintf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 (...) @gclrline()
%6 = load i32, i32* @help.mode
switch i32 %6, label %27 [
i32 0, label %7
i32 1, label %18
]
7: ; preds = %0
%8 = call i32 @gmove(i32 21, i32 1)
%9 = call i32 @gputs(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @gclrline()
%11 = call i32 @gmove(i32 22, i32 1)
%12 = call i32 @gputs(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @gputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (...) @gclrline()
%15 = call i32 @gmove(i32 23, i32 1)
%16 = call i32 @gputs(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (...) @gclrline()
br label %27
18: ; preds = %0
%19 = call i32 @gmove(i32 21, i32 1)
%20 = call i32 @gputs(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (...) @gclrline()
%22 = call i32 @gmove(i32 22, i32 1)
%23 = call i32 @gputs(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (...) @gclrline()
%25 = call i32 @gmove(i32 23, i32 1)
%26 = call i32 (...) @gclrline()
br label %27
27: ; preds = %0, %18, %7
%28 = load i32, i32* @help.mode
%29 = add nsw i32 %28, 1
store i32 %29, i32* @help.mode
%30 = load i32, i32* @help.mode
%31 = srem i32 %30, 2
store i32 %31, i32* @help.mode
ret void
}

LLVM IR (-O2):
@help.mode = internal unnamed_addr global i32 0
@.str = [43 x i8] c"Commands, Page %d (Press ? for More Help)\00"
@.str.1 = [51 x i8] c" (n)ext group (p)revious group (N)last (P)first\00"
@.str.2 = [39 x i8] c" (s)tatus display (i)nformation mode\00"
@.str.3 = [20 x i8] c" (a)rmy production\00"
@.str.4 = [48 x i8] c" (R)ead news read (M)ail (S)end mail (q)uit\00"
@.str.5 = [59 x i8] c" (j)pointer down (k)pointer up (SPACE)mark (*)mark all\00"
@.str.6 = [46 x i8] c" (m)ove marked armies (r)ename hero (q)uit\00"
@mode = global i32 0
define void @help() {
%1 = tail call i32 @gmove(i32 20, i32 1)
%2 = load i32, i32* @help.mode
%3 = add nsw i32 %2, 1
%4 = tail call i32 @gprintf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @gclrline()
%6 = load i32, i32* @help.mode
switch i32 %6, label %27 [
i32 0, label %7
i32 1, label %17
]
7: ; preds = %0
%8 = tail call i32 @gmove(i32 21, i32 1)
%9 = tail call i32 @gputs(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @gclrline()
%11 = tail call i32 @gmove(i32 22, i32 1)
%12 = tail call i32 @gputs(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @gputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 (...) @gclrline()
%15 = tail call i32 @gmove(i32 23, i32 1)
%16 = tail call i32 @gputs(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %25
17: ; preds = %0
%18 = tail call i32 @gmove(i32 21, i32 1)
%19 = tail call i32 @gputs(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%20 = tail call i32 (...) @gclrline()
%21 = tail call i32 @gmove(i32 22, i32 1)
%22 = tail call i32 @gputs(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%23 = tail call i32 (...) @gclrline()
%24 = tail call i32 @gmove(i32 23, i32 1)
br label %25
25: ; preds = %7, %17
%26 = tail call i32 (...) @gclrline()
br label %27
27: ; preds = %25, %0
%28 = load i32, i32* @help.mode
%29 = add nsw i32 %28, 1
%30 = srem i32 %29, 2
store i32 %30, i32* @help.mode
ret void
}