#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*/ strcpy(char *, char const *);
unsigned int strlen(char const *);
void libirc_colorparser_addorcat(char **destline, unsigned int *destlen,
                                 const char *str) {
  unsigned int len = strlen(str);
  if (*destline) {
    strcpy(*destline, str);
    *destline += len;
  } else
    *destlen += len;
}


x86 assembly (clang, -O0):
<libirc_colorparser_addorcat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1175 <libirc_colorparser_addorcat+0x55>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    %edx,%edx
add    %rdx,%rcx
mov    %rcx,(%rax)
jmp    1180 <libirc_colorparser_addorcat+0x60>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libirc_colorparser_addorcat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    (%r14),%rdi
test   %rdi,%rdi
je     1151 <libirc_colorparser_addorcat+0x31>
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %ebp,%eax
add    %rax,(%r14)
jmp    1154 <libirc_colorparser_addorcat+0x34>
add    %ebp,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @libirc_colorparser_addorcat(i8** nocapture %0, i32* nocapture %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = load i8*, i8** %0
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = tail call i32 @strcpy(i8* %5, i8* %2)
%9 = load i8*, i8** %0
%10 = zext i32 %4 to i64
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %0
br label %15
12: ; preds = %3
%13 = load i32, i32* %1
%14 = add i32 %13, %4
store i32 %14, i32* %1
br label %15
15: ; preds = %12, %7
ret void
}