#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*/ escape(char const *);
int /*<<< orphan*/ printc(char const);
void prints(const char *string) {
  for (int i = 0;; i++) {
    if (string[i] == '\0') {
      break;
    } else if (string[i] == 0x1B) {
      escape(string + i + 1);
      while (string[++i] != 'm')
        ;
    } else
      printc(string[i]);
  }
}


x86 assembly (clang, -O0):
<prints>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    114d <prints+0x2d>
jmp    11c6 <prints+0xa6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1b,%eax
jne    119d <prints+0x7d>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1040 <escape@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
je     1198 <prints+0x78>
jmp    1176 <prints+0x56>
jmp    11ae <prints+0x8e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <printc@plt>
jmp    11b3 <prints+0x93>
jmp    11b8 <prints+0x98>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <prints+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prints>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0x1(%rdi),%r14
xor    %ebp,%ebp
jmp    1143 <prints+0x23>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
movslq %ebp,%rbx
mov    (%r15,%rbx,1),%al
cmp    $0x1b,%al
je     1160 <prints+0x40>
test   %al,%al
je     117e <prints+0x5e>
movsbl %al,%edi
call   1030 <printc@plt>
jmp    1140 <prints+0x20>
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%rdi
add    $0x1,%rdi
call   1040 <escape@plt>
add    %r14,%rbx
add    $0x1,%ebp
cmpb   $0x6d,(%rbx)
lea    0x1(%rbx),%rbx
jne    1170 <prints+0x50>
jmp    1140 <prints+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @prints(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %48, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %4
br label %51
13: ; preds = %4
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 27
br i1 %20, label %21, label %39
21: ; preds = %13
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @escape(i8* %26)
br label %28
28: ; preds = %37, %21
%29 = load i8*, i8** %2
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 109
br i1 %36, label %37, label %38
37: ; preds = %28
br label %28
38: ; preds = %28
br label %46
39: ; preds = %13
%40 = load i8*, i8** %2
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @printc(i8 signext %44)
br label %46
46: ; preds = %39, %38
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %4
51: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @prints(i8* %0) {
br label %2
2: ; preds = %21, %1
%3 = phi i32 [ 0, %1 ], [ %23, %21 ]
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
switch i8 %6, label %17 [
i8 0, label %7
i8 27, label %8
]
7: ; preds = %2
ret void
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %5, i64 1
%10 = tail call i32 @escape(i8* %9)
br label %11
11: ; preds = %11, %8
%12 = phi i64 [ %13, %11 ], [ %4, %8 ]
%13 = add i64 %12, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 109
br i1 %16, label %19, label %11
17: ; preds = %2
%18 = tail call i32 @printc(i8 signext %6)
br label %21
19: ; preds = %11
%20 = trunc i64 %13 to i32
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %3, %17 ], [ %20, %19 ]
%23 = add nsw i32 %22, 1
br label %2
}