#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 char *wint_t;
typedef int wchar_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
char *MB_CUR_MAX;
int mbstowcs(int *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
char *setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
scalar_t__ wcscmp(int *, char *);
int wcslen(int *);
int wcstombs(char *, int *, int);
scalar_t__ wctomb(char *, int);
int main(void) {
  int test = 0;
  int idx = 0;
  char buf[100], *pchar;
  wchar_t tmp[10];
  wchar_t tmp1[] = {L'W', L'o', L'r', L'l', L'd', L'\0'};
  char str[] = "Hello";
  int result = 0;
  pchar = setlocale(LC_ALL, "");
  printf("locale : %s\n", pchar);
  printf("MB_CUR_MAX %Zd\n", MB_CUR_MAX);
  puts("---- test 1 ------");
  test = mbstowcs(tmp, str, (strlen(str) + 1) * sizeof(char));
  printf("size of string by mbstowcs %d\n", test);
  if (test != strlen(str))
    result = 1;
  idx += wctomb(&buf[0], tmp[0]);
  idx += wctomb(&buf[idx], tmp[1]);
  buf[idx] = 0;
  printf("orig string %s\n", str);
  printf("string by wctomb %s\n", buf);
  printf("string by %%C %C", (wint_t)tmp[0]);
  if (tmp[0] != L'H')
    result = 1;
  printf("%C\n", (wint_t)tmp[1]);
  if (tmp[1] != L'e')
    result = 1;
  printf("string by %%S %S\n", tmp);
  if (wcscmp(tmp, L"Hello") != 0)
    result = 1;
  puts("---- test 2 ------");
  printf("wchar string %S\n", tmp1);
  printf("wchar %C\n", (wint_t)tmp1[0]);
  test = wcstombs(buf, tmp1, (wcslen(tmp1) + 1) * sizeof(wchar_t));
  printf("size of string by wcstombs %d\n", test);
  if (test != wcslen(tmp1))
    result = 1;
  test = wcslen(tmp1);
  printf("size of string by wcslen %d\n", test);
  printf("char %s\n", buf);
  if (strcmp(buf, "World") != 0)
    result = 1;
  puts("------------------");
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xe39(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    0xe33(%rip),%rax
mov    %rax,-0xb8(%rbp)
mov    0xe2d(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe28(%rip),%eax
mov    %eax,-0xc6(%rbp)
mov    0xe1f(%rip),%ax
mov    %ax,-0xc2(%rbp)
movl   $0x0,-0xcc(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
lea    0xec4(%rip),%rsi
call   10a0 <setlocale@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%rsi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde3(%rip),%rdi
call   1040 <puts@plt>
lea    -0xa0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0xc6(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0xc6(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xe0(%rbp),%rdi
mov    -0xd8(%rbp),%rsi
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edx
call   1050 <mbstowcs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xd0(%rbp)
lea    -0xc6(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0xd0(%rbp),%eax
cmp    %ecx,%eax
je     12e6 <main+0x146>
movl   $0x1,-0xcc(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0xa0(%rbp),%esi
call   10b0 <wctomb@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
lea    -0x70(%rbp),%rdi
add    %rax,%rdi
mov    -0x9c(%rbp),%esi
call   10b0 <wctomb@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0xc6(%rbp),%rsi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movslq -0xa0(%rbp),%rsi
lea    0xd2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x48,-0xa0(%rbp)
je     1381 <main+0x1e1>
movl   $0x1,-0xcc(%rbp)
movslq -0x9c(%rbp),%rsi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x65,-0x9c(%rbp)
je     13ad <main+0x20d>
movl   $0x1,-0xcc(%rbp)
lea    -0xa0(%rbp),%rsi
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1030 <wcscmp@plt>
cmp    $0x0,%rax
je     13e9 <main+0x249>
movl   $0x1,-0xcc(%rbp)
lea    0xcc5(%rip),%rdi
call   1040 <puts@plt>
lea    -0xc0(%rbp),%rsi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movslq -0xc0(%rbp),%rsi
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0xf8(%rbp)
lea    -0xc0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    -0xc0(%rbp),%rdi
call   1080 <wcslen@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rsi
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edx
call   10c0 <wcstombs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xc74(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xe4(%rbp)
lea    -0xc0(%rbp),%rdi
call   1080 <wcslen@plt>
mov    %eax,%ecx
mov    -0xe4(%rbp),%eax
cmp    %ecx,%eax
je     14a5 <main+0x305>
movl   $0x1,-0xcc(%rbp)
lea    -0xc0(%rbp),%rdi
call   1080 <wcslen@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xc44(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xc4f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xc46(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
je     14fb <main+0x35b>
movl   $0x1,-0xcc(%rbp)
lea    0xc2c(%rip),%rdi
call   1040 <puts@plt>
mov    -0xcc(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    0xe58(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xe3c(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xefa(%rip),%rsi
call   10a0 <setlocale@plt>
lea    0xe2a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%rsi
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe1e(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <mbstowcs@plt>
mov    %eax,%ebp
lea    0xe03(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
setne  0x7(%rsp)
mov    0x10(%rsp),%esi
lea    0x60(%rsp),%r15
mov    %r15,%rdi
call   10b0 <wctomb@plt>
movslq %eax,%rbp
lea    (%rsp,%rbp,1),%rdi
add    $0x60,%rdi
mov    0x14(%rsp),%esi
call   10b0 <wctomb@plt>
add    %eax,%ebp
movslq %ebp,%rax
movb   $0x0,0x60(%rsp,%rax,1)
lea    0xdd4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd3(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movslq 0x10(%rsp),%rsi
lea    0xdd2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmpl   $0x48,0x10(%rsp)
setne  %bl
movslq 0x14(%rsp),%rsi
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmpl   $0x65,0x14(%rsp)
setne  %r13b
lea    0xdb1(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe41(%rip),%rsi
mov    %r14,%rdi
call   1030 <wcscmp@plt>
test   %rax,%rax
setne  %r12b
lea    0xd9c(%rip),%rdi
call   1040 <puts@plt>
lea    0xda3(%rip),%rdi
lea    0x40(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movslq 0x40(%rsp),%rsi
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1080 <wcslen@plt>
lea    0x4(,%rax,4),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   10c0 <wcstombs@plt>
mov    %eax,%ebp
lea    0xd79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1080 <wcslen@plt>
cmp    %eax,%ebp
setne  %bpl
lea    0xd7a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd87(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd7f(%rip),%rsi
mov    %r15,%rdi
call   1090 <strcmp@plt>
test   %rax,%rax
setne  %al
or     %r12b,%al
or     %bpl,%al
or     %r13b,%al
or     0x7(%rsp),%bl
or     %al,%bl
movzbl %bl,%ebx
lea    0xd5e(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.tmp1 = [6 x i32] [i32 87, i32 111, i32 114, i32 108, i32 100, i32 0]
@__const.main.str = [6 x i8] c"Hello\00"
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [13 x i8] c"locale : %s\0A\00"
@.str.2 = [16 x i8] c"MB_CUR_MAX %Zd\0A\00"
@MB_CUR_MAX = global i8* null
@.str.3 = [19 x i8] c"---- test 1 ------\00"
@.str.4 = [31 x i8] c"size of string by mbstowcs %d\0A\00"
@.str.5 = [16 x i8] c"orig string %s\0A\00"
@.str.6 = [21 x i8] c"string by wctomb %s\0A\00"
@.str.7 = [17 x i8] c"string by %%C %C\00"
@.str.8 = [4 x i8] c"%C\0A\00"
@.str.9 = [18 x i8] c"string by %%S %S\0A\00"
@.str.10 = [6 x i32] [i32 72, i32 101, i32 108, i32 108, i32 111, i32 0]
@.str.11 = [19 x i8] c"---- test 2 ------\00"
@.str.12 = [17 x i8] c"wchar string %S\0A\00"
@.str.13 = [10 x i8] c"wchar %C\0A\00"
@.str.14 = [31 x i8] c"size of string by wcstombs %d\0A\00"
@.str.15 = [29 x i8] c"size of string by wcslen %d\0A\00"
@.str.16 = [9 x i8] c"char %s\0A\00"
@.str.17 = [6 x i8] c"World\00"
@.str.18 = [19 x i8] c"------------------\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = alloca i8*
%6 = alloca [10 x i32]
%7 = alloca [6 x i32]
%8 = alloca [6 x i8]
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%10 = bitcast [6 x i32]* %7 to i8*
%11 = bitcast [6 x i8]* %8 to i8*
store i32 0, i32* %9
%12 = load i32, i32* @LC_ALL
%13 = call i8* @setlocale(i32 %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** @MB_CUR_MAX
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 1
%26 = trunc i64 %25 to i32
%27 = call i32 @mbstowcs(i32* %19, i8* %20, i32 %26)
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%32 = call i32 @strlen(i8* %31)
%33 = icmp ne i32 %30, %32
br i1 %33, label %34, label %35
34: ; preds = %0
store i32 1, i32* %9
br label %35
35: ; preds = %34, %0
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%38 = load i32, i32* %37
%39 = call i64 @wctomb(i8* %36, i32 %38)
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = add nsw i64 %41, %39
%43 = trunc i64 %42 to i32
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %45
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i64 @wctomb(i8* %46, i32 %48)
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = add nsw i64 %51, %49
%53 = trunc i64 %52 to i32
store i32 %53, i32* %3
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %57)
%59 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %59)
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%62 = load i32, i32* %61
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i8*
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %64)
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%67 = load i32, i32* %66
%68 = icmp ne i32 %67, 72
br i1 %68, label %69, label %70
69: ; preds = %35
store i32 1, i32* %9
br label %70
70: ; preds = %69, %35
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 1
%72 = load i32, i32* %71
%73 = sext i32 %72 to i64
%74 = inttoptr i64 %73 to i8*
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %74)
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 1
%77 = load i32, i32* %76
%78 = icmp ne i32 %77, 101
br i1 %78, label %79, label %80
79: ; preds = %70
store i32 1, i32* %9
br label %80
80: ; preds = %79, %70
%81 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32* %81)
%83 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%84 = call i64 @wcscmp(i32* %83, i8* bitcast ([6 x i32]* @.str.10 to i8*))
%85 = icmp ne i64 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %80
store i32 1, i32* %9
br label %87
87: ; preds = %86, %80
%88 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%89 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32* %89)
%91 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%92 = load i32, i32* %91
%93 = sext i32 %92 to i64
%94 = inttoptr i64 %93 to i8*
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* %94)
%96 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%97 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%98 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%99 = call i32 @wcslen(i32* %98)
%100 = add nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = mul i64 %101, 4
%103 = trunc i64 %102 to i32
%104 = call i32 @wcstombs(i8* %96, i32* %97, i32 %103)
store i32 %104, i32* %2
%105 = load i32, i32* %2
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %2
%108 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%109 = call i32 @wcslen(i32* %108)
%110 = icmp ne i32 %107, %109
br i1 %110, label %111, label %112
111: ; preds = %87
store i32 1, i32* %9
br label %112
112: ; preds = %111, %87
%113 = getelementptr inbounds [6 x i32], [6 x i32]* %7, i64 0, i64 0
%114 = call i32 @wcslen(i32* %113)
store i32 %114, i32* %2
%115 = load i32, i32* %2
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %115)
%117 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0), i8* %117)
%119 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%120 = call i64 @strcmp(i8* %119, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%121 = icmp ne i64 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %112
store i32 1, i32* %9
br label %123
123: ; preds = %122, %112
%124 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0))
%125 = load i32, i32* %9
ret i32 %125
}

LLVM IR (-O2):
@__const.main.tmp1 = [6 x i32] [i32 87, i32 111, i32 114, i32 108, i32 100, i32 0]
@__const.main.str = [6 x i8] c"Hello\00"
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [13 x i8] c"locale : %s\0A\00"
@.str.2 = [16 x i8] c"MB_CUR_MAX %Zd\0A\00"
@MB_CUR_MAX = global i8* null
@.str.3 = [19 x i8] c"---- test 1 ------\00"
@.str.4 = [31 x i8] c"size of string by mbstowcs %d\0A\00"
@.str.5 = [16 x i8] c"orig string %s\0A\00"
@.str.6 = [21 x i8] c"string by wctomb %s\0A\00"
@.str.7 = [17 x i8] c"string by %%C %C\00"
@.str.8 = [4 x i8] c"%C\0A\00"
@.str.9 = [18 x i8] c"string by %%S %S\0A\00"
@.str.10 = [6 x i32] [i32 72, i32 101, i32 108, i32 108, i32 111, i32 0]
@.str.11 = [19 x i8] c"---- test 2 ------\00"
@.str.12 = [17 x i8] c"wchar string %S\0A\00"
@.str.13 = [10 x i8] c"wchar %C\0A\00"
@.str.14 = [31 x i8] c"size of string by wcstombs %d\0A\00"
@.str.15 = [29 x i8] c"size of string by wcslen %d\0A\00"
@.str.16 = [9 x i8] c"char %s\0A\00"
@.str.17 = [6 x i8] c"World\00"
@.str.18 = [19 x i8] c"------------------\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [10 x i32]
%3 = alloca [6 x i32]
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = bitcast [10 x i32]* %2 to i8*
%7 = bitcast [6 x i32]* %3 to i8*
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @LC_ALL
%10 = tail call i8* @setlocale(i32 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** @MB_CUR_MAX
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %8)
%17 = add nsw i32 %16, 1
%18 = call i32 @mbstowcs(i32* %15, i8* %8, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = call i32 @strlen(i8* %8)
%21 = icmp ne i32 %18, %20
%22 = load i32, i32* %15
%23 = call i64 @wctomb(i8* %5, i32 %22)
%24 = shl i64 %23, 32
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i64 @wctomb(i8* %26, i32 %28)
%30 = add i64 %29, %23
%31 = shl i64 %30, 32
%32 = ashr exact i64 %31, 32
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%36 = load i32, i32* %15
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i8*
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %38)
%40 = load i32, i32* %15
%41 = icmp ne i32 %40, 72
%42 = load i32, i32* %27
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i8*
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %44)
%46 = load i32, i32* %27
%47 = icmp ne i32 %46, 101
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32* %15)
%49 = call i64 @wcscmp(i32* %15, i8* bitcast ([6 x i32]* @.str.10 to i8*))
%50 = icmp ne i64 %49, 0
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0))
%52 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), i32* %52)
%54 = load i32, i32* %52
%55 = sext i32 %54 to i64
%56 = inttoptr i64 %55 to i8*
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i8* %56)
%58 = call i32 @wcslen(i32* %52)
%59 = shl i32 %58, 2
%60 = add i32 %59, 4
%61 = call i32 @wcstombs(i8* %5, i32* %52, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %61)
%63 = call i32 @wcslen(i32* %52)
%64 = icmp ne i32 %61, %63
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.15, i64 0, i64 0), i32 %63)
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.16, i64 0, i64 0), i8* %5)
%67 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0))
%68 = icmp ne i64 %67, 0
%69 = or i1 %64, %68
%70 = select i1 %69, i1 true, i1 %50
%71 = select i1 %70, i1 true, i1 %47
%72 = select i1 %71, i1 true, i1 %41
%73 = select i1 %72, i1 true, i1 %21
%74 = zext i1 %73 to i32
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.18, i64 0, i64 0))
ret i32 %74
}