#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 */
unsigned char getchar();
void await_c1(unsigned char c1) {
  unsigned char c;
  bool in_esc = false;
  while ((c = getchar())) {
    if (c == c1)
      break;
    if (in_esc && c == (char)(c1 - 0x40))
      break;
    if (!in_esc && c == 0x1b)
      in_esc = true;
    else
      in_esc = false;
  }
}


x86 assembly (clang, -O0):
<await_c1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x2(%rbp)
cmp    $0x0,%al
je     11a0 <await_c1+0x90>
movzbl -0x2(%rbp),%eax
movzbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    114c <await_c1+0x3c>
jmp    11a0 <await_c1+0x90>
cmpl   $0x0,-0x8(%rbp)
je     1171 <await_c1+0x61>
movzbl -0x2(%rbp),%eax
movzbl -0x1(%rbp),%ecx
sub    $0x40,%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
jne    1171 <await_c1+0x61>
jmp    11a0 <await_c1+0x90>
cmpl   $0x0,-0x8(%rbp)
jne    1194 <await_c1+0x84>
movzbl -0x2(%rbp),%eax
cmp    $0x1b,%eax
jne    1194 <await_c1+0x84>
movl   $0x1,-0x8(%rbp)
jmp    119b <await_c1+0x8b>
movl   $0x0,-0x8(%rbp)
jmp    1125 <await_c1+0x15>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<await_c1>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
test   %al,%al
je     115a <await_c1+0x4a>
lea    -0x40(%rbx),%ecx
movsbl %cl,%r14d
xor    %ebp,%ebp
jmp    114a <await_c1+0x3a>
nopl   0x0(%rax)
test   %ebp,%ebp
sete   %cl
cmp    $0x1b,%al
sete   %al
and    %cl,%al
movzbl %al,%ebp
xor    %eax,%eax
call   1030 <getchar@plt>
test   %al,%al
je     115a <await_c1+0x4a>
cmp    %bl,%al
je     115a <await_c1+0x4a>
test   %ebp,%ebp
je     1130 <await_c1+0x20>
movzbl %al,%ecx
cmp    %r14d,%ecx
jne    1130 <await_c1+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @await_c1(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %4
br label %5
5: ; preds = %37, %1
%6 = call zeroext i8 (...) @getchar()
store i8 %6, i8* %3
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = load i8, i8* %2
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %10, %12
br i1 %13, label %14, label %15
14: ; preds = %8
br label %38
15: ; preds = %8
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = load i8, i8* %2
%22 = zext i8 %21 to i32
%23 = sub nsw i32 %22, 64
%24 = trunc i32 %23 to i8
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %20, %25
br i1 %26, label %27, label %28
27: ; preds = %18
br label %38
28: ; preds = %18, %15
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %28
%32 = load i8, i8* %3
%33 = zext i8 %32 to i32
%34 = icmp eq i32 %33, 27
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 1, i32* %4
br label %37
36: ; preds = %31, %28
store i32 0, i32* %4
br label %37
37: ; preds = %36, %35
br label %5
38: ; preds = %27, %14, %5
ret void
}

LLVM IR (-O2):
define void @await_c1(i8 zeroext %0) {
%2 = add i8 %0, -64
%3 = sext i8 %2 to i32
%4 = tail call zeroext i8 (...) @getchar()
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %1, %15
%7 = phi i8 [ %19, %15 ], [ %4, %1 ]
%8 = phi i32 [ %18, %15 ], [ 0, %1 ]
%9 = icmp eq i8 %7, %0
br i1 %9, label %21, label %10
10: ; preds = %6
%11 = zext i8 %7 to i32
%12 = icmp eq i32 %8, 0
%13 = icmp ne i32 %11, %3
%14 = or i1 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = icmp eq i8 %7, 27
%17 = and i1 %12, %16
%18 = zext i1 %17 to i32
%19 = tail call zeroext i8 (...) @getchar()
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %15, %6, %10, %1
ret void
}