#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*/ s;
typedef char mbstate_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EILSEQ;
int /*<<< orphan*/ LC_CTYPE;
int MB_CUR_MAX;
int /*<<< orphan*/ MB_LEN_MAX;
int UCHAR_MAX;
int /*<<< orphan*/ assert(int);
scalar_t__ errno;
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int wcrtomb(char *, int, char *);
int main(int argc, char *argv[]) {
  mbstate_t s;
  size_t len;
  char buf[MB_LEN_MAX + 1];
  printf("1..1\n");
  assert(MB_CUR_MAX == 1);
  assert(wcrtomb(NULL, L'\0', NULL) == 1);
  assert(wcrtomb(NULL, UCHAR_MAX + 1, NULL) == 1);
  memset(&s, 0, sizeof(s));
  memset(buf, 0xcc, sizeof(buf));
  len = wcrtomb(buf, L'\0', &s);
  assert(len == 1);
  assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
  assert(wcrtomb(NULL, L'\0', NULL) == 1);
  assert(wcrtomb(NULL, L'A', NULL) == 1);
  memset(&s, 0, sizeof(s));
  memset(buf, 0xcc, sizeof(buf));
  len = wcrtomb(buf, L'A', &s);
  assert(len == 1);
  assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
  assert(wcrtomb(buf, UCHAR_MAX + 1, NULL) == (size_t)-1);
  assert(errno == EILSEQ);
  assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
  assert(MB_CUR_MAX == 3);
  assert(wcrtomb(NULL, L'\0', NULL) == 1);
  memset(&s, 0, sizeof(s));
  memset(buf, 0xcc, sizeof(buf));
  len = wcrtomb(buf, L'\0', &s);
  assert(len == 1);
  assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
  assert(wcrtomb(NULL, L'\0', NULL) == 1);
  assert(wcrtomb(NULL, L'A', NULL) == 1);
  memset(&s, 0, sizeof(s));
  memset(buf, 0xcc, sizeof(buf));
  len = wcrtomb(buf, L'A', &s);
  assert(len == 1);
  assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
  memset(&s, 0, sizeof(s));
  memset(buf, 0xcc, sizeof(buf));
  len = wcrtomb(buf, 0xa3c1, &s);
  assert(len == 2);
  assert((unsigned char)buf[0] == 0xa3 && (unsigned char)buf[1] == 0xc1 &&
         (unsigned char)buf[2] == 0xcc);
  printf("ok 1 - wcrtomb()\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3c(%rip),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
xor    %esi,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
lea    -0x11(%rbp),%rdx
call   1070 <wcrtomb@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    1285 <main+0x125>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
xor    %esi,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
mov    $0x41,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    $0x41,%esi
lea    -0x11(%rbp),%rdx
call   1070 <wcrtomb@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x49(%rbp)
jne    1347 <main+0x1e7>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rdi
mov    0x2c81(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <wcrtomb@plt>
cltq
cmp    $0xffffffffffffffff,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2c39(%rip),%rax
mov    (%rax),%rax
mov    0x2c57(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2c28(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
call   1080 <setlocale@plt>
mov    %eax,%edi
lea    0xc47(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2c1c(%rip),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
xor    %esi,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
lea    -0x11(%rbp),%rdx
call   1070 <wcrtomb@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x4a(%rbp)
jne    147d <main+0x31d>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x4a(%rbp)
mov    -0x4a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
xor    %esi,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edx
mov    $0x41,%esi
mov    %rdx,%rdi
call   1070 <wcrtomb@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    $0x41,%esi
lea    -0x11(%rbp),%rdx
call   1070 <wcrtomb@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x4b(%rbp)
jne    153f <main+0x3df>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x4b(%rbp)
mov    -0x4b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    $0xa3c1,%esi
lea    -0x11(%rbp),%rdx
call   1070 <wcrtomb@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x2,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x40(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa3,%ecx
mov    %al,-0x4c(%rbp)
jne    15de <main+0x47e>
mov    -0x40(%rbp),%rax
movzbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0xc1,%ecx
mov    %al,-0x4c(%rbp)
jne    15de <main+0x47e>
mov    -0x40(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x4c(%rbp)
mov    -0x4c(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xa20(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,-0x38(%rbp)
mov    0x2e3c(%rip),%rax
mov    (%rax),%r14d
add    $0x1,%r14d
mov    %rsp,%r13
lea    0xf(%r14),%r15
and    $0xfffffffffffffff0,%r15
mov    %r13,%rbx
sub    %r15,%rbx
mov    %rbx,%rsp
neg    %r15
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4b(%rip),%rax
xor    %edi,%edi
cmpl   $0x1,(%rax)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
xor    %edi,%edi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    -0x29(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12,%rdx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x0,0x0(%r13,%r15,1)
mov    $0x0,%edi
jne    124c <main+0xec>
xor    %edi,%edi
cmpb   $0xcc,0x1(%rbx)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    $0x41,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    -0x29(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
mov    %r12,%rdx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x41,(%rbx)
mov    $0x0,%edi
jne    12db <main+0x17b>
xor    %edi,%edi
cmpb   $0xcc,0x1(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%rax
mov    0x2cd0(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%rax
sete   %dil
call   1060 <assert@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
lea    0xcca(%rip),%r12
mov    %r12,%rsi
call   1080 <setlocale@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    0x2c99(%rip),%rax
cmpl   $0x3,(%rax)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    -0x29(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r12,%rdx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x0,(%rbx)
mov    $0x0,%edi
jne    13d6 <main+0x276>
xor    %edi,%edi
cmpb   $0xcc,0x1(%rbx)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
mov    $0x41,%esi
xor    %edx,%edx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    -0x29(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
mov    %r12,%rdx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x41,(%rbx)
jne    1461 <main+0x301>
xor    %r15d,%r15d
cmpb   $0xcc,0x1(%rbx)
sete   %r15b
mov    %r15d,%edi
call   1060 <assert@plt>
lea    -0x29(%rbp),%r12
xor    %r15d,%r15d
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xa3c1,%esi
mov    %r12,%rdx
call   1070 <wcrtomb@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0xa3,(%rbx)
jne    14c9 <main+0x369>
cmpb   $0xc1,0x1(%rbx)
mov    -0x38(%rbp),%r14
jne    14cd <main+0x36d>
xor    %r15d,%r15d
cmpb   $0xcc,0x2(%rbx)
sete   %r15b
jmp    14cd <main+0x36d>
mov    -0x38(%rbp),%r14
mov    %r15d,%edi
call   1060 <assert@plt>
lea    0xb35(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MB_LEN_MAX = global i32 0
@.str = [6 x i8] c"1..1\0A\00"
@MB_CUR_MAX = global i32 0
@UCHAR_MAX = global i32 0
@errno = global i64 0
@EILSEQ = global i64 0
@LC_CTYPE = global i32 0
@.str.1 = [12 x i8] c"ja_JP.eucJP\00"
@.str.2 = [18 x i8] c"ok 1 - wcrtomb()\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @MB_LEN_MAX
%11 = add nsw i32 %10, 1
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca i8, i64 %12
store i64 %12, i64* %9
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @MB_CUR_MAX
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%21 = icmp eq i32 %20, 1
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* @UCHAR_MAX
%25 = add nsw i32 %24, 1
%26 = call i32 @wcrtomb(i8* null, i32 %25, i8* null)
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @memset(i8* %6, i32 0, i32 1)
%31 = trunc i64 %12 to i32
%32 = call i32 @memset(i8* %14, i32 204, i32 %31)
%33 = call i32 @wcrtomb(i8* %14, i32 0, i8* %6)
%34 = sext i32 %33 to i64
store i64 %34, i64* %7
%35 = load i64, i64* %7
%36 = icmp eq i64 %35, 1
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = getelementptr inbounds i8, i8* %14, i64 0
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %2
%44 = getelementptr inbounds i8, i8* %14, i64 1
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = icmp eq i32 %46, 204
br label %48
48: ; preds = %43, %2
%49 = phi i1 [ false, %2 ], [ %47, %43 ]
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%53 = icmp eq i32 %52, 1
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = call i32 @wcrtomb(i8* null, i32 65, i8* null)
%57 = icmp eq i32 %56, 1
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @memset(i8* %6, i32 0, i32 1)
%61 = trunc i64 %12 to i32
%62 = call i32 @memset(i8* %14, i32 204, i32 %61)
%63 = call i32 @wcrtomb(i8* %14, i32 65, i8* %6)
%64 = sext i32 %63 to i64
store i64 %64, i64* %7
%65 = load i64, i64* %7
%66 = icmp eq i64 %65, 1
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = getelementptr inbounds i8, i8* %14, i64 0
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = icmp eq i32 %71, 65
br i1 %72, label %73, label %78
73: ; preds = %48
%74 = getelementptr inbounds i8, i8* %14, i64 1
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = icmp eq i32 %76, 204
br label %78
78: ; preds = %73, %48
%79 = phi i1 [ false, %48 ], [ %77, %73 ]
%80 = zext i1 %79 to i32
%81 = call i32 @assert(i32 %80)
%82 = load i32, i32* @UCHAR_MAX
%83 = add nsw i32 %82, 1
%84 = call i32 @wcrtomb(i8* %14, i32 %83, i8* null)
%85 = sext i32 %84 to i64
%86 = icmp eq i64 %85, -1
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = load i64, i64* @errno
%90 = load i64, i64* @EILSEQ
%91 = icmp eq i64 %89, %90
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = load i32, i32* @LC_CTYPE
%95 = call i32 @setlocale(i32 %94, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%96 = call i64 @strcmp(i32 %95, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
%98 = zext i1 %97 to i32
%99 = call i32 @assert(i32 %98)
%100 = load i32, i32* @MB_CUR_MAX
%101 = icmp eq i32 %100, 3
%102 = zext i1 %101 to i32
%103 = call i32 @assert(i32 %102)
%104 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%105 = icmp eq i32 %104, 1
%106 = zext i1 %105 to i32
%107 = call i32 @assert(i32 %106)
%108 = call i32 @memset(i8* %6, i32 0, i32 1)
%109 = trunc i64 %12 to i32
%110 = call i32 @memset(i8* %14, i32 204, i32 %109)
%111 = call i32 @wcrtomb(i8* %14, i32 0, i8* %6)
%112 = sext i32 %111 to i64
store i64 %112, i64* %7
%113 = load i64, i64* %7
%114 = icmp eq i64 %113, 1
%115 = zext i1 %114 to i32
%116 = call i32 @assert(i32 %115)
%117 = getelementptr inbounds i8, i8* %14, i64 0
%118 = load i8, i8* %117
%119 = zext i8 %118 to i32
%120 = icmp eq i32 %119, 0
br i1 %120, label %121, label %126
121: ; preds = %78
%122 = getelementptr inbounds i8, i8* %14, i64 1
%123 = load i8, i8* %122
%124 = zext i8 %123 to i32
%125 = icmp eq i32 %124, 204
br label %126
126: ; preds = %121, %78
%127 = phi i1 [ false, %78 ], [ %125, %121 ]
%128 = zext i1 %127 to i32
%129 = call i32 @assert(i32 %128)
%130 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%131 = icmp eq i32 %130, 1
%132 = zext i1 %131 to i32
%133 = call i32 @assert(i32 %132)
%134 = call i32 @wcrtomb(i8* null, i32 65, i8* null)
%135 = icmp eq i32 %134, 1
%136 = zext i1 %135 to i32
%137 = call i32 @assert(i32 %136)
%138 = call i32 @memset(i8* %6, i32 0, i32 1)
%139 = trunc i64 %12 to i32
%140 = call i32 @memset(i8* %14, i32 204, i32 %139)
%141 = call i32 @wcrtomb(i8* %14, i32 65, i8* %6)
%142 = sext i32 %141 to i64
store i64 %142, i64* %7
%143 = load i64, i64* %7
%144 = icmp eq i64 %143, 1
%145 = zext i1 %144 to i32
%146 = call i32 @assert(i32 %145)
%147 = getelementptr inbounds i8, i8* %14, i64 0
%148 = load i8, i8* %147
%149 = zext i8 %148 to i32
%150 = icmp eq i32 %149, 65
br i1 %150, label %151, label %156
151: ; preds = %126
%152 = getelementptr inbounds i8, i8* %14, i64 1
%153 = load i8, i8* %152
%154 = zext i8 %153 to i32
%155 = icmp eq i32 %154, 204
br label %156
156: ; preds = %151, %126
%157 = phi i1 [ false, %126 ], [ %155, %151 ]
%158 = zext i1 %157 to i32
%159 = call i32 @assert(i32 %158)
%160 = call i32 @memset(i8* %6, i32 0, i32 1)
%161 = trunc i64 %12 to i32
%162 = call i32 @memset(i8* %14, i32 204, i32 %161)
%163 = call i32 @wcrtomb(i8* %14, i32 41921, i8* %6)
%164 = sext i32 %163 to i64
store i64 %164, i64* %7
%165 = load i64, i64* %7
%166 = icmp eq i64 %165, 2
%167 = zext i1 %166 to i32
%168 = call i32 @assert(i32 %167)
%169 = getelementptr inbounds i8, i8* %14, i64 0
%170 = load i8, i8* %169
%171 = zext i8 %170 to i32
%172 = icmp eq i32 %171, 163
br i1 %172, label %173, label %183
173: ; preds = %156
%174 = getelementptr inbounds i8, i8* %14, i64 1
%175 = load i8, i8* %174
%176 = zext i8 %175 to i32
%177 = icmp eq i32 %176, 193
br i1 %177, label %178, label %183
178: ; preds = %173
%179 = getelementptr inbounds i8, i8* %14, i64 2
%180 = load i8, i8* %179
%181 = zext i8 %180 to i32
%182 = icmp eq i32 %181, 204
br label %183
183: ; preds = %178, %173, %156
%184 = phi i1 [ false, %173 ], [ false, %156 ], [ %182, %178 ]
%185 = zext i1 %184 to i32
%186 = call i32 @assert(i32 %185)
%187 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
%188 = load i8*, i8** %8
%189 = load i32, i32* %3
ret i32 %189
}

LLVM IR (-O2):
@MB_LEN_MAX = global i32 0
@MB_CUR_MAX = global i32 0
@UCHAR_MAX = global i32 0
@errno = global i64 0
@EILSEQ = global i64 0
@LC_CTYPE = global i32 0
@.str.1 = [12 x i8] c"ja_JP.eucJP\00"
@str = [5 x i8] c"1..1\00"
@str.3 = [17 x i8] c"ok 1 - wcrtomb()\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = load i32, i32* @MB_LEN_MAX
%5 = add nsw i32 %4, 1
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @MB_CUR_MAX
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @wcrtomb(i8* null, i32 0, i8* null)
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = load i32, i32* @UCHAR_MAX
%19 = add nsw i32 %18, 1
%20 = tail call i32 @wcrtomb(i8* null, i32 %19, i8* null)
%21 = icmp eq i32 %20, 1
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = call i32 @memset(i8* %3, i32 0, i32 1)
%25 = call i32 @memset(i8* %8, i32 204, i32 %5)
%26 = call i32 @wcrtomb(i8* %8, i32 0, i8* %3)
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i8, i8* %8
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = getelementptr inbounds i8, i8* %8, i64 1
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, -52
%36 = zext i1 %35 to i32
br label %37
37: ; preds = %32, %2
%38 = phi i32 [ 0, %2 ], [ %36, %32 ]
%39 = call i32 @assert(i32 %38)
%40 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%41 = icmp eq i32 %40, 1
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i32 @wcrtomb(i8* null, i32 65, i8* null)
%45 = icmp eq i32 %44, 1
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = call i32 @memset(i8* %3, i32 0, i32 1)
%49 = call i32 @memset(i8* %8, i32 204, i32 %5)
%50 = call i32 @wcrtomb(i8* %8, i32 65, i8* %3)
%51 = icmp eq i32 %50, 1
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load i8, i8* %8
%55 = icmp eq i8 %54, 65
br i1 %55, label %56, label %61
56: ; preds = %37
%57 = getelementptr inbounds i8, i8* %8, i64 1
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, -52
%60 = zext i1 %59 to i32
br label %61
61: ; preds = %56, %37
%62 = phi i32 [ 0, %37 ], [ %60, %56 ]
%63 = call i32 @assert(i32 %62)
%64 = load i32, i32* @UCHAR_MAX
%65 = add nsw i32 %64, 1
%66 = call i32 @wcrtomb(i8* %8, i32 %65, i8* null)
%67 = icmp eq i32 %66, -1
%68 = zext i1 %67 to i32
%69 = call i32 @assert(i32 %68)
%70 = load i64, i64* @errno
%71 = load i64, i64* @EILSEQ
%72 = icmp eq i64 %70, %71
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load i32, i32* @LC_CTYPE
%76 = call i32 @setlocale(i32 %75, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%77 = call i64 @strcmp(i32 %76, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
%79 = zext i1 %78 to i32
%80 = call i32 @assert(i32 %79)
%81 = load i32, i32* @MB_CUR_MAX
%82 = icmp eq i32 %81, 3
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
%85 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%86 = icmp eq i32 %85, 1
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = call i32 @memset(i8* %3, i32 0, i32 1)
%90 = call i32 @memset(i8* %8, i32 204, i32 %5)
%91 = call i32 @wcrtomb(i8* %8, i32 0, i8* %3)
%92 = icmp eq i32 %91, 1
%93 = zext i1 %92 to i32
%94 = call i32 @assert(i32 %93)
%95 = load i8, i8* %8
%96 = icmp eq i8 %95, 0
br i1 %96, label %97, label %102
97: ; preds = %61
%98 = getelementptr inbounds i8, i8* %8, i64 1
%99 = load i8, i8* %98
%100 = icmp eq i8 %99, -52
%101 = zext i1 %100 to i32
br label %102
102: ; preds = %97, %61
%103 = phi i32 [ 0, %61 ], [ %101, %97 ]
%104 = call i32 @assert(i32 %103)
%105 = call i32 @wcrtomb(i8* null, i32 0, i8* null)
%106 = icmp eq i32 %105, 1
%107 = zext i1 %106 to i32
%108 = call i32 @assert(i32 %107)
%109 = call i32 @wcrtomb(i8* null, i32 65, i8* null)
%110 = icmp eq i32 %109, 1
%111 = zext i1 %110 to i32
%112 = call i32 @assert(i32 %111)
%113 = call i32 @memset(i8* %3, i32 0, i32 1)
%114 = call i32 @memset(i8* %8, i32 204, i32 %5)
%115 = call i32 @wcrtomb(i8* %8, i32 65, i8* %3)
%116 = icmp eq i32 %115, 1
%117 = zext i1 %116 to i32
%118 = call i32 @assert(i32 %117)
%119 = load i8, i8* %8
%120 = icmp eq i8 %119, 65
br i1 %120, label %121, label %126
121: ; preds = %102
%122 = getelementptr inbounds i8, i8* %8, i64 1
%123 = load i8, i8* %122
%124 = icmp eq i8 %123, -52
%125 = zext i1 %124 to i32
br label %126
126: ; preds = %121, %102
%127 = phi i32 [ 0, %102 ], [ %125, %121 ]
%128 = call i32 @assert(i32 %127)
%129 = call i32 @memset(i8* %3, i32 0, i32 1)
%130 = call i32 @memset(i8* %8, i32 204, i32 %5)
%131 = call i32 @wcrtomb(i8* %8, i32 41921, i8* %3)
%132 = icmp eq i32 %131, 2
%133 = zext i1 %132 to i32
%134 = call i32 @assert(i32 %133)
%135 = load i8, i8* %8
%136 = icmp eq i8 %135, -93
br i1 %136, label %137, label %146
137: ; preds = %126
%138 = getelementptr inbounds i8, i8* %8, i64 1
%139 = load i8, i8* %138
%140 = icmp eq i8 %139, -63
br i1 %140, label %141, label %146
141: ; preds = %137
%142 = getelementptr inbounds i8, i8* %8, i64 2
%143 = load i8, i8* %142
%144 = icmp eq i8 %143, -52
%145 = zext i1 %144 to i32
br label %146
146: ; preds = %141, %137, %126
%147 = phi i32 [ 0, %137 ], [ 0, %126 ], [ %145, %141 ]
%148 = call i32 @assert(i32 %147)
%149 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}