#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 *);
char *read_file_contents(char const *);
char *render_template(char *, int, char const **, char const **);
char *render_template_file(const char *filename, int len, const char *keys[],
                           const char *values[]) {
  char *contents = read_file_contents(filename);
  if (!contents)
    return NULL;
  char *rendered = render_template(contents, len, keys, values);
  free(contents);
  return rendered;
}


x86 assembly (clang, -O0):
<render_template_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <read_file_contents@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116c <render_template_file+0x3c>
movq   $0x0,-0x8(%rbp)
jmp    1195 <render_template_file+0x65>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <render_template@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<render_template_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
call   1040 <read_file_contents@plt>
test   %rax,%rax
je     116c <render_template_file+0x3c>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <render_template@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
jmp    116e <render_template_file+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @render_template_file(i8* %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
%12 = load i8*, i8** %6
%13 = call i8* @read_file_contents(i8* %12)
store i8* %13, i8** %10
%14 = load i8*, i8** %10
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %4
store i8* null, i8** %5
br label %26
17: ; preds = %4
%18 = load i8*, i8** %10
%19 = load i32, i32* %7
%20 = load i8**, i8*** %8
%21 = load i8**, i8*** %9
%22 = call i8* @render_template(i8* %18, i32 %19, i8** %20, i8** %21)
store i8* %22, i8** %11
%23 = load i8*, i8** %10
%24 = call i32 @free(i8* %23)
%25 = load i8*, i8** %11
store i8* %25, i8** %5
br label %26
26: ; preds = %17, %16
%27 = load i8*, i8** %5
ret i8* %27
}

LLVM IR (-O2):
define i8* @render_template_file(i8* %0, i32 %1, i8** %2, i8** %3) {
%5 = tail call i8* @read_file_contents(i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i8* @render_template(i8* %5, i32 %1, i8** %2, i8** %3)
%9 = tail call i32 @free(i8* %5)
br label %10
10: ; preds = %4, %7
%11 = phi i8* [ %8, %7 ], [ null, %4 ]
ret i8* %11
}