#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*/ printf(char *, char);
char rEscape(char, int /*<<< orphan*/);
void Rprintf(char *s) {
  char ch;
  if (!s)
    return;
  for (int i = 0; s[i] != 0; i++) {
    if (ch = rEscape(s[i], 0)) {
      printf("\033[0;32;31m"
             "%c"
             "\033[m",
             ch);
    } else {
      printf("%c", s[i]);
    }
  }
}


x86 assembly (clang, -O0):
<Rprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <Rprintf+0x1c>
jmp    11b6 <Rprintf+0x96>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b6 <Rprintf+0x96>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
xor    %esi,%esi
movsbl (%rax,%rcx,1),%edi
call   1030 <rEscape@plt>
mov    %al,-0x9(%rbp)
cmp    $0x0,%al
je     118b <Rprintf+0x6b>
lea    0xe83(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <printf@plt>
jmp    11a3 <Rprintf+0x83>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    0xe76(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1040 <printf@plt>
jmp    11a8 <Rprintf+0x88>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <Rprintf+0x23>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Rprintf>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     117d <Rprintf+0x5d>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     117d <Rprintf+0x5d>
add    $0x1,%rbx
lea    0xed2(%rip),%r14
lea    0xebb(%rip),%r15
jmp    1167 <Rprintf+0x47>
nopw   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117d <Rprintf+0x5d>
movsbl %al,%edi
xor    %esi,%esi
call   1030 <rEscape@plt>
test   %al,%al
je     1150 <Rprintf+0x30>
movsbl %al,%esi
mov    %r15,%rdi
jmp    1157 <Rprintf+0x37>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\1B[0;32;31m%c\1B[m\00"
@.str.1 = [3 x i8] c"%c\00"
define void @Rprintf(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
br label %39
8: ; preds = %1
store i32 0, i32* %4
br label %9
9: ; preds = %36, %8
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %9
%18 = load i8*, i8** %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call signext i8 @rEscape(i8 signext %22, i32 0)
store i8 %23, i8* %3
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i8, i8* %3
%27 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %26)
br label %35
28: ; preds = %17
%29 = load i8*, i8** %2
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %33)
br label %35
35: ; preds = %28, %25
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %9
39: ; preds = %7, %9
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"\1B[0;32;31m%c\1B[m\00"
@.str.1 = [3 x i8] c"%c\00"
define void @Rprintf(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3, %17
%7 = phi i64 [ %18, %17 ], [ 0, %3 ]
%8 = phi i8 [ %20, %17 ], [ %4, %3 ]
%9 = phi i8* [ %19, %17 ], [ %0, %3 ]
%10 = tail call signext i8 @rEscape(i8 signext %8, i32 0)
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8 signext %10)
br label %17
14: ; preds = %6
%15 = load i8, i8* %9
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %15)
br label %17
17: ; preds = %12, %14
%18 = add nuw i64 %7, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %17, %3, %1
ret void
}