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

/* Variables and functions */
int /*<<< orphan*/ LC_CTYPE;
int MB_CUR_MAX;
int /*<<< orphan*/ MB_LEN_MAX;
int /*<<< orphan*/ assert(int);
int mbrtowc(int *, char *, int, char *);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  mbstate_t s;
  size_t len;
  wchar_t wc;
  char buf[MB_LEN_MAX + 1];
  printf("1..1\n");
  assert(MB_CUR_MAX == 1);
  memset(buf, 0xcc, sizeof(buf));
  buf[0] = 0;
  assert(mbrtowc(&wc, buf, 1, NULL) == 0);
  assert(wc == 0);
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 1, &s) == 0);
  assert(wc == 0);
  assert(mbrtowc(NULL, 0, 0, NULL) == 0);
  buf[0] = 'A';
  assert(mbrtowc(&wc, buf, 1, NULL) == 1);
  assert(wc == L'A');
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 1, &s) == 1);
  assert(wc == L'A');
  wc = L'z';
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
  assert(wc == L'z');
  wc = L'z';
  memset(&s, 0, sizeof(s));
  buf[0] = '\0';
  assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
  assert(wc == L'z');
  assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
  assert(MB_CUR_MAX > 1);
  assert(mbrtowc(NULL, 0, 0, NULL) == 0);
  memset(buf, 0xcc, sizeof(buf));
  buf[0] = 0;
  assert(mbrtowc(&wc, buf, 1, NULL) == 0);
  assert(wc == 0);
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 1, &s) == 0);
  assert(wc == 0);
  assert(mbrtowc(NULL, 0, 0, NULL) == 0);
  buf[0] = 'A';
  assert(mbrtowc(&wc, buf, 1, NULL) == 1);
  assert(wc == L'A');
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 1, &s) == 1);
  assert(wc == L'A');
  wc = L'z';
  memset(&s, 0, sizeof(s));
  assert(mbrtowc(&wc, buf, 0, &s) == (size_t)-2);
  assert(wc == L'z');
  memset(buf, 0xcc, sizeof(buf));
  buf[0] = 0xa3;
  buf[1] = 0x00;
  memset(&s, 0, sizeof(s));
  wc = 0;
  assert(mbrtowc(&wc, buf, 1, &s) == (size_t)-2);
  buf[1] = 0xc1;
  memset(&s, 0, sizeof(s));
  wc = 0;
  assert(mbrtowc(&wc, buf, 2, &s) == 2);
  assert(wc == 0xa3c1);
  memset(buf, 0xcc, sizeof(buf));
  buf[0] = 0xa3;
  memset(&s, 0, sizeof(s));
  wc = 0;
  assert(mbrtowc(&wc, buf, 1, &s) == (size_t)-2);
  assert(wc == 0);
  buf[0] = 0xc1;
  assert(mbrtowc(&wc, buf, 1, &s) == 1);
  assert(wc == 0xa3c1);
  printf("ok 1 - mbrtowc()\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    0x2e53(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%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,-0x38(%rbp)
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e3c(%rip),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movb   $0x0,(%rsi)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rdi
mov    %rcx,%rsi
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rsi
movb   $0x41,(%rsi)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <mbrtowc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x41,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x41,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x7a,-0x24(%rbp)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
xor    %edx,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cltq
cmp    $0xfffffffffffffffe,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x7a,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x7a,-0x24(%rbp)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movb   $0x0,(%rsi)
lea    -0x24(%rbp),%rdi
xor    %edx,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cltq
cmp    $0xfffffffffffffffe,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x7a,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
call   1080 <setlocale@plt>
mov    %eax,%edi
lea    0xc46(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    0x2c1b(%rip),%rax
cmpl   $0x1,(%rax)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rdi
mov    %rcx,%rsi
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movb   $0x0,(%rsi)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
mov    %eax,%ecx
xor    %edx,%edx
mov    %rcx,%rdi
mov    %rcx,%rsi
call   1030 <mbrtowc@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rsi
movb   $0x41,(%rsi)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <mbrtowc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x41,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x41,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
movl   $0x7a,-0x24(%rbp)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
lea    -0x24(%rbp),%rdi
xor    %edx,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cltq
cmp    $0xfffffffffffffffe,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x7a,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rax
movb   $0xa3,(%rax)
movb   $0x0,0x1(%rax)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movl   $0x0,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cltq
cmp    $0xfffffffffffffffe,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rax
movb   $0xc1,0x1(%rax)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movl   $0x0,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x2,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0xa3c1,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1050 <memset@plt>
mov    -0x40(%rbp),%rax
movb   $0xa3,(%rax)
lea    -0x11(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0x40(%rbp),%rsi
movl   $0x0,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cltq
cmp    $0xfffffffffffffffe,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x40(%rbp),%rsi
movb   $0xc1,(%rsi)
lea    -0x24(%rbp),%rdi
mov    $0x1,%edx
lea    -0x11(%rbp),%rcx
call   1030 <mbrtowc@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0xa3c1,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0x917(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%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    $0x28,%rsp
mov    %rsp,-0x48(%rbp)
mov    0x2e54(%rip),%rax
mov    (%rax),%r15d
add    $0x1,%r15d
mov    %rsp,%rbx
mov    %rbx,-0x40(%rbp)
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
mov    %rax,-0x38(%rbp)
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e46(%rip),%rax
xor    %edi,%edi
cmpl   $0x1,(%rax)
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r15d,%edx
call   1050 <memset@plt>
movb   $0x0,(%rbx)
lea    -0x2c(%rbp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
lea    -0x2d(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
movb   $0x41,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x41,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x41,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
movl   $0x7a,-0x2c(%rbp)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x7a,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
movl   $0x7a,-0x2c(%rbp)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x7a,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%r13
mov    %r13,%rsi
call   1080 <setlocale@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
mov    0x2c64(%rip),%rax
cmpl   $0x2,(%rax)
setge  %dil
call   1070 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r15d,%edx
call   1050 <memset@plt>
movb   $0x0,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
movb   $0x41,(%rbx)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x41,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x41,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
movl   $0x7a,-0x2c(%rbp)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x7a,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r15d,%edx
call   1050 <memset@plt>
movw   $0xa3,(%rbx)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1070 <assert@plt>
movb   $0xc1,0x1(%rbx)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0xa3c1,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r15d,%edx
call   1050 <memset@plt>
movb   $0xa3,(%rbx)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0xfffffffe,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0xc1,(%rax,%rcx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r12,%rcx
call   1040 <mbrtowc@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmpl   $0xa3c1,-0x2c(%rbp)
sete   %dil
call   1070 <assert@plt>
lea    0x9d2(%rip),%rdi
call   1030 <puts@plt>
mov    -0x48(%rbp),%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
@LC_CTYPE = global i32 0
@.str.1 = [12 x i8] c"ja_JP.eucJP\00"
@.str.2 = [18 x i8] c"ok 1 - mbrtowc()\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 i32
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @MB_LEN_MAX
%12 = add nsw i32 %11, 1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @MB_CUR_MAX
%18 = icmp eq i32 %17, 1
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = trunc i64 %13 to i32
%22 = call i32 @memset(i8* %15, i32 204, i32 %21)
%23 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %23
%24 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* null)
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = call i32 @memset(i8* %6, i32 0, i32 1)
%33 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32, i32* %8
%38 = icmp eq i32 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = call i32 @mbrtowc(i32* null, i8* null, i32 0, i8* null)
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = getelementptr inbounds i8, i8* %15, i64 0
store i8 65, i8* %45
%46 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* null)
%47 = icmp eq i32 %46, 1
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 65
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = call i32 @memset(i8* %6, i32 0, i32 1)
%55 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%56 = icmp eq i32 %55, 1
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i32, i32* %8
%60 = icmp eq i32 %59, 65
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
store i32 122, i32* %8
%63 = call i32 @memset(i8* %6, i32 0, i32 1)
%64 = call i32 @mbrtowc(i32* %8, i8* %15, i32 0, i8* %6)
%65 = sext i32 %64 to i64
%66 = icmp eq i64 %65, -2
%67 = zext i1 %66 to i32
%68 = call i32 @assert(i32 %67)
%69 = load i32, i32* %8
%70 = icmp eq i32 %69, 122
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
store i32 122, i32* %8
%73 = call i32 @memset(i8* %6, i32 0, i32 1)
%74 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %74
%75 = call i32 @mbrtowc(i32* %8, i8* %15, i32 0, i8* %6)
%76 = sext i32 %75 to i64
%77 = icmp eq i64 %76, -2
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = load i32, i32* %8
%81 = icmp eq i32 %80, 122
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = load i32, i32* @LC_CTYPE
%85 = call i32 @setlocale(i32 %84, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%86 = call i64 @strcmp(i32 %85, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
%88 = zext i1 %87 to i32
%89 = call i32 @assert(i32 %88)
%90 = load i32, i32* @MB_CUR_MAX
%91 = icmp sgt i32 %90, 1
%92 = zext i1 %91 to i32
%93 = call i32 @assert(i32 %92)
%94 = call i32 @mbrtowc(i32* null, i8* null, i32 0, i8* null)
%95 = icmp eq i32 %94, 0
%96 = zext i1 %95 to i32
%97 = call i32 @assert(i32 %96)
%98 = trunc i64 %13 to i32
%99 = call i32 @memset(i8* %15, i32 204, i32 %98)
%100 = getelementptr inbounds i8, i8* %15, i64 0
store i8 0, i8* %100
%101 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* null)
%102 = icmp eq i32 %101, 0
%103 = zext i1 %102 to i32
%104 = call i32 @assert(i32 %103)
%105 = load i32, i32* %8
%106 = icmp eq i32 %105, 0
%107 = zext i1 %106 to i32
%108 = call i32 @assert(i32 %107)
%109 = call i32 @memset(i8* %6, i32 0, i32 1)
%110 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%111 = icmp eq i32 %110, 0
%112 = zext i1 %111 to i32
%113 = call i32 @assert(i32 %112)
%114 = load i32, i32* %8
%115 = icmp eq i32 %114, 0
%116 = zext i1 %115 to i32
%117 = call i32 @assert(i32 %116)
%118 = call i32 @mbrtowc(i32* null, i8* null, i32 0, i8* null)
%119 = icmp eq i32 %118, 0
%120 = zext i1 %119 to i32
%121 = call i32 @assert(i32 %120)
%122 = getelementptr inbounds i8, i8* %15, i64 0
store i8 65, i8* %122
%123 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* null)
%124 = icmp eq i32 %123, 1
%125 = zext i1 %124 to i32
%126 = call i32 @assert(i32 %125)
%127 = load i32, i32* %8
%128 = icmp eq i32 %127, 65
%129 = zext i1 %128 to i32
%130 = call i32 @assert(i32 %129)
%131 = call i32 @memset(i8* %6, i32 0, i32 1)
%132 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%133 = icmp eq i32 %132, 1
%134 = zext i1 %133 to i32
%135 = call i32 @assert(i32 %134)
%136 = load i32, i32* %8
%137 = icmp eq i32 %136, 65
%138 = zext i1 %137 to i32
%139 = call i32 @assert(i32 %138)
store i32 122, i32* %8
%140 = call i32 @memset(i8* %6, i32 0, i32 1)
%141 = call i32 @mbrtowc(i32* %8, i8* %15, i32 0, i8* %6)
%142 = sext i32 %141 to i64
%143 = icmp eq i64 %142, -2
%144 = zext i1 %143 to i32
%145 = call i32 @assert(i32 %144)
%146 = load i32, i32* %8
%147 = icmp eq i32 %146, 122
%148 = zext i1 %147 to i32
%149 = call i32 @assert(i32 %148)
%150 = trunc i64 %13 to i32
%151 = call i32 @memset(i8* %15, i32 204, i32 %150)
%152 = getelementptr inbounds i8, i8* %15, i64 0
store i8 -93, i8* %152
%153 = getelementptr inbounds i8, i8* %15, i64 1
store i8 0, i8* %153
%154 = call i32 @memset(i8* %6, i32 0, i32 1)
store i32 0, i32* %8
%155 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%156 = sext i32 %155 to i64
%157 = icmp eq i64 %156, -2
%158 = zext i1 %157 to i32
%159 = call i32 @assert(i32 %158)
%160 = getelementptr inbounds i8, i8* %15, i64 1
store i8 -63, i8* %160
%161 = call i32 @memset(i8* %6, i32 0, i32 1)
store i32 0, i32* %8
%162 = call i32 @mbrtowc(i32* %8, i8* %15, i32 2, i8* %6)
%163 = icmp eq i32 %162, 2
%164 = zext i1 %163 to i32
%165 = call i32 @assert(i32 %164)
%166 = load i32, i32* %8
%167 = icmp eq i32 %166, 41921
%168 = zext i1 %167 to i32
%169 = call i32 @assert(i32 %168)
%170 = trunc i64 %13 to i32
%171 = call i32 @memset(i8* %15, i32 204, i32 %170)
%172 = getelementptr inbounds i8, i8* %15, i64 0
store i8 -93, i8* %172
%173 = call i32 @memset(i8* %6, i32 0, i32 1)
store i32 0, i32* %8
%174 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%175 = sext i32 %174 to i64
%176 = icmp eq i64 %175, -2
%177 = zext i1 %176 to i32
%178 = call i32 @assert(i32 %177)
%179 = load i32, i32* %8
%180 = icmp eq i32 %179, 0
%181 = zext i1 %180 to i32
%182 = call i32 @assert(i32 %181)
%183 = getelementptr inbounds i8, i8* %15, i64 0
store i8 -63, i8* %183
%184 = call i32 @mbrtowc(i32* %8, i8* %15, i32 1, i8* %6)
%185 = icmp eq i32 %184, 1
%186 = zext i1 %185 to i32
%187 = call i32 @assert(i32 %186)
%188 = load i32, i32* %8
%189 = icmp eq i32 %188, 41921
%190 = zext i1 %189 to i32
%191 = call i32 @assert(i32 %190)
%192 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
%193 = load i8*, i8** %9
%194 = load i32, i32* %3
ret i32 %194
}

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