#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 */
scalar_t__ Q_IsColorString(char const *);
int Q_PrintStrlen(const char *string) {
  int len;
  const char *p;
  if (!string) {
    return 0;
  }
  len = 0;
  p = string;
  while (*p) {
    if (Q_IsColorString(p)) {
      p += 2;
      continue;
    }
    p++;
    len++;
  }
  return len;
}


x86 assembly (clang, -O0):
<Q_PrintStrlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <Q_PrintStrlen+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1193 <Q_PrintStrlen+0x83>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     118d <Q_PrintStrlen+0x7d>
mov    -0x20(%rbp),%rdi
call   1030 <Q_IsColorString@plt>
cmp    $0x0,%rax
je     1173 <Q_PrintStrlen+0x63>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1142 <Q_PrintStrlen+0x32>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1142 <Q_PrintStrlen+0x32>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q_PrintStrlen>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1158 <Q_PrintStrlen+0x48>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1158 <Q_PrintStrlen+0x48>
xor    %ebp,%ebp
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%rdi
call   1030 <Q_IsColorString@plt>
test   %rax,%rax
je     1150 <Q_PrintStrlen+0x40>
cmpb   $0x0,0x1(%rbx)
lea    0x2(%rbx),%rbx
jne    1130 <Q_PrintStrlen+0x20>
jmp    1158 <Q_PrintStrlen+0x48>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmpb   $0x0,(%rbx)
jne    1124 <Q_PrintStrlen+0x14>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Q_PrintStrlen(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %29
9: ; preds = %1
store i32 0, i32* %4
%10 = load i8*, i8** %3
store i8* %10, i8** %5
br label %11
11: ; preds = %22, %19, %9
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8*, i8** %5
%17 = call i64 @Q_IsColorString(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 2
store i8* %21, i8** %5
br label %11
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %11
27: ; preds = %11
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %8
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @Q_PrintStrlen(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 i8* [ %18, %17 ], [ %0, %3 ]
%8 = phi i32 [ %19, %17 ], [ 0, %3 ]
br label %9
9: ; preds = %6, %13
%10 = phi i8* [ %7, %6 ], [ %14, %13 ]
%11 = tail call i64 @Q_IsColorString(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %10, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %22, label %9
17: ; preds = %9
%18 = getelementptr inbounds i8, i8* %10, i64 1
%19 = add nuw nsw i32 %8, 1
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %6
22: ; preds = %17, %13, %3, %1
%23 = phi i32 [ 0, %1 ], [ 0, %3 ], [ %8, %13 ], [ %19, %17 ]
ret i32 %23
}