#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 _citrus_NONE_ctype_mbrlen(void *__restrict cl, const char *__restrict s,
                              size_t n, void *__restrict pspriv,
                              size_t *__restrict nresult) {
  if (!s) {
    *nresult = 0;
    return (0);
  }
  if (n == 0) {
    *nresult = (size_t)-2;
    return (0);
  }
  *nresult = (*s == 0) ? 0 : 1;
  return (0);
}


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_mbrlen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    113a <_citrus_NONE_ctype_mbrlen+0x3a>
mov    -0x30(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1181 <_citrus_NONE_ctype_mbrlen+0x81>
cmpq   $0x0,-0x20(%rbp)
jne    115c <_citrus_NONE_ctype_mbrlen+0x5c>
mov    -0x30(%rbp),%rax
movq   $0xfffffffffffffffe,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1181 <_citrus_NONE_ctype_mbrlen+0x81>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
movslq %eax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_mbrlen>:
test   %rsi,%rsi
je     1114 <_citrus_NONE_ctype_mbrlen+0x14>
test   %rdx,%rdx
je     1118 <_citrus_NONE_ctype_mbrlen+0x18>
xor    %eax,%eax
cmpb   $0x0,(%rsi)
setne  %al
jmp    111f <_citrus_NONE_ctype_mbrlen+0x1f>
xor    %eax,%eax
jmp    111f <_citrus_NONE_ctype_mbrlen+0x1f>
mov    $0xfffffffffffffffe,%rax
mov    %rax,(%r8)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @_citrus_NONE_ctype_mbrlen(i8* noalias nocapture readnone %0, i8* noalias %1, i64 %2, i8* noalias nocapture readnone %3, i64* noalias nocapture writeonly %4) {
%6 = icmp eq i8* %1, null
br i1 %6, label %13, label %7
7: ; preds = %5
%8 = icmp eq i64 %2, 0
br i1 %8, label %13, label %9
9: ; preds = %7
%10 = load i8, i8* %1
%11 = icmp ne i8 %10, 0
%12 = zext i1 %11 to i64
br label %13
13: ; preds = %7, %5, %9
%14 = phi i64 [ %12, %9 ], [ 0, %5 ], [ -2, %7 ]
store i64 %14, i64* %4
ret i32 0
}