#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(scalar_t__);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *concatDomLabel(char *dl, char *du) {
  char *s;
  if (dl == NULL) {
    s = (char *)malloc(strlen(du) + 1);
    strcpy(s, du);
  } else {
    s = (char *)malloc(strlen(dl) + 1 + strlen(du) + 1);
    strcpy(s, dl);
    strcat(s, ".");
    strcat(s, du);
  }
  return s;
}


x86 assembly (clang, -O0):
<concatDomLabel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1186 <concatDomLabel+0x46>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11de <concatDomLabel+0x9e>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatDomLabel>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
test   %rdi,%rdi
je     1197 <concatDomLabel+0x57>
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
jmp    11b6 <concatDomLabel+0x76>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define i8* @concatDomLabel(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 eq i8* %6, null
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i64 @malloc(i64 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 @strcpy(i8* %14, i8* %15)
br label %35
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %19, 1
%21 = load i8*, i8** %4
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %20, %22
%24 = add nsw i64 %23, 1
%25 = call i64 @malloc(i64 %24)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %5
%27 = load i8*, i8** %5
%28 = load i8*, i8** %3
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = load i8*, i8** %5
%33 = load i8*, i8** %4
%34 = call i32 @strcat(i8* %32, i8* %33)
br label %35
35: ; preds = %17, %8
%36 = load i8*, i8** %5
ret i8* %36
}

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