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


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_mblen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1135 <_citrus_NONE_ctype_mblen+0x35>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    117c <_citrus_NONE_ctype_mblen+0x7c>
cmpq   $0x0,-0x20(%rbp)
jne    115b <_citrus_NONE_ctype_mblen+0x5b>
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117c <_citrus_NONE_ctype_mblen+0x7c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%ecx
xor    %eax,%eax
cmp    $0x0,%edx
cmove  %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_mblen>:
test   %rsi,%rsi
je     1117 <_citrus_NONE_ctype_mblen+0x17>
test   %rdx,%rdx
je     1120 <_citrus_NONE_ctype_mblen+0x20>
xor    %eax,%eax
cmpb   $0x0,(%rsi)
setne  %al
mov    %eax,(%rcx)
xor    %eax,%eax
ret
movl   $0x0,(%rcx)
xor    %eax,%eax
ret
movl   $0xffffffff,(%rcx)
mov    0x2ec3(%rip),%rax
mov    (%rax),%eax
ret

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

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