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

/* Variables and functions */
int /*<<< orphan*/ LC_CTYPE;
int MB_CUR_MAX;
int /*<<< orphan*/ MB_LEN_MAX;
int UCHAR_MAX;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int wctomb(char *, int);
int main(int argc, char *argv[]) {
  size_t len;
  char buf[MB_LEN_MAX + 1];
  printf("1..1\n");
  assert(MB_CUR_MAX == 1);
  assert(wctomb(NULL, L'\0') == 0);
  memset(buf, 0xcc, sizeof(buf));
  len = wctomb(buf, L'\0');
  assert(len == 1);
  assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
  memset(buf, 0xcc, sizeof(buf));
  len = wctomb(buf, L'A');
  assert(len == 1);
  assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
  assert(wctomb(buf, UCHAR_MAX + 1) == -1);
  assert(wctomb(NULL, 0) == 0);
  assert(strcmp(setlocale(LC_CTYPE, "ja_JP.eucJP"), "ja_JP.eucJP") == 0);
  assert(MB_CUR_MAX == 3);
  assert(wctomb(NULL, L'\0') == 0);
  memset(buf, 0xcc, sizeof(buf));
  len = wctomb(buf, L'\0');
  assert(len == 1);
  assert((unsigned char)buf[0] == 0 && (unsigned char)buf[1] == 0xcc);
  memset(buf, 0xcc, sizeof(buf));
  len = wctomb(buf, L'A');
  assert(len == 1);
  assert((unsigned char)buf[0] == 'A' && (unsigned char)buf[1] == 0xcc);
  memset(buf, 0xcc, sizeof(buf));
  len = wctomb(buf, 0xa3c1);
  assert(len == 2);
  assert((unsigned char)buf[0] == 0xa3 && (unsigned char)buf[1] == 0xc1 &&
         (unsigned char)buf[2] == 0xcc);
  printf("ok 1 - wctomb()\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    0x2e4b(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%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,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1080 <wctomb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    1246 <main+0xe6>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    $0x41,%esi
call   1080 <wctomb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x41(%rbp)
jne    12b5 <main+0x155>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
call   1080 <wctomb@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xcf4(%rip),%rsi
call   1070 <setlocale@plt>
mov    %eax,%edi
lea    0xce6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2cbb(%rip),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1080 <wctomb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x42(%rbp)
jne    13c7 <main+0x267>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    $0x41,%esi
call   1080 <wctomb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x41,%ecx
mov    %al,-0x43(%rbp)
jne    1436 <main+0x2d6>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x43(%rbp)
mov    -0x43(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rax
mov    %eax,%edx
mov    $0xcc,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    $0xa3c1,%esi
call   1080 <wctomb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x38(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa3,%ecx
mov    %al,-0x44(%rbp)
jne    14c1 <main+0x361>
mov    -0x38(%rbp),%rax
movzbl 0x1(%rax),%ecx
xor    %eax,%eax
cmp    $0xc1,%ecx
mov    %al,-0x44(%rbp)
jne    14c1 <main+0x361>
mov    -0x38(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0xcc,%eax
sete   %al
mov    %al,-0x44(%rbp)
mov    -0x44(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xb3d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%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
push   %rax
mov    0x2e53(%rip),%rax
mov    (%rax),%r14d
add    $0x1,%r14d
mov    %rsp,%r12
lea    0xf(%r14),%r13
and    $0xfffffffffffffff0,%r13
mov    %r12,%rbx
sub    %r13,%rbx
mov    %rbx,%rsp
neg    %r13
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e52(%rip),%rax
xor    %edi,%edi
cmpl   $0x1,(%rax)
sete   %dil
call   1060 <assert@plt>
xor    %r15d,%r15d
xor    %edi,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x0,(%r12,%r13,1)
mov    $0x0,%edi
jne    120b <main+0xab>
xor    %edi,%edi
cmpb   $0xcc,0x1(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x41,(%rbx)
jne    124b <main+0xeb>
xor    %r15d,%r15d
cmpb   $0xcc,0x1(%rbx)
sete   %r15b
mov    %r15d,%edi
call   1060 <assert@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    %rbx,%rdi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1060 <assert@plt>
xor    %r15d,%r15d
xor    %edi,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%r12
mov    %r12,%rsi
call   1070 <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    0x2d31(%rip),%rax
cmpl   $0x3,(%rax)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x0,(%rbx)
mov    $0x0,%edi
jne    1325 <main+0x1c5>
xor    %edi,%edi
cmpb   $0xcc,0x1(%rbx)
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x41,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
cmpb   $0x41,(%rbx)
jne    1365 <main+0x205>
xor    %r15d,%r15d
cmpb   $0xcc,0x1(%rbx)
sete   %r15b
mov    %r15d,%edi
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0xcc,%esi
mov    %r14d,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0xa3c1,%esi
call   1080 <wctomb@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpb   $0xa3,(%rbx)
jne    13af <main+0x24f>
cmpb   $0xc1,0x1(%rbx)
jne    13af <main+0x24f>
xor    %edi,%edi
cmpb   $0xcc,0x2(%rbx)
sete   %dil
call   1060 <assert@plt>
lea    0xc56(%rip),%rdi
call   1030 <puts@plt>
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
@LC_CTYPE = global i32 0
@.str.1 = [12 x i8] c"ja_JP.eucJP\00"
@.str.2 = [17 x i8] c"ok 1 - wctomb()\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @MB_LEN_MAX
%10 = add nsw i32 %9, 1
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i8, i64 %11
store i64 %11, i64* %8
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @MB_CUR_MAX
%16 = icmp eq i32 %15, 1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @wctomb(i8* null, i32 0)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = trunc i64 %11 to i32
%24 = call i32 @memset(i8* %13, i32 204, i32 %23)
%25 = call i32 @wctomb(i8* %13, i32 0)
%26 = sext i32 %25 to i64
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 1
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds i8, i8* %13, i64 0
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %2
%36 = getelementptr inbounds i8, i8* %13, i64 1
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = icmp eq i32 %38, 204
br label %40
40: ; preds = %35, %2
%41 = phi i1 [ false, %2 ], [ %39, %35 ]
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = trunc i64 %11 to i32
%45 = call i32 @memset(i8* %13, i32 204, i32 %44)
%46 = call i32 @wctomb(i8* %13, i32 65)
%47 = sext i32 %46 to i64
store i64 %47, i64* %6
%48 = load i64, i64* %6
%49 = icmp eq i64 %48, 1
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = getelementptr inbounds i8, i8* %13, i64 0
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = icmp eq i32 %54, 65
br i1 %55, label %56, label %61
56: ; preds = %40
%57 = getelementptr inbounds i8, i8* %13, i64 1
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = icmp eq i32 %59, 204
br label %61
61: ; preds = %56, %40
%62 = phi i1 [ false, %40 ], [ %60, %56 ]
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i32, i32* @UCHAR_MAX
%66 = add nsw i32 %65, 1
%67 = call i32 @wctomb(i8* %13, i32 %66)
%68 = icmp eq i32 %67, -1
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = call i32 @wctomb(i8* null, i32 0)
%72 = icmp eq i32 %71, 0
%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 @wctomb(i8* null, i32 0)
%86 = icmp eq i32 %85, 0
%87 = zext i1 %86 to i32
%88 = call i32 @assert(i32 %87)
%89 = trunc i64 %11 to i32
%90 = call i32 @memset(i8* %13, i32 204, i32 %89)
%91 = call i32 @wctomb(i8* %13, i32 0)
%92 = sext i32 %91 to i64
store i64 %92, i64* %6
%93 = load i64, i64* %6
%94 = icmp eq i64 %93, 1
%95 = zext i1 %94 to i32
%96 = call i32 @assert(i32 %95)
%97 = getelementptr inbounds i8, i8* %13, i64 0
%98 = load i8, i8* %97
%99 = zext i8 %98 to i32
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %61
%102 = getelementptr inbounds i8, i8* %13, i64 1
%103 = load i8, i8* %102
%104 = zext i8 %103 to i32
%105 = icmp eq i32 %104, 204
br label %106
106: ; preds = %101, %61
%107 = phi i1 [ false, %61 ], [ %105, %101 ]
%108 = zext i1 %107 to i32
%109 = call i32 @assert(i32 %108)
%110 = trunc i64 %11 to i32
%111 = call i32 @memset(i8* %13, i32 204, i32 %110)
%112 = call i32 @wctomb(i8* %13, i32 65)
%113 = sext i32 %112 to i64
store i64 %113, i64* %6
%114 = load i64, i64* %6
%115 = icmp eq i64 %114, 1
%116 = zext i1 %115 to i32
%117 = call i32 @assert(i32 %116)
%118 = getelementptr inbounds i8, i8* %13, i64 0
%119 = load i8, i8* %118
%120 = zext i8 %119 to i32
%121 = icmp eq i32 %120, 65
br i1 %121, label %122, label %127
122: ; preds = %106
%123 = getelementptr inbounds i8, i8* %13, i64 1
%124 = load i8, i8* %123
%125 = zext i8 %124 to i32
%126 = icmp eq i32 %125, 204
br label %127
127: ; preds = %122, %106
%128 = phi i1 [ false, %106 ], [ %126, %122 ]
%129 = zext i1 %128 to i32
%130 = call i32 @assert(i32 %129)
%131 = trunc i64 %11 to i32
%132 = call i32 @memset(i8* %13, i32 204, i32 %131)
%133 = call i32 @wctomb(i8* %13, i32 41921)
%134 = sext i32 %133 to i64
store i64 %134, i64* %6
%135 = load i64, i64* %6
%136 = icmp eq i64 %135, 2
%137 = zext i1 %136 to i32
%138 = call i32 @assert(i32 %137)
%139 = getelementptr inbounds i8, i8* %13, i64 0
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = icmp eq i32 %141, 163
br i1 %142, label %143, label %153
143: ; preds = %127
%144 = getelementptr inbounds i8, i8* %13, i64 1
%145 = load i8, i8* %144
%146 = zext i8 %145 to i32
%147 = icmp eq i32 %146, 193
br i1 %147, label %148, label %153
148: ; preds = %143
%149 = getelementptr inbounds i8, i8* %13, i64 2
%150 = load i8, i8* %149
%151 = zext i8 %150 to i32
%152 = icmp eq i32 %151, 204
br label %153
153: ; preds = %148, %143, %127
%154 = phi i1 [ false, %143 ], [ false, %127 ], [ %152, %148 ]
%155 = zext i1 %154 to i32
%156 = call i32 @assert(i32 %155)
%157 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
%158 = load i8*, i8** %7
%159 = load i32, i32* %3
ret i32 %159
}

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