#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *strdup(char const *const);
void astringCopy(char **dst, const char *const *src) {
  assert(dst != NULL);
  assert(src != NULL);
  if (*dst != NULL) {
    free(*dst);
    *dst = NULL;
  }
  if (*src != NULL) {
    *dst = strdup(*src);
  }
}


x86 assembly (clang, -O0):
<astringCopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1189 <astringCopy+0x59>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11ad <astringCopy+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strdup@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<astringCopy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     116a <astringCopy+0x3a>
call   1030 <free@plt>
movq   $0x0,(%rbx)
mov    (%r14),%rdi
test   %rdi,%rdi
je     117a <astringCopy+0x4a>
call   1050 <strdup@plt>
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @astringCopy(i8** %0, i8** %1) {
%3 = icmp ne i8** %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i8** %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load i8*, i8** %0
%10 = icmp eq i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = tail call i32 @free(i8* %9)
store i8* null, i8** %0
br label %13
13: ; preds = %11, %2
%14 = load i8*, i8** %1
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = tail call i8* @strdup(i8* %14)
store i8* %17, i8** %0
br label %18
18: ; preds = %16, %13
ret void
}