#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 *m_strdup(char const *);
char *m_xrealloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *m_strcat(char *dynamic_string, const char *normal_string) {
  int len;
  if (!dynamic_string)
    return m_strdup(normal_string);
  len = strlen(dynamic_string);
  dynamic_string = m_xrealloc(dynamic_string, 1 + len + strlen(normal_string));
  strcpy(dynamic_string + len, normal_string);
  return dynamic_string;
}


x86 assembly (clang, -O0):
<m_strcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <m_strcat+0x2d>
mov    -0x18(%rbp),%rdi
call   1060 <m_strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11c1 <m_strcat+0x81>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%rdi
add    %eax,%esi
call   1050 <m_xrealloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_strcat>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
test   %rdi,%rdi
je     1189 <m_strcat+0x49>
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%r15,%rax,1),%esi
add    $0x1,%esi
mov    %rbx,%rdi
call   1050 <m_xrealloc@plt>
mov    %rax,%rbx
movslq %r15d,%rdi
add    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <m_strdup@plt>

LLVM IR (-O0):
define i8* @m_strcat(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i8* @m_strdup(i8* %10)
store i8* %11, i8** %3
br label %29
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
store i32 %14, i32* %6
%15 = load i8*, i8** %4
%16 = load i32, i32* %6
%17 = add nsw i32 1, %16
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = call i8* @m_xrealloc(i8* %15, i32 %20)
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8*, i8** %5
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %4
store i8* %28, i8** %3
br label %29
29: ; preds = %12, %9
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
define i8* @m_strcat(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i8* @m_strdup(i8* %1)
br label %15
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, 1
%9 = tail call i32 @strlen(i8* %1)
%10 = add nsw i32 %8, %9
%11 = tail call i8* @m_xrealloc(i8* %0, i32 %10)
%12 = sext i32 %7 to i64
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = tail call i32 @strcpy(i8* %13, i8* %1)
br label %15
15: ; preds = %6, %4
%16 = phi i8* [ %11, %6 ], [ %5, %4 ]
ret i8* %16
}