#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 */
typedef int /*<<< orphan*/ wchar_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *wcsdup(int /*<<< orphan*/ const *const);
void ustringCopy(wchar_t **dst, const wchar_t *const *src) {
  assert(dst != NULL);
  assert(src != NULL);
  if (*dst != NULL) {
    free(*dst);
    *dst = NULL;
  }
  if (*src != NULL) {
    *dst = wcsdup(*src);
  }
}


x86 assembly (clang, -O0):
<ustringCopy>:
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 <ustringCopy+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 <ustringCopy+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <wcsdup@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ustringCopy>:
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 <ustringCopy+0x3a>
call   1030 <free@plt>
movq   $0x0,(%rbx)
mov    (%r14),%rdi
test   %rdi,%rdi
je     117a <ustringCopy+0x4a>
call   1050 <wcsdup@plt>
mov    %rax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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