#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 */
struct feed_tty {
  int dummy;
};
struct feed_buf {
  int dummy;
};

/* Variables and functions */
char feed_tty_read_unicode_character(struct feed_tty *const,
                                     struct feed_buf *const, unsigned long *);
char feed_tty_read_escape_sequence(struct feed_tty *const p_tty,
                                   struct feed_buf *const p_buf) {
  char b_result;
  unsigned long int i_value;
  b_result = feed_tty_read_unicode_character(p_tty, p_buf, &(i_value));
  if (b_result) {
    if ('\033' == i_value) {
      b_result = feed_tty_read_unicode_character(p_tty, p_buf, &(i_value));
      if (b_result) {
        if ('[' == i_value) {
          char b_more;
          b_more = 1;
          while (b_result && b_more) {
            b_result =
                feed_tty_read_unicode_character(p_tty, p_buf, &(i_value));
            if (b_result) {
              if ((i_value >= 0x30) && (i_value <= 0x3F)) {
                b_more = 1;
              } else if ((i_value >= 0x40) && (i_value <= 0x7F)) {
                b_more = 0;
              } else {
                b_result = 0;
              }
            }
          }
        } else if (('O' == i_value) || ('N' == i_value) || ('(' == i_value) ||
                   (')' == i_value) || ('#' == i_value)) {
          b_result = feed_tty_read_unicode_character(p_tty, p_buf, &(i_value));
        }
      }
    } else {
    }
  }
  return b_result;
}


x86 assembly (clang, -O0):
<feed_tty_read_escape_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <feed_tty_read_unicode_character@plt>
mov    %al,-0x11(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     1299 <feed_tty_read_escape_sequence+0x189>
mov    $0x1b,%eax
cmp    -0x20(%rbp),%rax
jne    128f <feed_tty_read_escape_sequence+0x17f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <feed_tty_read_unicode_character@plt>
mov    %al,-0x11(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     128a <feed_tty_read_escape_sequence+0x17a>
mov    $0x5b,%eax
cmp    -0x20(%rbp),%rax
jne    1221 <feed_tty_read_escape_sequence+0x111>
movb   $0x1,-0x21(%rbp)
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x22(%rbp)
je     119d <feed_tty_read_escape_sequence+0x8d>
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    11ad <feed_tty_read_escape_sequence+0x9d>
jmp    121c <feed_tty_read_escape_sequence+0x10c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <feed_tty_read_unicode_character@plt>
mov    %al,-0x11(%rbp)
cmpb   $0x0,-0x11(%rbp)
je     1217 <feed_tty_read_escape_sequence+0x107>
cmpq   $0x30,-0x20(%rbp)
jb     11ea <feed_tty_read_escape_sequence+0xda>
cmpq   $0x3f,-0x20(%rbp)
ja     11ea <feed_tty_read_escape_sequence+0xda>
movb   $0x1,-0x21(%rbp)
jmp    1212 <feed_tty_read_escape_sequence+0x102>
cmpq   $0x40,-0x20(%rbp)
jb     1209 <feed_tty_read_escape_sequence+0xf9>
cmpq   $0x7f,-0x20(%rbp)
ja     1209 <feed_tty_read_escape_sequence+0xf9>
movb   $0x0,-0x21(%rbp)
jmp    120d <feed_tty_read_escape_sequence+0xfd>
movb   $0x0,-0x11(%rbp)
jmp    1212 <feed_tty_read_escape_sequence+0x102>
jmp    1217 <feed_tty_read_escape_sequence+0x107>
jmp    117e <feed_tty_read_escape_sequence+0x6e>
jmp    1285 <feed_tty_read_escape_sequence+0x175>
mov    $0x4f,%eax
cmp    -0x20(%rbp),%rax
je     126c <feed_tty_read_escape_sequence+0x15c>
mov    $0x4e,%eax
cmp    -0x20(%rbp),%rax
je     126c <feed_tty_read_escape_sequence+0x15c>
mov    $0x28,%eax
cmp    -0x20(%rbp),%rax
je     126c <feed_tty_read_escape_sequence+0x15c>
mov    $0x29,%eax
cmp    -0x20(%rbp),%rax
je     126c <feed_tty_read_escape_sequence+0x15c>
mov    $0x23,%eax
cmp    -0x20(%rbp),%rax
jne    1280 <feed_tty_read_escape_sequence+0x170>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <feed_tty_read_unicode_character@plt>
mov    %al,-0x11(%rbp)
jmp    1285 <feed_tty_read_escape_sequence+0x175>
jmp    128a <feed_tty_read_escape_sequence+0x17a>
jmp    1294 <feed_tty_read_escape_sequence+0x184>
jmp    1294 <feed_tty_read_escape_sequence+0x184>
jmp    1299 <feed_tty_read_escape_sequence+0x189>
movsbl -0x11(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_tty_read_escape_sequence>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
mov    %rsp,%rdx
call   1030 <feed_tty_read_unicode_character@plt>
test   %al,%al
je     11f9 <feed_tty_read_escape_sequence+0xe9>
cmpq   $0x1b,(%rsp)
jne    11f9 <feed_tty_read_escape_sequence+0xe9>
mov    %rsp,%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <feed_tty_read_unicode_character@plt>
test   %al,%al
je     11f7 <feed_tty_read_escape_sequence+0xe7>
mov    (%rsp),%rcx
add    $0xffffffffffffffdd,%rcx
cmp    $0x38,%rcx
ja     11f9 <feed_tty_read_escape_sequence+0xe9>
movabs $0x180000000061,%rdx
bt     %rcx,%rdx
jae    1184 <feed_tty_read_escape_sequence+0x74>
mov    %rsp,%rdx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <feed_tty_read_unicode_character@plt>
jmp    11f9 <feed_tty_read_escape_sequence+0xe9>
cmp    $0x38,%rcx
jne    11f9 <feed_tty_read_escape_sequence+0xe9>
mov    $0x1,%bpl
mov    %rsp,%r15
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <feed_tty_read_unicode_character@plt>
test   %al,%al
je     11f7 <feed_tty_read_escape_sequence+0xe7>
mov    (%rsp),%rcx
mov    %rcx,%rdx
and    $0xfffffffffffffff0,%rdx
and    $0xffffffffffffffc0,%rcx
cmp    $0x40,%rcx
sete   %bl
movzbl %bpl,%ebp
mov    $0x0,%ecx
cmove  %ecx,%ebp
cmp    $0x30,%rdx
sete   %cl
cmove  %r13d,%ebp
or     %bl,%cl
cmp    $0x1,%cl
jne    11eb <feed_tty_read_escape_sequence+0xdb>
test   %bpl,%bpl
jne    11a0 <feed_tty_read_escape_sequence+0x90>
movzbl %al,%edx
xor    %eax,%eax
test   %cl,%cl
cmovne %edx,%eax
jmp    11f9 <feed_tty_read_escape_sequence+0xe9>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.feed_tty = type { i32 }
%struct.feed_buf = type { i32 }
define signext i8 @feed_tty_read_escape_sequence(%struct.feed_tty* %0, %struct.feed_buf* %1) {
%3 = alloca %struct.feed_tty*
%4 = alloca %struct.feed_buf*
%5 = alloca i8
%6 = alloca i64
%7 = alloca i8
store %struct.feed_tty* %0, %struct.feed_tty** %3
store %struct.feed_buf* %1, %struct.feed_buf** %4
%8 = load %struct.feed_tty*, %struct.feed_tty** %3
%9 = load %struct.feed_buf*, %struct.feed_buf** %4
%10 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %8, %struct.feed_buf* %9, i64* %6)
store i8 %10, i8* %5
%11 = load i8, i8* %5
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %85
13: ; preds = %2
%14 = load i64, i64* %6
%15 = icmp eq i64 27, %14
br i1 %15, label %16, label %83
16: ; preds = %13
%17 = load %struct.feed_tty*, %struct.feed_tty** %3
%18 = load %struct.feed_buf*, %struct.feed_buf** %4
%19 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %17, %struct.feed_buf* %18, i64* %6)
store i8 %19, i8* %5
%20 = load i8, i8* %5
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %82
22: ; preds = %16
%23 = load i64, i64* %6
%24 = icmp eq i64 91, %23
br i1 %24, label %25, label %61
25: ; preds = %22
store i8 1, i8* %7
br label %26
26: ; preds = %59, %25
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i8, i8* %7
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %30, %26
%35 = phi i1 [ false, %26 ], [ %33, %30 ]
br i1 %35, label %36, label %60
36: ; preds = %34
%37 = load %struct.feed_tty*, %struct.feed_tty** %3
%38 = load %struct.feed_buf*, %struct.feed_buf** %4
%39 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %37, %struct.feed_buf* %38, i64* %6)
store i8 %39, i8* %5
%40 = load i8, i8* %5
%41 = icmp ne i8 %40, 0
br i1 %41, label %42, label %59
42: ; preds = %36
%43 = load i64, i64* %6
%44 = icmp uge i64 %43, 48
br i1 %44, label %45, label %49
45: ; preds = %42
%46 = load i64, i64* %6
%47 = icmp ule i64 %46, 63
br i1 %47, label %48, label %49
48: ; preds = %45
store i8 1, i8* %7
br label %58
49: ; preds = %45, %42
%50 = load i64, i64* %6
%51 = icmp uge i64 %50, 64
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = load i64, i64* %6
%54 = icmp ule i64 %53, 127
br i1 %54, label %55, label %56
55: ; preds = %52
store i8 0, i8* %7
br label %57
56: ; preds = %52, %49
store i8 0, i8* %5
br label %57
57: ; preds = %56, %55
br label %58
58: ; preds = %57, %48
br label %59
59: ; preds = %58, %36
br label %26
60: ; preds = %34
br label %81
61: ; preds = %22
%62 = load i64, i64* %6
%63 = icmp eq i64 79, %62
br i1 %63, label %76, label %64
64: ; preds = %61
%65 = load i64, i64* %6
%66 = icmp eq i64 78, %65
br i1 %66, label %76, label %67
67: ; preds = %64
%68 = load i64, i64* %6
%69 = icmp eq i64 40, %68
br i1 %69, label %76, label %70
70: ; preds = %67
%71 = load i64, i64* %6
%72 = icmp eq i64 41, %71
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i64, i64* %6
%75 = icmp eq i64 35, %74
br i1 %75, label %76, label %80
76: ; preds = %73, %70, %67, %64, %61
%77 = load %struct.feed_tty*, %struct.feed_tty** %3
%78 = load %struct.feed_buf*, %struct.feed_buf** %4
%79 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %77, %struct.feed_buf* %78, i64* %6)
store i8 %79, i8* %5
br label %80
80: ; preds = %76, %73
br label %81
81: ; preds = %80, %60
br label %82
82: ; preds = %81, %16
br label %84
83: ; preds = %13
br label %84
84: ; preds = %83, %82
br label %85
85: ; preds = %84, %2
%86 = load i8, i8* %5
ret i8 %86
}

LLVM IR (-O2):
%struct.feed_tty = type { i32 }
%struct.feed_buf = type { i32 }
define signext i8 @feed_tty_read_escape_sequence(%struct.feed_tty* %0, %struct.feed_buf* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %0, %struct.feed_buf* %1, i64* %3)
%6 = icmp ne i8 %5, 0
%7 = load i64, i64* %3
%8 = icmp eq i64 %7, 27
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %34
10: ; preds = %2
%11 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %0, %struct.feed_buf* %1, i64* %3)
%12 = icmp eq i8 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %10
%14 = load i64, i64* %3
switch i64 %14, label %34 [
i64 91, label %15
i64 79, label %30
i64 78, label %30
i64 41, label %30
i64 40, label %30
i64 35, label %30
]
15: ; preds = %13, %19
%16 = phi i8 [ %27, %19 ], [ 1, %13 ]
%17 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %0, %struct.feed_buf* %1, i64* %3)
%18 = icmp eq i8 %17, 0
br i1 %18, label %34, label %19
19: ; preds = %15
%20 = load i64, i64* %3
%21 = and i64 %20, -16
%22 = icmp eq i64 %21, 48
%23 = and i64 %20, -64
%24 = icmp eq i64 %23, 64
%25 = select i1 %24, i8 0, i8 %16
%26 = or i1 %22, %24
%27 = select i1 %22, i8 1, i8 %25
%28 = icmp ne i8 %27, 0
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %15, label %32
30: ; preds = %13, %13, %13, %13, %13
%31 = call signext i8 @feed_tty_read_unicode_character(%struct.feed_tty* %0, %struct.feed_buf* %1, i64* %3)
br label %34
32: ; preds = %19
%33 = select i1 %26, i8 %17, i8 0
br label %34
34: ; preds = %32, %15, %13, %30, %10, %2
%35 = phi i8 [ %31, %30 ], [ 0, %10 ], [ %5, %2 ], [ %11, %13 ], [ %33, %32 ], [ 0, %15 ]
ret i8 %35
}