#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;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *);
int waddstr(int /*<<< orphan*/ *, char *);
char *wcs_duplicate_as_mbs(int /*<<< orphan*/ const *);
int /*<<< orphan*/ xfree(char *);
int waddwcs(WINDOW *win, const wchar_t *str) {
  int ret;
  char *mbs;
  mbs = wcs_duplicate_as_mbs(str);
  if (mbs == NULL) {
    err(EXIT_FAILURE, "waddwcs:wcs_duplicate_as_mbs");
  }
  ret = waddstr(win, mbs);
  xfree(mbs);
  return (ret);
}


x86 assembly (clang, -O0):
<waddwcs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <wcs_duplicate_as_mbs@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117d <waddwcs+0x3d>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1060 <err@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <waddstr@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <xfree@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<waddwcs>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <wcs_duplicate_as_mbs@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116c <waddwcs+0x2c>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1060 <err@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <waddstr@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <xfree@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [29 x i8] c"waddwcs:wcs_duplicate_as_mbs\00"
define i32 @waddwcs(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %4
%8 = call i8* @wcs_duplicate_as_mbs(i32* %7)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @err(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = load i32*, i32** %3
%16 = load i8*, i8** %6
%17 = call i32 @waddstr(i32* %15, i8* %16)
store i32 %17, i32* %5
%18 = load i8*, i8** %6
%19 = call i32 @xfree(i8* %18)
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [29 x i8] c"waddwcs:wcs_duplicate_as_mbs\00"
define i32 @waddwcs(i32* %0, i32* %1) {
%3 = tail call i8* @wcs_duplicate_as_mbs(i32* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @err(i32 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = tail call i32 @waddstr(i32* %0, i8* %3)
%10 = tail call i32 @xfree(i8* %3)
ret i32 %9
}