#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 */
scalar_t__ malloc(int);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *blossom_template_base_new(const char *template_name,
                                const char *flavour) {
  int l1, l2, len;
  char *template_base, *s;
  if (!template_name || !flavour)
    return NULL;
  l1 = strlen(template_name);
  l2 = strlen(flavour);
  len = l1 + l2 + 2;
  s = template_base = (char *)malloc(len);
  strncpy(s, template_name, l1);
  s += l1;
  *s = '.';
  s++;
  strncpy(s, flavour, l2);
  s += l2;
  *s = '\0';
  return template_base;
}


x86 assembly (clang, -O0):
<blossom_template_base_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <blossom_template_base_new+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1163 <blossom_template_base_new+0x33>
movq   $0x0,-0x8(%rbp)
jmp    11fb <blossom_template_base_new+0xcb>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x2e,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blossom_template_base_new>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     11a2 <blossom_template_base_new+0x72>
mov    %rsi,%r14
test   %rsi,%rsi
je     11a2 <blossom_template_base_new+0x72>
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
lea    (%r12,%r13,1),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movslq %r12d,%rax
lea    (%rbx,%rax,1),%r15
movb   $0x2e,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
movslq %r13d,%rax
movb   $0x0,0x1(%rax,%r15,1)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @blossom_template_base_new(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13, %2
store i8* null, i8** %3
br label %50
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %6
%20 = load i8*, i8** %5
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = add nsw i32 %22, %23
%25 = add nsw i32 %24, 2
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %9
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = load i8*, i8** %4
%31 = load i32, i32* %6
%32 = call i32 @strncpy(i8* %29, i8* %30, i32 %31)
%33 = load i32, i32* %6
%34 = load i8*, i8** %10
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %34, i64 %35
store i8* %36, i8** %10
%37 = load i8*, i8** %10
store i8 46, i8* %37
%38 = load i8*, i8** %10
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %10
%40 = load i8*, i8** %10
%41 = load i8*, i8** %5
%42 = load i32, i32* %7
%43 = call i32 @strncpy(i8* %40, i8* %41, i32 %42)
%44 = load i32, i32* %7
%45 = load i8*, i8** %10
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8, i8* %45, i64 %46
store i8* %47, i8** %10
%48 = load i8*, i8** %10
store i8 0, i8* %48
%49 = load i8*, i8** %9
store i8* %49, i8** %3
br label %50
50: ; preds = %17, %16
%51 = load i8*, i8** %3
ret i8* %51
}

LLVM IR (-O2):
define i8* @blossom_template_base_new(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = add i32 %7, 2
%10 = add i32 %9, %8
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
%13 = tail call i32 @strncpy(i8* %12, i8* %0, i32 %7)
%14 = sext i32 %7 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8 46, i8* %15
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @strncpy(i8* %16, i8* %1, i32 %8)
%18 = sext i32 %8 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %2, %6
%21 = phi i8* [ %12, %6 ], [ null, %2 ]
ret i8* %21
}