#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 */
scalar_t__ isdigit(char);
char *consume_escape_seq(char *c) {
  if (*c != '\033' || c[1] != '[')
    return c;
  ++c;
  do {
    ++c;
    while (isdigit(*c))
      ++c;
  } while (*c == ';');
  ++c;
  return c;
}


x86 assembly (clang, -O0):
<consume_escape_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x1b,%eax
jne    113d <consume_escape_seq+0x2d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x5b,%eax
je     114a <consume_escape_seq+0x3a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <consume_escape_seq+0xa2>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1189 <consume_escape_seq+0x79>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1162 <consume_escape_seq+0x52>
jmp    118e <consume_escape_seq+0x7e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     1156 <consume_escape_seq+0x46>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume_escape_seq>:
push   %rbx
mov    %rdi,%rbx
cmpb   $0x1b,(%rdi)
jne    1148 <consume_escape_seq+0x38>
cmpb   $0x5b,0x1(%rbx)
jne    1148 <consume_escape_seq+0x38>
add    $0x3,%rbx
jmp    1134 <consume_escape_seq+0x24>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
movsbl -0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1130 <consume_escape_seq+0x20>
cmpb   $0x3b,-0x1(%rbx)
je     1130 <consume_escape_seq+0x20>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @consume_escape_seq(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 27
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 91
br i1 %13, label %14, label %16
14: ; preds = %8, %1
%15 = load i8*, i8** %3
store i8* %15, i8** %2
br label %40
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
br label %19
19: ; preds = %31, %16
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %22
22: ; preds = %27, %19
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = call i64 @isdigit(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
br label %22
30: ; preds = %22
br label %31
31: ; preds = %30
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 59
br i1 %35, label %19, label %36
36: ; preds = %31
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %3
%39 = load i8*, i8** %3
store i8* %39, i8** %2
br label %40
40: ; preds = %36, %14
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
define i8* @consume_escape_seq(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 27
br i1 %3, label %4, label %20
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 91
br i1 %7, label %8, label %20
8: ; preds = %4, %14
%9 = phi i8* [ %10, %14 ], [ %5, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = tail call i64 @isdigit(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %8, %15
br label %8
15: ; preds = %8
%16 = load i8, i8* %10
%17 = icmp eq i8 %16, 59
br i1 %17, label %14, label %18
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %9, i64 2
br label %20
20: ; preds = %1, %4, %18
%21 = phi i8* [ %19, %18 ], [ %0, %4 ], [ %0, %1 ]
ret i8* %21
}