#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 fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reset_tty();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdin;
int tolower(int);
int /*<<< orphan*/ usleep(int);
int help(void) {
  reset_tty();
  printf("\r\n\r\nPress the following keys during the replay session:\r\n");
  printf("    f or /    Find a string (not implemented yet)\r\n");
  printf("    n or /    Find the next match (not yet implemented)\r\n");
  printf("    r or ?    Find backwards (not implemented yet)\r\n");
  printf("    b         Back up 1 line\r\n");
  printf("    <enter>   Display next line\r\n");
  printf("    <anykey>  Display next char\r\n");
  printf("    q         quit\r\n");
  printf("    + or p    Starts auto-replay\r\n");
  printf("    d         Toggle debug mode\r\n");
  printf("\r\n");
  printf("During playback:\r\n");
  printf("    +         Increase playback speed\r\n");
  printf("    -         Decrease playback speed\r\n");
  printf("    <anykey>  End auto-replay \r\n");
  sleep(2);
  int c, answer;
  c = -1;
  while (c < 1) {
    c = fgetc(stdin);
    answer = tolower(c);
    usleep(500);
  }
  return 1;
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <reset_tty@plt>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4a(%rip),%rdi
call   1030 <printf@plt>
lea    0xf60(%rip),%rdi
call   1030 <printf@plt>
lea    0xf76(%rip),%rdi
call   1030 <printf@plt>
lea    0xf7f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf96(%rip),%rdi
call   1030 <printf@plt>
lea    0x102d(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa0(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa7(%rip),%rdi
call   1030 <printf@plt>
lea    0xfc3(%rip),%rdi
call   1030 <printf@plt>
lea    0xfdf(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2,%edi
call   1070 <sleep@plt>
movl   $0xffffffff,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
jge    1269 <help+0x109>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <tolower@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1f4,%edi
call   1080 <usleep@plt>
jmp    1234 <help+0xd4>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <reset_tty@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf47(%rip),%rdi
call   1030 <puts@plt>
lea    0xf59(%rip),%rdi
call   1030 <puts@plt>
lea    0xf6e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf83(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa1(%rip),%rdi
call   1030 <puts@plt>
lea    0x1034(%rip),%rdi
call   1030 <puts@plt>
lea    0xfaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xfcb(%rip),%rdi
call   1030 <puts@plt>
lea    0xfe6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
mov    0x2dc8(%rip),%r14
mov    (%r14),%edi
call   1040 <fgetc@plt>
mov    %eax,%ebx
mov    $0x1f4,%edi
call   1070 <usleep@plt>
test   %ebx,%ebx
jle    1220 <help+0xd0>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [58 x i8] c"\0D\0A\0D\0APress the following keys during the replay session:\0D\0A\00"
@.str.1 = [52 x i8] c" f or / Find a string (not implemented yet)\0D\0A\00"
@.str.2 = [58 x i8] c" n or / Find the next match (not yet implemented)\0D\0A\00"
@.str.3 = [53 x i8] c" r or ? Find backwards (not implemented yet)\0D\0A\00"
@.str.4 = [31 x i8] c" b Back up 1 line\0D\0A\00"
@.str.5 = [34 x i8] c" <enter> Display next line\0D\0A\00"
@.str.6 = [34 x i8] c" <anykey> Display next char\0D\0A\00"
@.str.7 = [21 x i8] c" q quit\0D\0A\00"
@.str.8 = [35 x i8] c" + or p Starts auto-replay\0D\0A\00"
@.str.9 = [34 x i8] c" d Toggle debug mode\0D\0A\00"
@.str.10 = [3 x i8] c"\0D\0A\00"
@.str.11 = [19 x i8] c"During playback:\0D\0A\00"
@.str.12 = [40 x i8] c" + Increase playback speed\0D\0A\00"
@.str.13 = [40 x i8] c" - Decrease playback speed\0D\0A\00"
@.str.14 = [33 x i8] c" <anykey> End auto-replay \0D\0A\00"
@stdin = global i32 0
define i32 @help() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @reset_tty()
%4 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.12, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.13, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0))
%19 = call i32 @sleep(i32 2)
store i32 -1, i32* %1
br label %20
20: ; preds = %23, %0
%21 = load i32, i32* %1
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* @stdin
%25 = call i32 @fgetc(i32 %24)
store i32 %25, i32* %1
%26 = load i32, i32* %1
%27 = call i32 @tolower(i32 %26)
store i32 %27, i32* %2
%28 = call i32 @usleep(i32 500)
br label %20
29: ; preds = %20
ret i32 1
}

LLVM IR (-O2):
@stdin = global i32 0
@str = [57 x i8] c"\0D\0A\0D\0APress the following keys during the replay session:\0D\00"
@str.15 = [51 x i8] c" f or / Find a string (not implemented yet)\0D\00"
@str.16 = [57 x i8] c" n or / Find the next match (not yet implemented)\0D\00"
@str.17 = [52 x i8] c" r or ? Find backwards (not implemented yet)\0D\00"
@str.18 = [30 x i8] c" b Back up 1 line\0D\00"
@str.19 = [33 x i8] c" <enter> Display next line\0D\00"
@str.20 = [33 x i8] c" <anykey> Display next char\0D\00"
@str.21 = [20 x i8] c" q quit\0D\00"
@str.22 = [34 x i8] c" + or p Starts auto-replay\0D\00"
@str.23 = [33 x i8] c" d Toggle debug mode\0D\00"
@str.24 = [2 x i8] c"\0D\00"
@str.25 = [18 x i8] c"During playback:\0D\00"
@str.26 = [39 x i8] c" + Increase playback speed\0D\00"
@str.27 = [39 x i8] c" - Decrease playback speed\0D\00"
@str.28 = [32 x i8] c" <anykey> End auto-replay \0D\00"
define i32 @help() {
%1 = tail call i32 (...) @reset_tty()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.16, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.17, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.18, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.19, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.20, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.21, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.22, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.23, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.24, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.25, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.26, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.27, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.28, i64 0, i64 0))
%17 = tail call i32 @sleep(i32 2)
br label %18
18: ; preds = %0, %18
%19 = load i32, i32* @stdin
%20 = tail call i32 @fgetc(i32 %19)
%21 = tail call i32 @usleep(i32 500)
%22 = icmp slt i32 %20, 1
br i1 %22, label %18, label %23
23: ; preds = %18
ret i32 1
}