#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
char *realloc(char *, scalar_t__);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
char *append_to_string_with_size(char *destination, char *append_string,
                                 long long size) {
  destination = realloc(destination, strlen(destination) + size + 1);
  if (destination == NULL) {
    printf("Out of Memory!! Fuuuuuuuu");
    exit(1);
  }
  strcat(destination, append_string);
  return destination;
}


x86 assembly (clang, -O0):
<append_to_string_with_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
add    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11ae <append_to_string_with_size+0x5e>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_to_string_with_size>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    (%r15,%rax,1),%rsi
add    $0x1,%rsi
mov    %rbx,%rdi
call   1050 <realloc@plt>
test   %rax,%rax
je     118f <append_to_string_with_size+0x3f>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Out of Memory!! Fuuuuuuuu\00"
define i8* @append_to_string_with_size(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %4
%9 = call i64 @strlen(i8* %8)
%10 = load i64, i64* %6
%11 = add nsw i64 %9, %10
%12 = add nsw i64 %11, 1
%13 = call i8* @realloc(i8* %7, i64 %12)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %3
%20 = load i8*, i8** %4
%21 = load i8*, i8** %5
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
@.str = [26 x i8] c"Out of Memory!! Fuuuuuuuu\00"
define i8* @append_to_string_with_size(i8* nocapture %0, i8* %1, i64 %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add i64 %2, 1
%6 = add i64 %5, %4
%7 = tail call i8* @realloc(i8* %0, i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = tail call i32 @strcat(i8* %7, i8* %1)
ret i8* %7
}