#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 */
char *UTIL_mallocStr(size_t);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *addLine(char *str, char *addOn) {
  size_t length = (str ? strlen(str) : 0) + strlen(addOn) + 2;
  char *newStr = UTIL_mallocStr(length);
  if (str) {
    strcpy(newStr, str);
    strcat(newStr, addOn);
  } else
    strcpy(newStr, addOn);
  strcat(newStr, "\n\n");
  return newStr;
}


x86 assembly (clang, -O0):
<addLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     116c <addLine+0x2c>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
jmp    1176 <addLine+0x36>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1176 <addLine+0x36>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
add    $0x2,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <UTIL_mallocStr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11cc <addLine+0x8c>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
jmp    11d9 <addLine+0x99>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addLine>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
test   %rdi,%rdi
je     115f <addLine+0x1f>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
add    $0x2,%ebx
jmp    1164 <addLine+0x24>
mov    $0x2,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %ebx,%eax
movslq %eax,%rdi
call   1050 <UTIL_mallocStr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
test   %r15,%r15
je     1196 <addLine+0x56>
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
jmp    119e <addLine+0x5e>
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0A\0A\00"
define i8* @addLine(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
br label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %9
%14 = phi i32 [ %11, %9 ], [ 0, %12 ]
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %14, %16
%18 = add nsw i32 %17, 2
%19 = sext i32 %18 to i64
store i64 %19, i64* %5
%20 = load i64, i64* %5
%21 = call i8* @UTIL_mallocStr(i64 %20)
store i8* %21, i8** %6
%22 = load i8*, i8** %3
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %31
24: ; preds = %13
%25 = load i8*, i8** %6
%26 = load i8*, i8** %3
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %6
%29 = load i8*, i8** %4
%30 = call i32 @strcat(i8* %28, i8* %29)
br label %35
31: ; preds = %13
%32 = load i8*, i8** %6
%33 = load i8*, i8** %4
%34 = call i32 @strcpy(i8* %32, i8* %33)
br label %35
35: ; preds = %31, %24
%36 = load i8*, i8** %6
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%38 = load i8*, i8** %6
ret i8* %38
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0A\0A\00"
define i8* @addLine(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %0)
%6 = add i32 %5, 2
br label %7
7: ; preds = %2, %4
%8 = phi i32 [ %6, %4 ], [ 2, %2 ]
%9 = tail call i32 @strlen(i8* %1)
%10 = add i32 %8, %9
%11 = sext i32 %10 to i64
%12 = tail call i8* @UTIL_mallocStr(i64 %11)
br i1 %3, label %16, label %13
13: ; preds = %7
%14 = tail call i32 @strcpy(i8* %12, i8* %0)
%15 = tail call i32 @strcat(i8* %12, i8* %1)
br label %18
16: ; preds = %7
%17 = tail call i32 @strcpy(i8* %12, i8* %1)
br label %18
18: ; preds = %16, %13
%19 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret i8* %12
}