#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 /*<<< orphan*/ wchar_t;

/* Variables and functions */
int _citrus_NONE_ctype_wcrtomb(void *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/ *, size_t *);
int _citrus_NONE_ctype_wctomb(void *__restrict cl, char *__restrict s,
                              wchar_t wc, int *__restrict nresult) {
  int ret;
  size_t nr;
  if (s == 0) {
    *nresult = 0;
    return (0);
  }
  ret = _citrus_NONE_ctype_wcrtomb(cl, s, wc, NULL, &nr);
  *nresult = (int)nr;
  return (ret);
}


x86 assembly (clang, -O0):
<_citrus_NONE_ctype_wctomb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1148 <_citrus_NONE_ctype_wctomb+0x38>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1175 <_citrus_NONE_ctype_wctomb+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x38(%rbp),%r8
call   1030 <_citrus_NONE_ctype_wcrtomb@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_ctype_wctomb>:
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
test   %rsi,%rsi
je     112f <_citrus_NONE_ctype_wctomb+0x1f>
lea    0x8(%rsp),%r8
xor    %ecx,%ecx
call   1030 <_citrus_NONE_ctype_wcrtomb@plt>
mov    0x8(%rsp),%ecx
jmp    1133 <_citrus_NONE_ctype_wctomb+0x23>
xor    %ecx,%ecx
xor    %eax,%eax
mov    %ecx,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

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

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