#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 */
size_t mpui_string_strlen16bit(const unsigned char *str) {
  const unsigned char *s;
  for (s = str++; *s++ || *s; s++)
    ;
  return (s - str);
}


x86 assembly (clang, -O0):
<mpui_string_strlen16bit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    114b <mpui_string_strlen16bit+0x4b>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    115b <mpui_string_strlen16bit+0x5b>
jmp    1171 <mpui_string_strlen16bit+0x71>
jmp    1160 <mpui_string_strlen16bit+0x60>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    111b <mpui_string_strlen16bit+0x1b>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpui_string_strlen16bit>:
xor    %eax,%eax
jmp    1114 <mpui_string_strlen16bit+0x14>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x2,%rax
cmpb   $0x0,(%rdi,%rax,1)
jne    1110 <mpui_string_strlen16bit+0x10>
cmpb   $0x0,0x1(%rdi,%rax,1)
jne    1110 <mpui_string_strlen16bit+0x10>
ret

LLVM IR (-O0):
define i64 @mpui_string_strlen16bit(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i32 1
store i8* %5, i8** %2
store i8* %4, i8** %3
br label %6
6: ; preds = %20, %1
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i32 1
store i8* %8, i8** %3
%9 = load i8, i8* %7
%10 = zext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br label %17
17: ; preds = %12, %6
%18 = phi i1 [ true, %6 ], [ %16, %12 ]
br i1 %18, label %19, label %23
19: ; preds = %17
br label %20
20: ; preds = %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %6
23: ; preds = %17
%24 = load i8*, i8** %3
%25 = load i8*, i8** %2
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
ret i64 %28
}

LLVM IR (-O2):
define i64 @mpui_string_strlen16bit(i8* %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i8* [ %0, %1 ], [ %11, %10 ]
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %2, %7
%11 = getelementptr inbounds i8, i8* %3, i64 2
br label %2
12: ; preds = %7
%13 = getelementptr inbounds i8, i8* %0, i64 1
%14 = ptrtoint i8* %4 to i64
%15 = ptrtoint i8* %13 to i64
%16 = sub i64 %14, %15
ret i64 %16
}