#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 wchar_t;

/* Variables and functions */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
size_t wcstombs(char *, char *, int);
int main() {
  size_t ret;
  char *MB = (char *)malloc(50);
  wchar_t *WC = L"http://www.yiibai.com/html";
  ret = wcstombs(MB, WC, 50);
  printf("Characters converted = %u\n", ret);
  printf("Multibyte character = %s\n", MB);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x32,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x32,%edx
call   1050 <wcstombs@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x32,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xebb(%rip),%rsi
mov    %rax,%rdi
mov    $0x32,%edx
call   1050 <wcstombs@plt>
lea    0xf13(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf1d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i32] [i32 104, i32 116, i32 116, i32 112, i32 58, i32 47, i32 47, i32 119, i32 119, i32 119, i32 46, i32 121, i32 105, i32 105, i32 98, i32 97, i32 105, i32 46, i32 99, i32 111, i32 109, i32 47, i32 104, i32 116, i32 109, i32 108, i32 0]
@.str.1 = [27 x i8] c"Characters converted = %u\0A\00"
@.str.2 = [26 x i8] c"Multibyte character = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i64 @malloc(i32 50)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
store i8* bitcast ([27 x i32]* @.str to i8*), i8** %4
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = call i64 @wcstombs(i8* %7, i8* %8, i32 50)
store i64 %9, i64* %2
%10 = load i64, i64* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = load i8*, i8** %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i32] [i32 104, i32 116, i32 116, i32 112, i32 58, i32 47, i32 47, i32 119, i32 119, i32 119, i32 46, i32 121, i32 105, i32 105, i32 98, i32 97, i32 105, i32 46, i32 99, i32 111, i32 109, i32 47, i32 104, i32 116, i32 109, i32 108, i32 0]
@.str.1 = [27 x i8] c"Characters converted = %u\0A\00"
@.str.2 = [26 x i8] c"Multibyte character = %s\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 50)
%2 = inttoptr i64 %1 to i8*
%3 = tail call i64 @wcstombs(i8* %2, i8* bitcast ([27 x i32]* @.str to i8*), i32 50)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret i32 0
}