#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__ *s;

/* Variables and functions */
scalar_t__ isalnum(scalar_t__);
int CG_DrawStrlen(const char *str) {
  const char *s = str;
  int count = 0;
  while (*s) {
    if (((s) && *(s) == '^' && *((s) + 1) && isalnum(*((s) + 1))))
      s += 2;
    else {
      count++;
      s++;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<CG_DrawStrlen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a7 <CG_DrawStrlen+0x97>
cmpq   $0x0,-0x10(%rbp)
je     118d <CG_DrawStrlen+0x7d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    118d <CG_DrawStrlen+0x7d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     118d <CG_DrawStrlen+0x7d>
mov    -0x10(%rbp),%rax
movsbq 0x1(%rax),%rdi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     118d <CG_DrawStrlen+0x7d>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    11a2 <CG_DrawStrlen+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <CG_DrawStrlen+0x1b>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_DrawStrlen>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
jmp    112f <CG_DrawStrlen+0x1f>
nopw   0x0(%rax,%rax,1)
test   %al,%al
je     1151 <CG_DrawStrlen+0x41>
add    $0x1,%ebp
mov    $0x1,%ecx
add    %rcx,%rbx
movzbl (%rbx),%eax
cmp    $0x5e,%al
jne    1120 <CG_DrawStrlen+0x10>
movsbq 0x1(%rbx),%rdi
test   %rdi,%rdi
je     1124 <CG_DrawStrlen+0x14>
call   1030 <isalnum@plt>
mov    $0x2,%ecx
test   %rax,%rax
jne    112c <CG_DrawStrlen+0x1c>
jmp    1124 <CG_DrawStrlen+0x14>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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