#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 *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
char *write_cvlettertitle(char *message) {
  char *out;
  if (message != NULL) {
    out = malloc(strlen(message) + 5);
    sprintf(out, "<p>%s\n", message);
    free(message);
  } else {
    out = malloc(1);
    out[0] = 0;
  }
  return out;
}


x86 assembly (clang, -O0):
<write_cvlettertitle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1190 <write_cvlettertitle+0x50>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%edi
add    $0x5,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    11a5 <write_cvlettertitle+0x65>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_cvlettertitle>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1178 <write_cvlettertitle+0x38>
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x5(%rax),%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0xe9d(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1188 <write_cvlettertitle+0x48>
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
movb   $0x0,(%rax)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<p>%s\0A\00"
define i8* @write_cvlettertitle(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %16
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %8, 5
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
br label %20
16: ; preds = %1
%17 = call i8* @malloc(i32 1)
store i8* %17, i8** %3
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 0, i8* %19
br label %20
20: ; preds = %16, %6
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@.str = [7 x i8] c"<p>%s\0A\00"
define noalias i8* @write_cvlettertitle(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 5
%6 = tail call i8* @malloc(i32 %5)
%7 = tail call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @free(i8* %0)
br label %11
9: ; preds = %1
%10 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
store i8 0, i8* %10
br label %11
11: ; preds = %9, %3
%12 = phi i8* [ %6, %3 ], [ %10, %9 ]
ret i8* %12
}