#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
char *render_template_file2(char *, int, char const **);
int main() {
  const char *data[] = {
      "ph1",
      "awesome",
      "ph2",
      " is running",
  };
  char *rendered = render_template_file2("spec/templates/basic.txt", 2, data);
  printf("%s", rendered);
  if (rendered)
    free(rendered);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2cba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cb1(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rdx
lea    0xea6(%rip),%rdi
mov    $0x2,%esi
call   1050 <render_template_file2@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
je     11a8 <main+0x78>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0x2cd4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2cb8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xec9(%rip),%rdi
mov    %rsp,%rdx
mov    $0x2,%esi
call   1050 <render_template_file2@plt>
mov    %rax,%rbx
lea    0xecb(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
test   %rbx,%rbx
je     117f <main+0x4f>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ph1\00"
@.str.1 = [8 x i8] c"awesome\00"
@.str.2 = [4 x i8] c"ph2\00"
@.str.3 = [12 x i8] c" is running\00"
@__const.main.data = [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [25 x i8] c"spec/templates/basic.txt\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8*]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [4 x i8*]* %2 to i8*
%5 = getelementptr inbounds [4 x i8*], [4 x i8*]* %2, i64 0, i64 0
%6 = call i8* @render_template_file2(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 2, i8** %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i8*, i8** %3
%13 = call i32 @free(i8* %12)
br label %14
14: ; preds = %11, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"ph1\00"
@.str.1 = [8 x i8] c"awesome\00"
@.str.2 = [4 x i8] c"ph2\00"
@.str.3 = [12 x i8] c" is running\00"
@__const.main.data = [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [25 x i8] c"spec/templates/basic.txt\00"
@.str.5 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [4 x i8*]
%2 = bitcast [4 x i8*]* %1 to i8*
%3 = getelementptr inbounds [4 x i8*], [4 x i8*]* %1, i64 0, i64 0
%4 = call i8* @render_template_file2(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 2, i8** %3)
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%6 = icmp eq i8* %4, null
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @free(i8* %4)
br label %9
9: ; preds = %7, %0
ret i32 0
}