#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 EILSEQ;
int _citrus_NONE_ctype_mbtowc(void *__restrict cl, wchar_t *__restrict pwc,
                              const char *__restrict s, size_t n,
                              int *__restrict nresult) {
  if (s == NULL) {
    *nresult = 0;
    return (0);
  }
  if (n == 0) {
    return (EILSEQ);
  }
  if (pwc == NULL) {
    if (*s == '\0') {
      *nresult = 0;
    } else {
      *nresult = 1;
    }
    return (0);
  }
  *pwc = (wchar_t)(unsigned char)*s;
  *nresult = *s == '\0' ? 0 : 1;
  return (0);
}


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_mbtowc>:
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,-0x20(%rbp)
jne    1139 <_citrus_NONE_ctype_mbtowc+0x39>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c6 <_citrus_NONE_ctype_mbtowc+0xc6>
cmpq   $0x0,-0x28(%rbp)
jne    1155 <_citrus_NONE_ctype_mbtowc+0x55>
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <_citrus_NONE_ctype_mbtowc+0xc6>
cmpq   $0x0,-0x18(%rbp)
jne    1195 <_citrus_NONE_ctype_mbtowc+0x95>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117f <_citrus_NONE_ctype_mbtowc+0x7f>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
jmp    1189 <_citrus_NONE_ctype_mbtowc+0x89>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c6 <_citrus_NONE_ctype_mbtowc+0xc6>
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,%ecx
xor    %eax,%eax
cmp    $0x0,%edx
cmove  %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_mbtowc>:
test   %rdx,%rdx
je     1123 <_citrus_NONE_ctype_mbtowc+0x23>
test   %rcx,%rcx
je     112d <_citrus_NONE_ctype_mbtowc+0x2d>
movzbl (%rdx),%eax
test   %rsi,%rsi
je     1115 <_citrus_NONE_ctype_mbtowc+0x15>
mov    %rax,(%rsi)
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,(%r8)
xor    %eax,%eax
ret
movl   $0x0,(%r8)
xor    %eax,%eax
ret
mov    0x2ebc(%rip),%rax
mov    (%rax),%eax
ret

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

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