#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*/ STDOUT_FILENO;
char editorReadKey();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printKeyPress(char);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void editorProcessKeypress() {
  char c = editorReadKey();
  printKeyPress(c);
  switch (c) {
  case (('q') & 0x1f):
    write(STDOUT_FILENO, "\x1b[2J", 4);
    write(STDOUT_FILENO, "\x1b[H", 3);
    exit(0);
    break;
  }
}


x86 assembly (clang, -O0):
<editorProcessKeypress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <editorReadKey@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%edi
call   1040 <printKeyPress@plt>
mov    -0x1(%rbp),%al
sub    $0x11,%al
jne    11a6 <editorProcessKeypress+0x66>
jmp    116b <editorProcessKeypress+0x2b>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<editorProcessKeypress>:
push   %rbx
xor    %eax,%eax
call   1050 <editorReadKey@plt>
movsbl %al,%ebx
mov    %ebx,%edi
call   1040 <printKeyPress@plt>
cmp    $0x11,%bl
je     1159 <editorProcessKeypress+0x19>
pop    %rbx
ret
mov    0x2e90(%rip),%rbx
mov    (%rbx),%edi
lea    0xe97(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    (%rbx),%edi
lea    0xe89(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [5 x i8] c"\1B[2J\00"
@.str.1 = [4 x i8] c"\1B[H\00"
define void @editorProcessKeypress() {
%1 = alloca i8
%2 = call signext i8 (...) @editorReadKey()
store i8 %2, i8* %1
%3 = load i8, i8* %1
%4 = call i32 @printKeyPress(i8 signext %3)
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
switch i32 %6, label %13 [
i32 17, label %7
]
7: ; preds = %0
%8 = load i32, i32* @STDOUT_FILENO
%9 = call i32 @write(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%10 = load i32, i32* @STDOUT_FILENO
%11 = call i32 @write(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [5 x i8] c"\1B[2J\00"
@.str.1 = [4 x i8] c"\1B[H\00"
define void @editorProcessKeypress() {
%1 = tail call signext i8 (...) @editorReadKey()
%2 = tail call i32 @printKeyPress(i8 signext %1)
%3 = icmp eq i8 %1, 17
br i1 %3, label %4, label %10
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%7 = load i32, i32* @STDOUT_FILENO
%8 = tail call i32 @write(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%9 = tail call i32 @exit(i32 0)
unreachable
10: ; preds = %0
ret void
}