#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_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ memoryFailure();
char *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
size_t strlen(char const *);
char *resizeValue(char *old, const char *new) {
  size_t len = strlen(new);
  char *tmp = realloc(old, sizeof(char) * (len + 1));
  if (tmp == NULL) {
    memoryFailure();
    exit(EXIT_FAILURE);
  }
  old = tmp;
  strcpy(old, new);
  return old;
}


x86 assembly (clang, -O0):
<resizeValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a8 <resizeValue+0x58>
mov    $0x0,%al
call   1050 <memoryFailure@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resizeValue>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%esi
mov    %rbx,%rdi
call   1060 <realloc@plt>
test   %rax,%rax
je     118b <resizeValue+0x3b>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1050 <memoryFailure@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i8* @resizeValue(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %5
%9 = load i8*, i8** %3
%10 = load i64, i64* %5
%11 = add i64 %10, 1
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @realloc(i8* %9, i32 %13)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = call i32 (...) @memoryFailure()
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = load i8*, i8** %6
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @strcpy(i8* %23, i8* %24)
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define i8* @resizeValue(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = add i32 %4, 1
%6 = tail call i8* @realloc(i8* %0, i32 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 (...) @memoryFailure()
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 @strcpy(i8* %6, i8* %1)
ret i8* %6
}