#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 template_render(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                    int /*<<< orphan*/ const **);
int /*<<< orphan*/ wprintf(char *, int /*<<< orphan*/ *);
void prwd_template(wchar_t *t) {
  wchar_t output[1024];
  int i;
  const wchar_t *errstr;
  i = 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_template>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
mov    $0x400,%edx
lea    -0x1020(%rbp),%rcx
call   1040 <template_render@plt>
mov    %eax,-0x1014(%rbp)
cmpq   $0x0,-0x1020(%rbp)
je     1187 <prwd_template+0x57>
mov    -0x1020(%rbp),%rdx
mov    $0x1,%edi
lea    0xe7e(%rip),%rsi
call   1030 <errx@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1050 <wprintf@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prwd_template>:
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_template+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_template(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i32]
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
%8 = call i32 @template_render(i32* %6, i32* %7, i32 1024, i32** %5)
store i32 %8, i32* %4
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32*, i32** %5
%13 = call i32 @errx(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %14
14: ; preds = %11, %1
%15 = getelementptr inbounds [1024 x i32], [1024 x i32]* %3, i64 0, i64 0
%16 = call i32 @wprintf(i8* bitcast ([5 x i32]* @.str.1 to i8*), i32* %15)
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_template(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
}