#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__ wchar_t;

/* Variables and functions */
int _citrus_NONE_ctype_mbrtowc(void *__restrict cl, wchar_t *__restrict pwc,
                               const char *__restrict s, size_t n,
                               void *__restrict pspriv,
                               size_t *__restrict nresult) {
  if (s == NULL) {
    *nresult = 0;
    return (0);
  }
  if (n == 0) {
    *nresult = (size_t)-2;
    return (0);
  }
  if (pwc != NULL)
    *pwc = (wchar_t)(unsigned char)*s;
  *nresult = *s == '\0' ? 0 : 1;
  return (0);
}


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_mbrtowc>:
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)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    113e <_citrus_NONE_ctype_mbrtowc+0x3e>
mov    -0x38(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11a0 <_citrus_NONE_ctype_mbrtowc+0xa0>
cmpq   $0x0,-0x28(%rbp)
jne    1160 <_citrus_NONE_ctype_mbrtowc+0x60>
mov    -0x38(%rbp),%rax
movq   $0xfffffffffffffffe,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11a0 <_citrus_NONE_ctype_mbrtowc+0xa0>
cmpq   $0x0,-0x18(%rbp)
je     117b <_citrus_NONE_ctype_mbrtowc+0x7b>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
movslq %eax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_mbrtowc>:
test   %rdx,%rdx
je     111f <_citrus_NONE_ctype_mbrtowc+0x1f>
test   %rcx,%rcx
je     1123 <_citrus_NONE_ctype_mbrtowc+0x23>
movzbl (%rdx),%ecx
test   %rsi,%rsi
je     1115 <_citrus_NONE_ctype_mbrtowc+0x15>
mov    %rcx,(%rsi)
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    112a <_citrus_NONE_ctype_mbrtowc+0x2a>
xor    %eax,%eax
jmp    112a <_citrus_NONE_ctype_mbrtowc+0x2a>
mov    $0xfffffffffffffffe,%rax
mov    %rax,(%r9)
xor    %eax,%eax
ret

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

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