#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ wchar_t;

/* Variables and functions */
int /*<<< orphan*/ MB_CUR_MAX;
int mblen(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ mbtowc(int /*<<< orphan*/ *, char *, int);
int strlen(char *);
int /*<<< orphan*/ wprintf(char *, int /*<<< orphan*/ *);
int main() {
  char *str = "This is yiibai.com";
  wchar_t mb[100];
  int len;
  len = mblen(NULL, MB_CUR_MAX);
  mbtowc(mb, str, len * strlen(str));
  wprintf(L"%ls \n", mb);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <mblen@plt>
mov    %eax,-0x1a4(%rbp)
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x1b8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1bc(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1bc(%rbp),%edx
mov    -0x1b8(%rbp),%rdi
mov    -0x1b0(%rbp),%rsi
imul   %eax,%edx
call   1050 <mbtowc@plt>
lea    -0x1a0(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1060 <wprintf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x190,%rsp
mov    0x2ea5(%rip),%rax
mov    (%rax),%esi
xor    %edi,%edi
call   1030 <mblen@plt>
mov    %eax,%ebx
lea    0xe9b(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
imul   %eax,%ebx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <mbtowc@plt>
lea    0xe8d(%rip),%rdi
mov    %r15,%rsi
call   1060 <wprintf@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"This is yiibai.com\00"
@MB_CUR_MAX = global i32 0
@.str.1 = [6 x i32] [i32 37, i32 108, i32 115, i32 32, i32 10, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [100 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i32, i32* @MB_CUR_MAX
%6 = call i32 @mblen(i32* null, i32 %5)
store i32 %6, i32* %4
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%8 = load i8*, i8** %2
%9 = load i32, i32* %4
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = mul nsw i32 %9, %11
%13 = call i32 @mbtowc(i32* %7, i8* %8, i32 %12)
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%15 = call i32 @wprintf(i8* bitcast ([6 x i32]* @.str.1 to i8*), i32* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"This is yiibai.com\00"
@MB_CUR_MAX = global i32 0
@.str.1 = [6 x i32] [i32 37, i32 108, i32 115, i32 32, i32 10, i32 0]
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = load i32, i32* @MB_CUR_MAX
%4 = tail call i32 @mblen(i32* null, i32 %3)
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = mul nsw i32 %6, %4
%8 = call i32 @mbtowc(i32* %5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @wprintf(i8* bitcast ([6 x i32]* @.str.1 to i8*), i32* %5)
ret i32 0
}