#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int quicktime_set_udta_string(char **string, int *size, char *new_string) {
  if (*size)
    free(*string);
  *size = strlen(new_string) + 1;
  *string = malloc(*size);
  strcpy(*string, new_string);
  return 0;
}


x86 assembly (clang, -O0):
<quicktime_set_udta_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     116d <quicktime_set_udta_string+0x2d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicktime_set_udta_string>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
cmpl   $0x0,(%rsi)
je     115b <quicktime_set_udta_string+0x1b>
mov    (%r14),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
mov    %edi,(%rbx)
call   1060 <malloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @quicktime_set_udta_string(i8** nocapture %0, i32* nocapture %1, i8* %2) {
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i8*, i8** %0
%8 = tail call i32 @free(i8* %7)
br label %9
9: ; preds = %6, %3
%10 = tail call i32 @strlen(i8* %2)
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = tail call i8* @malloc(i32 %11)
store i8* %12, i8** %0
%13 = tail call i32 @strcpy(i8* %12, i8* %2)
ret i32 0
}