#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 */
typedef scalar_t__ *str;

/* Variables and functions */
int /*<<< orphan*/ Q_UTF8Width(char const *);
scalar_t__ isalnum(scalar_t__);
int Q_UTF8PrintStrlen(const char *str) {
  int l = 0;
  while (*str) {
    if (((str) && *(str) == '^' && *((str) + 1) && isalnum(*((str) + 1)))) {
      str += 2;
      continue;
    }
    l++;
    str += Q_UTF8Width(str);
  }
  return l;
}


x86 assembly (clang, -O0):
<Q_UTF8PrintStrlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bc <Q_UTF8PrintStrlen+0x9c>
cmpq   $0x0,-0x8(%rbp)
je     1195 <Q_UTF8PrintStrlen+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    1195 <Q_UTF8PrintStrlen+0x75>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1195 <Q_UTF8PrintStrlen+0x75>
mov    -0x8(%rbp),%rax
movsbq 0x1(%rax),%rdi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
je     1195 <Q_UTF8PrintStrlen+0x75>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
jmp    1133 <Q_UTF8PrintStrlen+0x13>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <Q_UTF8Width@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1133 <Q_UTF8PrintStrlen+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q_UTF8PrintStrlen>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
jmp    1141 <Q_UTF8PrintStrlen+0x21>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rbx,%rdi
call   1030 <Q_UTF8Width@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%eax
cmp    $0x5e,%al
jne    1180 <Q_UTF8PrintStrlen+0x60>
movsbq 0x1(%rbx),%rdi
test   %rdi,%rdi
je     1130 <Q_UTF8PrintStrlen+0x10>
call   1040 <isalnum@plt>
test   %rax,%rax
je     1130 <Q_UTF8PrintStrlen+0x10>
add    $0x2,%rbx
jmp    1150 <Q_UTF8PrintStrlen+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %al,%al
jne    1130 <Q_UTF8PrintStrlen+0x10>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @Q_UTF8PrintStrlen(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %32, %29, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %40
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 94
br i1 %15, label %16, label %32
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i64
%27 = call i64 @isalnum(i64 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 2
store i8* %31, i8** %2
br label %4
32: ; preds = %22, %16, %11, %8
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
%35 = load i8*, i8** %2
%36 = call i32 @Q_UTF8Width(i8* %35)
%37 = load i8*, i8** %2
%38 = sext i32 %36 to i64
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8* %39, i8** %2
br label %4
40: ; preds = %4
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @Q_UTF8PrintStrlen(i8* %0) {
br label %2
2: ; preds = %18, %1
%3 = phi i8* [ %22, %18 ], [ %0, %1 ]
%4 = phi i32 [ %19, %18 ], [ 0, %1 ]
br label %5
5: ; preds = %2, %16
%6 = phi i8* [ %17, %16 ], [ %3, %2 ]
%7 = load i8, i8* %6
switch i8 %7, label %18 [
i8 0, label %23
i8 94, label %8
]
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = sext i8 %10 to i64
%14 = tail call i64 @isalnum(i64 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %6, i64 2
br label %5
18: ; preds = %5, %12, %8
%19 = add nuw nsw i32 %4, 1
%20 = tail call i32 @Q_UTF8Width(i8* %6)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %6, i64 %21
br label %2
23: ; preds = %5
ret i32 %4
}