#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 */
char *get_end_of_esc(char const *);
char *get_end_of_text(char const *);
scalar_t__ is_esc(char const *);
int /*<<< orphan*/ print_text(char const *, int);
void print_clean(const char *line) {
  const char *p = line;
  if (is_esc(p))
    p = get_end_of_esc(p);
  while (*p != '\0') {
    const char *text_start = p;
    const char *text_end = get_end_of_text(p);
    print_text(text_start, text_end - text_start);
    p = get_end_of_esc(text_end);
  }
}


x86 assembly (clang, -O0):
<print_clean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <is_esc@plt>
cmp    $0x0,%rax
je     1174 <print_clean+0x34>
mov    -0x10(%rbp),%rdi
call   1050 <get_end_of_esc@plt>
mov    %rax,-0x10(%rbp)
jmp    1179 <print_clean+0x39>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11c6 <print_clean+0x86>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <get_end_of_text@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <print_text@plt>
mov    -0x20(%rbp),%rdi
call   1050 <get_end_of_esc@plt>
mov    %rax,-0x10(%rbp)
jmp    1179 <print_clean+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_clean>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <is_esc@plt>
test   %rax,%rax
je     115c <print_clean+0x1c>
mov    %rbx,%rdi
call   1050 <get_end_of_esc@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rbx)
je     1198 <print_clean+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <get_end_of_text@plt>
mov    %rax,%r14
mov    %r14d,%esi
sub    %ebx,%esi
mov    %rbx,%rdi
call   1030 <print_text@plt>
mov    %r14,%rdi
call   1050 <get_end_of_esc@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    1170 <print_clean+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @print_clean(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @is_esc(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @get_end_of_esc(i8* %11)
store i8* %12, i8** %3
br label %13
13: ; preds = %10, %1
br label %14
14: ; preds = %19, %13
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %33
19: ; preds = %14
%20 = load i8*, i8** %3
store i8* %20, i8** %4
%21 = load i8*, i8** %3
%22 = call i8* @get_end_of_text(i8* %21)
store i8* %22, i8** %5
%23 = load i8*, i8** %4
%24 = load i8*, i8** %5
%25 = load i8*, i8** %4
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = call i32 @print_text(i8* %23, i32 %29)
%31 = load i8*, i8** %5
%32 = call i8* @get_end_of_esc(i8* %31)
store i8* %32, i8** %3
br label %14
33: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @print_clean(i8* %0) {
%2 = tail call i64 @is_esc(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i8* @get_end_of_esc(i8* %0)
br label %6
6: ; preds = %4, %1
%7 = phi i8* [ %5, %4 ], [ %0, %1 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %6, %10
%11 = phi i8* [ %18, %10 ], [ %7, %6 ]
%12 = tail call i8* @get_end_of_text(i8* %11)
%13 = ptrtoint i8* %12 to i64
%14 = ptrtoint i8* %11 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @print_text(i8* %11, i32 %16)
%18 = tail call i8* @get_end_of_esc(i8* %12)
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %10, %6
ret void
}