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

/* Variables and functions */
int EILSEQ;
int _citrus_NONE_ctype_wcrtomb(void *__restrict cl, char *__restrict s,
                               wchar_t wc, void *__restrict pspriv,
                               size_t *__restrict nresult) {
  if ((wc & ~0xFFU) != 0) {
    *nresult = (size_t)-1;
    return (EILSEQ);
  }
  *nresult = 1;
  if (s != NULL)
    *s = (char)wc;
  return (0);
}


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_wcrtomb>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xffffff00,%eax
cmp    $0x0,%eax
je     1144 <_citrus_NONE_ctype_wcrtomb+0x44>
mov    -0x30(%rbp),%rax
movq   $0xffffffffffffffff,(%rax)
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    116c <_citrus_NONE_ctype_wcrtomb+0x6c>
mov    -0x30(%rbp),%rax
movq   $0x1,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     1165 <_citrus_NONE_ctype_wcrtomb+0x65>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_wcrtomb>:
cmp    $0x100,%edx
jae    1119 <_citrus_NONE_ctype_wcrtomb+0x19>
movq   $0x1,(%r8)
xor    %eax,%eax
test   %rsi,%rsi
je     1118 <_citrus_NONE_ctype_wcrtomb+0x18>
mov    %dl,(%rsi)
ret
movq   $0xffffffffffffffff,(%r8)
mov    0x2ec9(%rip),%rax
mov    (%rax),%eax
ret

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

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