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


x86 assembly (clang, -O0):
<printColoredComment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11b3 <printColoredComment+0x93>
mov    $0x1,%edi
lea    0xeb5(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     1192 <printColoredComment+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%esi
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
jmp    115b <printColoredComment+0x3b>
mov    $0x1,%edi
lea    0xe69(%rip),%rsi
mov    $0x3,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ba <printColoredComment+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printColoredComment>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
cmpb   $0x23,(%rdi)
jne    118e <printColoredComment+0x6e>
mov    %esi,%r14d
mov    %rdi,%r12
lea    0xec4(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <write@plt>
test   %r14d,%r14d
je     1175 <printColoredComment+0x55>
mov    %r14d,%ebp
xor    %ebx,%ebx
lea    0xea8(%rip),%r15
nopl   0x0(%rax)
movsbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1160 <printColoredComment+0x40>
lea    0xe8b(%rip),%rsi
mov    $0x1,%edi
mov    $0x3,%edx
call   1030 <write@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"\1B\22\08\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [4 x i8] c"\1B\22\07\00"
define i32 @printColoredComment(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 35
br i1 %4, label %5, label %19
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 = icmp eq i32 %1, 0
br i1 %7, label %17, label %8
8: ; preds = %5, %8
%9 = phi i32 [ %11, %8 ], [ %1, %5 ]
%10 = phi i8* [ %12, %8 ], [ %0, %5 ]
%11 = add nsw i32 %9, -1
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = load i8, i8* %10
%14 = sext i8 %13 to i32
%15 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %11, 0
br i1 %16, label %17, label %8
17: ; preds = %8, %5
%18 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %19
19: ; preds = %2, %17
%20 = phi i32 [ %1, %17 ], [ 0, %2 ]
ret i32 %20
}