#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int readln(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char escape(void) {
  char c, buf[64];
  int n;
loop:
  fprintf(stderr, ">>> ");
  fflush(stdout);
  n = readln(0, buf, sizeof buf - 1);
  if (n <= 0)
    return '.';
  c = buf[0];
  switch (c) {
  case 'i':
  case 'q':
  case '.':
    return c;
  }
  fprintf(stderr, "	(q)uit, (i)nterrupt, (.)continue\r\n");
  goto loop;
}


x86 assembly (clang, -O0):
<escape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    -0x50(%rbp),%rsi
xor    %edi,%edi
mov    $0x3f,%edx
call   1050 <readln@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jg     1181 <escape+0x51>
movb   $0x2e,-0x1(%rbp)
jmp    11e3 <escape+0xb3>
mov    -0x50(%rbp),%al
mov    %al,-0x2(%rbp)
movsbl -0x2(%rbp),%eax
mov    %eax,-0x58(%rbp)
sub    $0x2e,%eax
je     11be <escape+0x8e>
jmp    119c <escape+0x6c>
mov    -0x58(%rbp),%eax
sub    $0x69,%eax
je     11be <escape+0x8e>
jmp    11ad <escape+0x7d>
mov    -0x58(%rbp),%eax
sub    $0x71,%eax
jne    11c9 <escape+0x99>
jmp    11be <escape+0x8e>
mov    -0x2(%rbp),%al
mov    %al,-0x1(%rbp)
jmp    11e3 <escape+0xb3>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1138 <escape+0x8>
movsbl -0x1(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escape>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    0x2e9c(%rip),%rbx
mov    (%rbx),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e7f(%rip),%r13
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
mov    %rsp,%rsi
xor    %edi,%edi
mov    $0x3f,%edx
call   1050 <readln@plt>
test   %eax,%eax
jle    11d6 <escape+0xa6>
lea    0xe89(%rip),%r14
lea    0xe7d(%rip),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp),%eax
movsbl %al,%ecx
cmp    $0x2e,%ecx
je     11d8 <escape+0xa8>
cmp    $0x69,%ecx
je     11d8 <escape+0xa8>
cmp    $0x71,%ecx
je     11d8 <escape+0xa8>
mov    (%rbx),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
call   1030 <fprintf@plt>
mov    0x0(%r13),%edi
call   1040 <fflush@plt>
xor    %edi,%edi
mov    %r12,%rsi
mov    $0x3f,%edx
call   1050 <readln@plt>
test   %eax,%eax
jg     1190 <escape+0x60>
mov    $0x2e,%al
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c">>> \00"
@stdout = global i32 0
@.str.1 = [36 x i8] c"\09(q)uit, (i)nterrupt, (.)continue\0D\0A\00"
define signext i8 @escape() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca [64 x i8]
%4 = alloca i32
br label %5
5: ; preds = %22, %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdout
%9 = call i32 @fflush(i32 %8)
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%11 = call i32 @readln(i32 0, i8* %10, i32 63)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %5
store i8 46, i8* %1
br label %25
15: ; preds = %5
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%17 = load i8, i8* %16
store i8 %17, i8* %2
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
switch i32 %19, label %22 [
i32 105, label %20
i32 113, label %20
i32 46, label %20
]
20: ; preds = %15, %15, %15
%21 = load i8, i8* %2
store i8 %21, i8* %1
br label %25
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %5
25: ; preds = %20, %14
%26 = load i8, i8* %1
ret i8 %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c">>> \00"
@stdout = global i32 0
@.str.1 = [36 x i8] c"\09(q)uit, (i)nterrupt, (.)continue\0D\0A\00"
define signext i8 @escape() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stderr
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
%7 = call i32 @readln(i32 0, i8* %2, i32 63)
%8 = icmp slt i32 %7, 1
br i1 %8, label %21, label %9
9: ; preds = %0, %12
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
switch i32 %11, label %12 [
i32 105, label %21
i32 113, label %21
i32 46, label %21
]
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = call i32 @fflush(i32 %17)
%19 = call i32 @readln(i32 0, i8* %2, i32 63)
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %9
21: ; preds = %12, %9, %9, %9, %0
%22 = phi i8 [ 46, %0 ], [ %10, %9 ], [ %10, %9 ], [ %10, %9 ], [ 46, %12 ]
ret i8 %22
}