#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 *, ...);
int /*<<< orphan*/ write(int, char *, int);
int printColoredSingleString(const char *linbuff, int numChars) {
  if (*linbuff != '\'')
    return 0;
  write(1, "\e\"\x02", 3);
  printf("'");
  linbuff++;
  numChars--;
  int result = 1;
  while (numChars) {
    char c = *linbuff++;
    printf("%c", c);
    result++;
    numChars--;
    if (c == '\'')
      break;
  };
  write(1, "\e\"\x07", 3);
  return result;
}


x86 assembly (clang, -O0):
<printColoredSingleString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
je     114b <printColoredSingleString+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    1200 <printColoredSingleString+0xe0>
mov    $0x1,%edi
lea    0xea9(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11e4 <printColoredSingleString+0xc4>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x27,%eax
jne    11df <printColoredSingleString+0xbf>
jmp    11e4 <printColoredSingleString+0xc4>
jmp    118b <printColoredSingleString+0x6b>
mov    $0x1,%edi
lea    0xe19(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printColoredSingleString>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
cmpb   $0x27,(%rdi)
jne    1193 <printColoredSingleString+0x73>
mov    %rdi,%r15
mov    %esi,%r14d
lea    0xec4(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1040 <write@plt>
mov    $0x27,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
cmp    %ebx,%r14d
je     117d <printColoredSingleString+0x5d>
movsbl (%r15,%rbx,1),%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x27,%ebp
jne    1160 <printColoredSingleString+0x40>
mov    %ebx,%r14d
lea    0xe80(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1040 <write@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"\1B\22\02\00"
@.str.3 = [4 x i8] c"\1B\22\07\00"
define i32 @printColoredSingleString(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 39
br i1 %4, label %5, label %24
5: ; preds = %2
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%7 = tail call i32 @putchar(i32 39)
br label %8
8: ; preds = %15, %5
%9 = phi i8* [ %0, %5 ], [ %12, %15 ]
%10 = phi i32 [ %1, %5 ], [ %13, %15 ]
%11 = phi i32 [ 1, %5 ], [ %19, %15 ]
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = add nsw i32 %10, -1
%14 = icmp eq i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %8
%16 = load i8, i8* %12
%17 = sext i8 %16 to i32
%18 = tail call i32 @putchar(i32 %17)
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i8 %16, 39
br i1 %20, label %21, label %8
21: ; preds = %15, %8
%22 = phi i32 [ %19, %15 ], [ %1, %8 ]
%23 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
br label %24
24: ; preds = %2, %21
%25 = phi i32 [ %22, %21 ], [ 0, %2 ]
ret i32 %25
}