#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*/ AbortChanges();
int /*<<< orphan*/ BlockRead(int);
int /*<<< orphan*/ BlockWrite();
int /*<<< orphan*/ EditHex();
int /*<<< orphan*/ EditText();
int FALSE;
int /*<<< orphan*/ LINES;
int /*<<< orphan*/ LoadBlock();
int TRUE;
int /*<<< orphan*/ beep();
int /*<<< orphan*/ findData();
int getch();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
void BlockEdit() {
  int c;
  bool CONTINUE = TRUE;
  do {
    move(20, 0);
    printw("h) Edit Hex, t) Edit Text, /) Search, q) Quit\n");
    printw("</> : next/previous block, l) Load Block, w) Write Block");
    refresh();
    c = getch();
    switch (c) {
    case 'h':
    case 'H':
      EditHex();
      break;
    case 't':
    case 'T':
      EditText();
      break;
    case '<':
      if (AbortChanges())
        BlockRead(2);
      break;
    case '>':
      if (AbortChanges())
        BlockRead(1);
      break;
    case 'l':
    case 'L':
      if (AbortChanges())
        LoadBlock();
      break;
    case 'w':
    case 'W':
      BlockWrite();
      break;
    case 'q':
    case 'Q':
      if (AbortChanges())
        CONTINUE = FALSE;
      break;
    case '/':
      findData();
      break;
    default: {
      move(LINES - 1, 30);
      printw("Unknown Command");
      beep();
    } break;
    }
  } while (CONTINUE);
}


x86 assembly (clang, -O0):
<BlockEdit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x14,%edi
xor    %esi,%esi
mov    %esi,-0x18(%rbp)
call   10e0 <move@plt>
lea    0xf3a(%rip),%rdi
call   1040 <printw@plt>
lea    0xf5d(%rip),%rdi
call   1040 <printw@plt>
mov    -0x18(%rbp),%eax
mov    %al,-0x11(%rbp)
call   1070 <refresh@plt>
mov    -0x11(%rbp),%al
call   1080 <getch@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffd1,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x48,%eax
ja     12e5 <BlockEdit+0x125>
mov    -0x10(%rbp),%rax
lea    0xdcf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10d0 <EditHex@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10a0 <EditText@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10b0 <AbortChanges@plt>
cmp    $0x0,%eax
je     126c <BlockEdit+0xac>
mov    $0x2,%edi
call   1090 <BlockRead@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10b0 <AbortChanges@plt>
cmp    $0x0,%eax
je     128b <BlockEdit+0xcb>
mov    $0x1,%edi
call   1090 <BlockRead@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10b0 <AbortChanges@plt>
cmp    $0x0,%eax
je     12a7 <BlockEdit+0xe7>
mov    $0x0,%al
call   1060 <LoadBlock@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   1050 <BlockWrite@plt>
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10b0 <AbortChanges@plt>
cmp    $0x0,%eax
je     12d4 <BlockEdit+0x114>
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    130e <BlockEdit+0x14e>
mov    $0x0,%al
call   10c0 <findData@plt>
jmp    130e <BlockEdit+0x14e>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    $0x1e,%esi
call   10e0 <move@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printw@plt>
mov    $0x0,%al
call   1030 <beep@plt>
jmp    1313 <BlockEdit+0x153>
cmpl   $0x0,-0x8(%rbp)
jne    11d4 <BlockEdit+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BlockEdit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e0e(%rip),%rax
mov    (%rax),%ebp
lea    0xf49(%rip),%r14
lea    0xf71(%rip),%r13
lea    0xfa3(%rip),%r15
lea    0xe10(%rip),%rbx
mov    0x2dd9(%rip),%r12
jmp    1208 <BlockEdit+0x48>
xor    %eax,%eax
call   1050 <BlockWrite@plt>
test   %ebp,%ebp
je     12ec <BlockEdit+0x12c>
mov    $0x14,%edi
xor    %esi,%esi
call   10e0 <move@plt>
mov    %r14,%rdi
call   1040 <printw@plt>
mov    %r13,%rdi
call   1040 <printw@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1080 <getch@plt>
add    $0xffffffd1,%eax
cmp    $0x48,%eax
ja     1286 <BlockEdit+0xc6>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
xor    %eax,%eax
call   10d0 <EditHex@plt>
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10b0 <AbortChanges@plt>
test   %eax,%eax
je     1200 <BlockEdit+0x40>
xor    %eax,%eax
call   1060 <LoadBlock@plt>
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10b0 <AbortChanges@plt>
test   %eax,%eax
je     1200 <BlockEdit+0x40>
mov    (%r12),%ebp
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10a0 <EditText@plt>
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10c0 <findData@plt>
jmp    1200 <BlockEdit+0x40>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
add    $0xffffffff,%edi
mov    $0x1e,%esi
call   10e0 <move@plt>
mov    %r15,%rdi
call   1040 <printw@plt>
xor    %eax,%eax
call   1030 <beep@plt>
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10b0 <AbortChanges@plt>
test   %eax,%eax
je     1200 <BlockEdit+0x40>
mov    $0x2,%edi
call   1090 <BlockRead@plt>
jmp    1200 <BlockEdit+0x40>
xor    %eax,%eax
call   10b0 <AbortChanges@plt>
test   %eax,%eax
je     1200 <BlockEdit+0x40>
mov    $0x1,%edi
call   1090 <BlockRead@plt>
jmp    1200 <BlockEdit+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TRUE = global i32 0
@.str = [47 x i8] c"h) Edit Hex, t) Edit Text, /) Search, q) Quit\0A\00"
@.str.1 = [57 x i8] c"</> : next/previous block, l) Load Block, w) Write Block\00"
@FALSE = global i32 0
@LINES = global i32 0
@.str.2 = [16 x i8] c"Unknown Command\00"
define void @BlockEdit() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @TRUE
store i32 %3, i32* %2
br label %4
4: ; preds = %50, %0
%5 = call i32 @move(i32 20, i32 0)
%6 = call i32 @printw(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @printw(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (...) @refresh()
%9 = call i32 (...) @getch()
store i32 %9, i32* %1
%10 = load i32, i32* %1
switch i32 %10, label %43 [
i32 104, label %11
i32 72, label %11
i32 116, label %13
i32 84, label %13
i32 60, label %15
i32 62, label %21
i32 108, label %27
i32 76, label %27
i32 119, label %33
i32 87, label %33
i32 113, label %35
i32 81, label %35
i32 47, label %41
]
11: ; preds = %4, %4
%12 = call i32 (...) @EditHex()
br label %49
13: ; preds = %4, %4
%14 = call i32 (...) @EditText()
br label %49
15: ; preds = %4
%16 = call i32 (...) @AbortChanges()
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @BlockRead(i32 2)
br label %20
20: ; preds = %18, %15
br label %49
21: ; preds = %4
%22 = call i32 (...) @AbortChanges()
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @BlockRead(i32 1)
br label %26
26: ; preds = %24, %21
br label %49
27: ; preds = %4, %4
%28 = call i32 (...) @AbortChanges()
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (...) @LoadBlock()
br label %32
32: ; preds = %30, %27
br label %49
33: ; preds = %4, %4
%34 = call i32 (...) @BlockWrite()
br label %49
35: ; preds = %4, %4
%36 = call i32 (...) @AbortChanges()
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32, i32* @FALSE
store i32 %39, i32* %2
br label %40
40: ; preds = %38, %35
br label %49
41: ; preds = %4
%42 = call i32 (...) @findData()
br label %49
43: ; preds = %4
%44 = load i32, i32* @LINES
%45 = sub nsw i32 %44, 1
%46 = call i32 @move(i32 %45, i32 30)
%47 = call i32 @printw(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%48 = call i32 (...) @beep()
br label %49
49: ; preds = %43, %41, %40, %33, %32, %26, %20, %13, %11
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = icmp ne i32 %51, 0
br i1 %52, label %4, label %53
53: ; preds = %50
ret void
}

LLVM IR (-O2):
@TRUE = global i32 0
@.str = [47 x i8] c"h) Edit Hex, t) Edit Text, /) Search, q) Quit\0A\00"
@.str.1 = [57 x i8] c"</> : next/previous block, l) Load Block, w) Write Block\00"
@FALSE = global i32 0
@LINES = global i32 0
@.str.2 = [16 x i8] c"Unknown Command\00"
define void @BlockEdit() {
%1 = load i32, i32* @TRUE
br label %2
2: ; preds = %43, %0
%3 = phi i32 [ %1, %0 ], [ %44, %43 ]
%4 = tail call i32 @move(i32 20, i32 0)
%5 = tail call i32 @printw(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printw(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 (...) @refresh()
%8 = tail call i32 (...) @getch()
switch i32 %8, label %37 [
i32 104, label %9
i32 72, label %9
i32 116, label %11
i32 84, label %11
i32 60, label %13
i32 62, label %18
i32 108, label %23
i32 76, label %23
i32 119, label %28
i32 87, label %28
i32 113, label %30
i32 81, label %30
i32 47, label %35
]
9: ; preds = %2, %2
%10 = tail call i32 (...) @EditHex()
br label %43
11: ; preds = %2, %2
%12 = tail call i32 (...) @EditText()
br label %43
13: ; preds = %2
%14 = tail call i32 (...) @AbortChanges()
%15 = icmp eq i32 %14, 0
br i1 %15, label %43, label %16
16: ; preds = %13
%17 = tail call i32 @BlockRead(i32 2)
br label %43
18: ; preds = %2
%19 = tail call i32 (...) @AbortChanges()
%20 = icmp eq i32 %19, 0
br i1 %20, label %43, label %21
21: ; preds = %18
%22 = tail call i32 @BlockRead(i32 1)
br label %43
23: ; preds = %2, %2
%24 = tail call i32 (...) @AbortChanges()
%25 = icmp eq i32 %24, 0
br i1 %25, label %43, label %26
26: ; preds = %23
%27 = tail call i32 (...) @LoadBlock()
br label %43
28: ; preds = %2, %2
%29 = tail call i32 (...) @BlockWrite()
br label %43
30: ; preds = %2, %2
%31 = tail call i32 (...) @AbortChanges()
%32 = icmp eq i32 %31, 0
%33 = load i32, i32* @FALSE
%34 = select i1 %32, i32 %3, i32 %33
br label %43
35: ; preds = %2
%36 = tail call i32 (...) @findData()
br label %43
37: ; preds = %2
%38 = load i32, i32* @LINES
%39 = add nsw i32 %38, -1
%40 = tail call i32 @move(i32 %39, i32 30)
%41 = tail call i32 @printw(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%42 = tail call i32 (...) @beep()
br label %43
43: ; preds = %30, %9, %11, %28, %35, %37, %16, %13, %21, %18, %26, %23
%44 = phi i32 [ %3, %37 ], [ %3, %35 ], [ %3, %28 ], [ %3, %26 ], [ %3, %23 ], [ %3, %21 ], [ %3, %18 ], [ %3, %16 ], [ %3, %13 ], [ %3, %11 ], [ %3, %9 ], [ %34, %30 ]
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %2
46: ; preds = %43
ret void
}