#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*/ add_to_string(char *, char const *);
int /*<<< orphan*/ initialize_string(char *);
scalar_t__ strlen(char const *);
void cachebust_filename(char *var, const char *key, const char *hash,
                        const char *ending) {
  initialize_string(var);
  add_to_string(var, key);
  add_to_string(var, ".");
  add_to_string(var, hash);
  if (strlen(ending) > 0) {
    add_to_string(var, ".");
    add_to_string(var, ending);
  }
}


x86 assembly (clang, -O0):
<cachebust_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <initialize_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <add_to_string@plt>
mov    -0x8(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1040 <add_to_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <add_to_string@plt>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    11ab <cachebust_filename+0x7b>
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <add_to_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <add_to_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cachebust_filename>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
call   1050 <initialize_string@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <add_to_string@plt>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1040 <add_to_string@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <add_to_string@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jle    11a0 <cachebust_filename+0x70>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <add_to_string@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <add_to_string@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define void @cachebust_filename(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%9 = load i8*, i8** %5
%10 = call i32 @initialize_string(i8* %9)
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @add_to_string(i8* %11, i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @add_to_string(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %5
%17 = load i8*, i8** %7
%18 = call i32 @add_to_string(i8* %16, i8* %17)
%19 = load i8*, i8** %8
%20 = call i64 @strlen(i8* %19)
%21 = icmp sgt i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %4
%23 = load i8*, i8** %5
%24 = call i32 @add_to_string(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i8*, i8** %5
%26 = load i8*, i8** %8
%27 = call i32 @add_to_string(i8* %25, i8* %26)
br label %28
28: ; preds = %22, %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define void @cachebust_filename(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i32 @initialize_string(i8* %0)
%6 = tail call i32 @add_to_string(i8* %0, i8* %1)
%7 = tail call i32 @add_to_string(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @add_to_string(i8* %0, i8* %2)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = tail call i32 @add_to_string(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @add_to_string(i8* %0, i8* %3)
br label %14
14: ; preds = %11, %4
ret void
}