#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*/ time_t;
typedef scalar_t__ result;

/* Variables and functions */
int /*<<< orphan*/ free(size_t *);
char *template_bake(char const *, size_t, char const **);
int /*<<< orphan*/ util_output(char *, size_t, int, int /*<<< orphan*/);
void template_puts(const char *data, size_t len, const char **subst, int type,
                   time_t mod) {
  char *result = template_bake(data, len, subst);
  util_output(result, ((result) ? ((size_t *)(result)-2)[1] : 0), type, mod);
  ((result) ? free(((size_t *)(result)-2)), (result) = 0, 0 : 0);
}


x86 assembly (clang, -O0):
<template_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <template_bake@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1184 <template_puts+0x54>
mov    -0x28(%rbp),%rax
mov    -0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    118f <template_puts+0x5f>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    118f <template_puts+0x5f>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <util_output@plt>
cmpq   $0x0,-0x28(%rbp)
je     11c7 <template_puts+0x97>
mov    -0x28(%rbp),%rdi
add    $0xfffffffffffffff0,%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
jmp    11cc <template_puts+0x9c>
jmp    11cc <template_puts+0x9c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<template_puts>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%r14d
mov    %ecx,%ebp
call   1040 <template_bake@plt>
test   %rax,%rax
je     1167 <template_puts+0x37>
mov    %rax,%rbx
mov    -0x8(%rax),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1050 <util_output@plt>
add    $0xfffffffffffffff0,%rbx
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <util_output@plt>

LLVM IR (-O0):
define void @template_puts(i8* %0, i64 %1, i8** %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = load i64, i64* %7
%14 = load i8**, i8*** %8
%15 = call i8* @template_bake(i8* %12, i64 %13, i8** %14)
store i8* %15, i8** %11
%16 = load i8*, i8** %11
%17 = load i8*, i8** %11
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %25
19: ; preds = %5
%20 = load i8*, i8** %11
%21 = bitcast i8* %20 to i64*
%22 = getelementptr inbounds i64, i64* %21, i64 -2
%23 = getelementptr inbounds i64, i64* %22, i64 1
%24 = load i64, i64* %23
br label %26
25: ; preds = %5
br label %26
26: ; preds = %25, %19
%27 = phi i64 [ %24, %19 ], [ 0, %25 ]
%28 = load i32, i32* %9
%29 = load i32, i32* %10
%30 = call i32 @util_output(i8* %16, i64 %27, i32 %28, i32 %29)
%31 = load i8*, i8** %11
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %26
%34 = load i8*, i8** %11
%35 = bitcast i8* %34 to i64*
%36 = getelementptr inbounds i64, i64* %35, i64 -2
%37 = call i32 @free(i64* %36)
store i8* null, i8** %11
br label %39
38: ; preds = %26
br label %39
39: ; preds = %38, %33
%40 = phi i32 [ 0, %33 ], [ 0, %38 ]
ret void
}

LLVM IR (-O2):
define void @template_puts(i8* %0, i64 %1, i8** %2, i32 %3, i32 %4) {
%6 = tail call i8* @template_bake(i8* %0, i64 %1, i8** %2)
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 -8
%10 = bitcast i8* %9 to i64*
%11 = load i64, i64* %10
%12 = tail call i32 @util_output(i8* %6, i64 %11, i32 %3, i32 %4)
%13 = getelementptr inbounds i8, i8* %6, i64 -16
%14 = bitcast i8* %13 to i64*
%15 = tail call i32 @free(i64* %14)
br label %18
16: ; preds = %5
%17 = tail call i32 @util_output(i8* null, i64 0, i32 %3, i32 %4)
br label %18
18: ; preds = %16, %8
ret void
}