#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 */
char *MAP_FAILED;
int MAP_FILE;
int MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ PrintInterfaceKB();
int /*<<< orphan*/ Sleep(int);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int, char *);
char getch();
scalar_t__ kbhit();
scalar_t__ mmap(int /*<<< orphan*/ *, int, int, int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  int mmapfd;
  char *mmap_file;
  int press = 0;
  if ((mmapfd = open("mmap.in", O_RDWR, 0)) == -1)
    err(1, "cannot open input file=mmap.in");
  mmap_file = (char *)mmap(NULL, 4096, PROT_READ | PROT_WRITE,
                           MAP_FILE | MAP_SHARED, mmapfd, 0);
  if (mmap_file == MAP_FAILED)
    errx(1, "either mmap");
  strcpy(mmap_file, "\0");
  int Quit = 0;
  PrintInterfaceKB();
  while (!Quit) {
    if (kbhit()) {
      char c;
      c = getch();
      strcpy(mmap_file, "\0");
      press++;
      if (c == 'q') {
        Quit = 1;
        strcpy(mmap_file, "quit");
      }
      if (c == 's') {
        strcpy(mmap_file, "start");
      }
      if (c == 'S') {
        strcpy(mmap_file, "STOP");
      }
      if (c == 'c') {
        strcpy(mmap_file, "clear");
      }
      if (c == 'a') {
        strcpy(mmap_file, "autosaveON");
      }
      if (c == 'A') {
        strcpy(mmap_file, "autosaveOFF");
      }
      if (c == 't') {
        strcpy(mmap_file, "trigger");
      }
      if (c == 'p') {
        strcpy(mmap_file, "probe_up");
      }
      if (c == 'P') {
        strcpy(mmap_file, "probe_down");
      }
      if (c == 'h') {
        strcpy(mmap_file, "histogram");
      }
      if (c == 'w') {
        strcpy(mmap_file, "wave");
      }
      if (c == 'r') {
        strcpy(mmap_file, "restart");
      }
      if (c == 'i') {
        strcpy(mmap_file, "init");
      }
      if (c == 'd') {
        strcpy(mmap_file, "displayON");
      }
      if (c == 'D') {
        strcpy(mmap_file, "displayOFF");
      }
      if (0 == press % 10)
        PrintInterfaceKB();
      printf("%s\n", mmap_file);
    }
    Sleep(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
lea    0xe4a(%rip),%rdi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    11f1 <main+0x51>
mov    $0x1,%edi
lea    0xe14(%rip),%rsi
call   1090 <err@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
mov    0x2dbf(%rip),%rax
or     (%rax),%edx
mov    0x2dc6(%rip),%rax
mov    (%rax),%ecx
mov    0x2dd5(%rip),%rax
or     (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1000,%esi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2d7f(%rip),%rcx
cmp    (%rcx),%rax
jne    1253 <main+0xb3>
mov    $0x1,%edi
lea    0xdd1(%rip),%rsi
call   1060 <errx@plt>
mov    -0x20(%rbp),%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <PrintInterfaceKB@plt>
cmpl   $0x0,-0x28(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1287 <main+0xe7>
jmp    14b0 <main+0x310>
mov    $0x0,%al
call   1080 <kbhit@plt>
cmp    $0x0,%rax
je     14a1 <main+0x301>
mov    $0x0,%al
call   10a0 <getch@plt>
mov    %al,-0x29(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x71,%eax
jne    12df <main+0x13f>
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd51(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x73,%eax
jne    12fc <main+0x15c>
mov    -0x20(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x53,%eax
jne    1319 <main+0x179>
mov    -0x20(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x63,%eax
jne    1336 <main+0x196>
mov    -0x20(%rbp),%rdi
lea    0xd04(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x61,%eax
jne    1353 <main+0x1b3>
mov    -0x20(%rbp),%rdi
lea    0xced(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x41,%eax
jne    1370 <main+0x1d0>
mov    -0x20(%rbp),%rdi
lea    0xcdb(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x74,%eax
jne    138d <main+0x1ed>
mov    -0x20(%rbp),%rdi
lea    0xcca(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x70,%eax
jne    13aa <main+0x20a>
mov    -0x20(%rbp),%rdi
lea    0xcb5(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x50,%eax
jne    13c7 <main+0x227>
mov    -0x20(%rbp),%rdi
lea    0xca1(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x68,%eax
jne    13e4 <main+0x244>
mov    -0x20(%rbp),%rdi
lea    0xc8f(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x77,%eax
jne    1401 <main+0x261>
mov    -0x20(%rbp),%rdi
lea    0xc7c(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x72,%eax
jne    141e <main+0x27e>
mov    -0x20(%rbp),%rdi
lea    0xc64(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x69,%eax
jne    143b <main+0x29b>
mov    -0x20(%rbp),%rdi
lea    0xc4f(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x64,%eax
jne    1458 <main+0x2b8>
mov    -0x20(%rbp),%rdi
lea    0xc37(%rip),%rsi
call   1030 <strcpy@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x44,%eax
jne    1475 <main+0x2d5>
mov    -0x20(%rbp),%rdi
lea    0xc24(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    1491 <main+0x2f1>
mov    $0x0,%al
call   1040 <PrintInterfaceKB@plt>
mov    -0x20(%rbp),%rsi
lea    0xc03(%rip),%rdi
call   1070 <printf@plt>
mov    $0xa,%edi
call   10c0 <Sleep@plt>
jmp    1271 <main+0xd1>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e26(%rip),%rax
mov    (%rax),%esi
lea    0xf3a(%rip),%rdi
xor    %edx,%edx
call   10b0 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11da <main+0x3a>
lea    0xf0e(%rip),%rsi
mov    $0x1,%edi
call   1090 <err@plt>
mov    0x2e17(%rip),%rax
mov    0x2dd8(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2ddd(%rip),%rax
mov    0x2dee(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x1000,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r12
mov    0x2d9e(%rip),%rax
cmp    %r12,(%rax)
jne    1230 <main+0x90>
lea    0xed7(%rip),%rsi
mov    $0x1,%edi
call   1060 <errx@plt>
lea    0xea5(%rip),%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1040 <PrintInterfaceKB@plt>
lea    0xdb3(%rip),%rbp
xor    %r13d,%r13d
jmp    1282 <main+0xe2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xf16(%rip),%rdi
mov    %r12,%rsi
call   1070 <printf@plt>
mov    $0xa,%edi
call   10c0 <Sleep@plt>
test   %r14d,%r14d
jne    13c0 <main+0x220>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <kbhit@plt>
test   %rax,%rax
je     126f <main+0xcf>
xor    %r14d,%r14d
xor    %eax,%eax
call   10a0 <getch@plt>
mov    %eax,%ebx
mov    %r12,%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x1,%r13d
add    $0xbf,%bl
cmp    $0x36,%bl
ja     139b <main+0x1fb>
mov    $0x1,%r15d
movzbl %bl,%eax
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
lea    0xe35(%rip),%rsi
jmp    *%rax
xor    %r15d,%r15d
lea    0xe44(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe83(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe43(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe01(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xdfd(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xdeb(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe34(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe0c(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xe17(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xde0(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xdf7(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xded(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xdb4(%rip),%rsi
jmp    1390 <main+0x1f0>
xor    %r15d,%r15d
lea    0xdce(%rip),%rsi
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    %r15d,%r14d
imul   $0xcccccccd,%r13d,%eax
add    $0x19999998,%eax
ror    %eax
cmp    $0x19999998,%eax
ja     1260 <main+0xc0>
xor    %eax,%eax
call   1040 <PrintInterfaceKB@plt>
jmp    1260 <main+0xc0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"mmap.in\00"
@O_RDWR = global i32 0
@.str.1 = [31 x i8] c"cannot open input file=mmap.in\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_FILE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [12 x i8] c"either mmap\00"
@.str.3 = [2 x i8] zeroinitializer
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [6 x i8] c"start\00"
@.str.6 = [5 x i8] c"STOP\00"
@.str.7 = [6 x i8] c"clear\00"
@.str.8 = [11 x i8] c"autosaveON\00"
@.str.9 = [12 x i8] c"autosaveOFF\00"
@.str.10 = [8 x i8] c"trigger\00"
@.str.11 = [9 x i8] c"probe_up\00"
@.str.12 = [11 x i8] c"probe_down\00"
@.str.13 = [10 x i8] c"histogram\00"
@.str.14 = [5 x i8] c"wave\00"
@.str.15 = [8 x i8] c"restart\00"
@.str.16 = [5 x i8] c"init\00"
@.str.17 = [10 x i8] c"displayON\00"
@.str.18 = [11 x i8] c"displayOFF\00"
@.str.19 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = load i32, i32* @O_RDWR
%12 = call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11, i32 0)
store i32 %12, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @err(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @PROT_WRITE
%19 = or i32 %17, %18
%20 = load i32, i32* @MAP_FILE
%21 = load i32, i32* @MAP_SHARED
%22 = or i32 %20, %21
%23 = load i32, i32* %6
%24 = call i64 @mmap(i32* null, i32 4096, i32 %19, i32 %22, i32 %23, i32 0)
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = load i8*, i8** @MAP_FAILED
%28 = icmp eq i8* %26, %27
br i1 %28, label %29, label %31
29: ; preds = %16
%30 = call i32 @errx(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %16
%32 = load i8*, i8** %7
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
%34 = call i32 (...) @PrintInterfaceKB()
br label %35
35: ; preds = %161, %31
%36 = load i32, i32* %9
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
br i1 %38, label %39, label %163
39: ; preds = %35
%40 = call i64 (...) @kbhit()
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %161
42: ; preds = %39
%43 = call signext i8 (...) @getch()
store i8 %43, i8* %10
%44 = load i8*, i8** %7
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
%48 = load i8, i8* %10
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 113
br i1 %50, label %51, label %54
51: ; preds = %42
store i32 1, i32* %9
%52 = load i8*, i8** %7
%53 = call i32 @strcpy(i8* %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %42
%55 = load i8, i8* %10
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 115
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i8*, i8** %7
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %58, %54
%62 = load i8, i8* %10
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 83
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = load i8*, i8** %7
%67 = call i32 @strcpy(i8* %66, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %68
68: ; preds = %65, %61
%69 = load i8, i8* %10
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 99
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load i8*, i8** %7
%74 = call i32 @strcpy(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %75
75: ; preds = %72, %68
%76 = load i8, i8* %10
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 97
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load i8*, i8** %7
%81 = call i32 @strcpy(i8* %80, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
br label %82
82: ; preds = %79, %75
%83 = load i8, i8* %10
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 65
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i8*, i8** %7
%88 = call i32 @strcpy(i8* %87, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %89
89: ; preds = %86, %82
%90 = load i8, i8* %10
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 116
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i8*, i8** %7
%95 = call i32 @strcpy(i8* %94, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
br label %96
96: ; preds = %93, %89
%97 = load i8, i8* %10
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 112
br i1 %99, label %100, label %103
100: ; preds = %96
%101 = load i8*, i8** %7
%102 = call i32 @strcpy(i8* %101, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
br label %103
103: ; preds = %100, %96
%104 = load i8, i8* %10
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 80
br i1 %106, label %107, label %110
107: ; preds = %103
%108 = load i8*, i8** %7
%109 = call i32 @strcpy(i8* %108, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %110
110: ; preds = %107, %103
%111 = load i8, i8* %10
%112 = sext i8 %111 to i32
%113 = icmp eq i32 %112, 104
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load i8*, i8** %7
%116 = call i32 @strcpy(i8* %115, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0))
br label %117
117: ; preds = %114, %110
%118 = load i8, i8* %10
%119 = sext i8 %118 to i32
%120 = icmp eq i32 %119, 119
br i1 %120, label %121, label %124
121: ; preds = %117
%122 = load i8*, i8** %7
%123 = call i32 @strcpy(i8* %122, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %124
124: ; preds = %121, %117
%125 = load i8, i8* %10
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 114
br i1 %127, label %128, label %131
128: ; preds = %124
%129 = load i8*, i8** %7
%130 = call i32 @strcpy(i8* %129, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0))
br label %131
131: ; preds = %128, %124
%132 = load i8, i8* %10
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 105
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = load i8*, i8** %7
%137 = call i32 @strcpy(i8* %136, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0))
br label %138
138: ; preds = %135, %131
%139 = load i8, i8* %10
%140 = sext i8 %139 to i32
%141 = icmp eq i32 %140, 100
br i1 %141, label %142, label %145
142: ; preds = %138
%143 = load i8*, i8** %7
%144 = call i32 @strcpy(i8* %143, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0))
br label %145
145: ; preds = %142, %138
%146 = load i8, i8* %10
%147 = sext i8 %146 to i32
%148 = icmp eq i32 %147, 68
br i1 %148, label %149, label %152
149: ; preds = %145
%150 = load i8*, i8** %7
%151 = call i32 @strcpy(i8* %150, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
br label %152
152: ; preds = %149, %145
%153 = load i32, i32* %8
%154 = srem i32 %153, 10
%155 = icmp eq i32 0, %154
br i1 %155, label %156, label %158
156: ; preds = %152
%157 = call i32 (...) @PrintInterfaceKB()
br label %158
158: ; preds = %156, %152
%159 = load i8*, i8** %7
%160 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i8* %159)
br label %161
161: ; preds = %158, %39
%162 = call i32 @Sleep(i32 10)
br label %35
163: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"mmap.in\00"
@O_RDWR = global i32 0
@.str.1 = [31 x i8] c"cannot open input file=mmap.in\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_FILE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.2 = [12 x i8] c"either mmap\00"
@.str.3 = [2 x i8] zeroinitializer
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [6 x i8] c"start\00"
@.str.6 = [5 x i8] c"STOP\00"
@.str.7 = [6 x i8] c"clear\00"
@.str.8 = [11 x i8] c"autosaveON\00"
@.str.9 = [12 x i8] c"autosaveOFF\00"
@.str.10 = [8 x i8] c"trigger\00"
@.str.11 = [9 x i8] c"probe_up\00"
@.str.12 = [11 x i8] c"probe_down\00"
@.str.13 = [10 x i8] c"histogram\00"
@.str.14 = [5 x i8] c"wave\00"
@.str.15 = [8 x i8] c"restart\00"
@.str.16 = [5 x i8] c"init\00"
@.str.17 = [10 x i8] c"displayON\00"
@.str.18 = [11 x i8] c"displayOFF\00"
@.str.19 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i32 @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @MAP_FILE
%13 = load i32, i32* @MAP_SHARED
%14 = or i32 %13, %12
%15 = tail call i64 @mmap(i32* null, i32 4096, i32 %11, i32 %14, i32 %4, i32 0)
%16 = inttoptr i64 %15 to i8*
%17 = load i8*, i8** @MAP_FAILED
%18 = icmp eq i8* %17, %16
br i1 %18, label %19, label %21
19: ; preds = %8
%20 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %8
%22 = tail call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 (...) @PrintInterfaceKB()
br label %24
24: ; preds = %21, %58
%25 = phi i32 [ 0, %21 ], [ %60, %58 ]
%26 = tail call i64 (...) @kbhit()
%27 = icmp eq i64 %26, 0
br i1 %27, label %58, label %28
28: ; preds = %24
%29 = tail call signext i8 (...) @getch()
%30 = tail call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = add nsw i32 %25, 1
switch i8 %29, label %50 [
i8 113, label %46
i8 115, label %32
i8 83, label %33
i8 99, label %34
i8 97, label %35
i8 65, label %36
i8 116, label %37
i8 112, label %38
i8 80, label %39
i8 104, label %40
i8 119, label %41
i8 114, label %42
i8 105, label %43
i8 100, label %44
i8 68, label %45
]
32: ; preds = %28
br label %46
33: ; preds = %28
br label %46
34: ; preds = %28
br label %46
35: ; preds = %28
br label %46
36: ; preds = %28
br label %46
37: ; preds = %28
br label %46
38: ; preds = %28
br label %46
39: ; preds = %28
br label %46
40: ; preds = %28
br label %46
41: ; preds = %28
br label %46
42: ; preds = %28
br label %46
43: ; preds = %28
br label %46
44: ; preds = %28
br label %46
45: ; preds = %28
br label %46
46: ; preds = %28, %45, %32, %33, %34, %35, %36, %37, %38, %39, %40, %41, %42, %43, %44
%47 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.17, i64 0, i64 0), %44 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), %43 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), %42 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), %41 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), %40 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), %39 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), %38 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), %37 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), %36 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), %35 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %34 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %33 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %32 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), %45 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %28 ]
%48 = phi i32 [ 0, %44 ], [ 0, %43 ], [ 0, %42 ], [ 0, %41 ], [ 0, %40 ], [ 0, %39 ], [ 0, %38 ], [ 0, %37 ], [ 0, %36 ], [ 0, %35 ], [ 0, %34 ], [ 0, %33 ], [ 0, %32 ], [ 0, %45 ], [ 1, %28 ]
%49 = tail call i32 @strcpy(i8* %16, i8* %47)
br label %50
50: ; preds = %46, %28
%51 = phi i32 [ 0, %28 ], [ %48, %46 ]
%52 = srem i32 %31, 10
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = tail call i32 (...) @PrintInterfaceKB()
br label %56
56: ; preds = %54, %50
%57 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0), i8* %16)
br label %58
58: ; preds = %56, %24
%59 = phi i32 [ %51, %56 ], [ 0, %24 ]
%60 = phi i32 [ %31, %56 ], [ %25, %24 ]
%61 = tail call i32 @Sleep(i32 10)
%62 = icmp eq i32 %59, 0
br i1 %62, label %24, label %63
63: ; preds = %58
ret i32 0
}