char *add(this, that)
register char *this, *that;
{
  register char *r;
  if (!this)
    this = "";
  if (!that)
    that = "";
  r = malloc((unsigned)(strlen(this) + strlen(that) + 1));
  sprintf(r, "%s%s", that, this);
  if (*that)
    cndfree(that);
  return (r);
}


x86 assembly (clang, -O0):
<add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1166 <add+0x26>
lea    0xea2(%rip),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117c <add+0x3c>
lea    0xe8c(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
add    $0x1,%rax
mov    %eax,%eax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11df <add+0x9f>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <cndfree@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
lea    0xeb2(%rip),%rax
cmove  %rax,%r14
mov    %rsi,%rbx
test   %rsi,%rsi
cmove  %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
lea    0xe77(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <sprintf@plt>
cmpb   $0x0,(%rbx)
je     11a8 <add+0x68>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <cndfree@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"%s%s\00"
define i8* @add(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %0
%5 = icmp eq i8* %1, null
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %1
%7 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%8 = tail call i64 @strlen(i8* dereferenceable(1) %6)
%9 = add i64 %7, 1
%10 = add i64 %9, %8
%11 = and i64 %10, 4294967295
%12 = tail call i8* @malloc(i64 %11)
%13 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %4)
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = tail call i32 (i8*, ...) bitcast (i32 (...)* @cndfree to i32 (i8*, ...)*)(i8* %6)
br label %18
18: ; preds = %16, %2
ret i8* %12
}