#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*/ console_CR();
char *console_ESC(char *);
int /*<<< orphan*/ console_LF();
char *console_processCodes(char *str) {
  char val = *str;
  while ((val == '\r') || (val == '\n') || (val == '\x1b')) {
    switch (val) {
    case '\r':
      str++;
      break;
    case '\n':
      str++;
      console_CR();
      console_LF();
      break;
    case '\x1b':
      str = console_ESC(str);
      break;
    case '\0':
      break;
    default:
      break;
    }
    val = *str;
  }
  return (str);
}


x86 assembly (clang, -O0):
<console_processCodes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0xa(%rbp)
je     1176 <console_processCodes+0x46>
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0xa(%rbp)
je     1176 <console_processCodes+0x46>
movsbl -0x9(%rbp),%eax
cmp    $0x1b,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1186 <console_processCodes+0x56>
jmp    1207 <console_processCodes+0xd7>
movsbl -0x9(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x1b,%eax
ja     11f4 <console_processCodes+0xc4>
mov    -0x18(%rbp),%rax
lea    0xe5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <console_processCodes+0xc9>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <console_CR@plt>
mov    $0x0,%al
call   1050 <console_LF@plt>
jmp    11f9 <console_processCodes+0xc9>
mov    -0x8(%rbp),%rdi
call   1030 <console_ESC@plt>
mov    %rax,-0x8(%rbp)
jmp    11f9 <console_processCodes+0xc9>
jmp    11f9 <console_processCodes+0xc9>
jmp    11f9 <console_processCodes+0xc9>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
jmp    1145 <console_processCodes+0x15>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<console_processCodes>:
push   %rbx
mov    %rdi,%rbx
jmp    114b <console_processCodes+0x1b>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <console_ESC@plt>
mov    %rax,%rbx
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1160 <console_processCodes+0x30>
cmp    $0x1b,%al
je     1140 <console_processCodes+0x10>
cmp    $0xd,%al
jne    1174 <console_processCodes+0x44>
add    $0x1,%rbx
jmp    114b <console_processCodes+0x1b>
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <console_CR@plt>
xor    %eax,%eax
call   1050 <console_LF@plt>
jmp    114b <console_processCodes+0x1b>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
define i8* @console_processCodes(i8* %0) {
br label %2
2: ; preds = %13, %1
%3 = phi i8* [ %0, %1 ], [ %14, %13 ]
%4 = load i8, i8* %3
switch i8 %4, label %15 [
i8 13, label %5
i8 10, label %7
i8 27, label %11
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %13
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 1
%9 = tail call i32 (...) @console_CR()
%10 = tail call i32 (...) @console_LF()
br label %13
11: ; preds = %2
%12 = tail call i8* @console_ESC(i8* %3)
br label %13
13: ; preds = %11, %7, %5
%14 = phi i8* [ %12, %11 ], [ %8, %7 ], [ %6, %5 ]
br label %2
15: ; preds = %2
ret i8* %3
}