#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*/ puts(char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int addAttribute(char **buffer, char *attribute) {
  if ((*buffer = (char *)malloc(strlen(attribute) + 1)) == NULL) {
    puts("Out of memory.");
    return (0);
  }
  strcpy(*buffer, attribute);
  return ((!0));
}


x86 assembly (clang, -O0):
<addAttribute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    118e <addAttribute+0x4e>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <addAttribute+0x65>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addAttribute>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1060 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1175 <addAttribute+0x35>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
jmp    1183 <addAttribute+0x43>
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"Out of memory.\00"
define i32 @addAttribute(i8** nocapture writeonly %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = add nsw i64 %3, 1
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %0
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = tail call i32 @strcpy(i8* %6, i8* %1)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ 0, %8 ], [ 1, %10 ]
ret i32 %13
}