#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*/ errx(int, char *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ template_render(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int, int /*<<< orphan*/ const **);
int /*<<< orphan*/ wprintf(char *, int /*<<< orphan*/ *);
void prwd(wchar_t *t) {
  wchar_t output[1024];
  const wchar_t *errstr;
  template_render(t, output, 1024, &errstr);
  if (errstr != NULL)
    errx(1, "template error: %ls", errstr);
  wprintf(L"%ls\n", output);
}


x86 assembly (clang, -O0):
<prwd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
mov    $0x400,%edx
lea    -0x1018(%rbp),%rcx
call   1040 <template_render@plt>
cmpq   $0x0,-0x1018(%rbp)
je     1181 <prwd+0x51>
mov    -0x1018(%rbp),%rdx
mov    $0x1,%edi
lea    0xe84(%rip),%rsi
call   1030 <errx@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1050 <wprintf@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prwd>:
sub    $0x1018,%rsp
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rcx
mov    $0x400,%edx
call   1040 <template_render@plt>
mov    0x8(%rsp),%rdx
test   %rdx,%rdx
je     1166 <prwd+0x36>
lea    0xea4(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
lea    0xea7(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <wprintf@plt>
add    $0x1018,%rsp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"template error: %ls\00"
@.str.1 = [5 x i32] [i32 37, i32 108, i32 115, i32 10, i32 0]
define void @prwd(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i32]
%4 = alloca i32*
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
%7 = call i32 @template_render(i32* %5, i32* %6, i32 1024, i32** %4)
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32*, i32** %4
%12 = call i32 @errx(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %11)
br label %13
13: ; preds = %10, %1
%14 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
%15 = call i32 @wprintf(i8* bitcast ([5 x i32]* @.str.1 to i8*), i32* %14)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"template error: %ls\00"
@.str.1 = [5 x i32] [i32 37, i32 108, i32 115, i32 10, i32 0]
define void @prwd(i32* %0) {
%2 = alloca [1024 x i32]
%3 = alloca i32*
%4 = bitcast [1024 x i32]* %2 to i8*
%5 = bitcast i32** %3 to i8*
%6 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 0
%7 = call i32 @template_render(i32* %0, i32* %6, i32 1024, i32** %3)
%8 = load i32*, i32** %3
%9 = icmp eq i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = call i32 @errx(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %8)
br label %12
12: ; preds = %10, %1
%13 = call i32 @wprintf(i8* bitcast ([5 x i32]* @.str.1 to i8*), i32* %6)
ret void
}