#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*/ HTMemory_outofmem(char *, char *, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *HTSACopy(char **dest, const char *src) {
  if (*dest)
    free(*dest);
  if (!src)
    *dest = NULL;
  else {
    if ((*dest = (char *)malloc(strlen(src) + 1)) == NULL)
      HTMemory_outofmem(
          ("HTSACopy"),
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/BOT-Man-JL/BUPT-Projects/refs/heads/"
          "master/0-0-Misc/crawler/third_party/HTParse.c",
          52);
    strcpy(*dest, src);
  }
  return *dest;
}


x86 assembly (clang, -O0):
<HTSACopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     117a <HTSACopy+0x2a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1195 <HTSACopy+0x45>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11e3 <HTSACopy+0x93>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    11d3 <HTSACopy+0x83>
lea    0xe3e(%rip),%rdi
lea    0xe40(%rip),%rsi
mov    $0x34,%edx
call   1060 <HTMemory_outofmem@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HTSACopy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1167 <HTSACopy+0x17>
call   1030 <free@plt>
test   %r14,%r14
je     11b0 <HTSACopy+0x60>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
jne    11a0 <HTSACopy+0x50>
lea    0xe74(%rip),%rdi
lea    0xe76(%rip),%rsi
mov    $0x34,%edx
call   1060 <HTMemory_outofmem@plt>
mov    (%rbx),%rax
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    (%rbx),%rax
jmp    11b9 <HTSACopy+0x69>
movq   $0x0,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"HTSACopy\00"
@.str.1 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BOT-Man-JL/BUPT-Projects/refs/heads/master/0-0-Misc/crawler/third_party/HTParse.c\00"
define i8* @HTSACopy(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 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8**, i8*** %3
%10 = load i8*, i8** %9
%11 = call i32 @free(i8* %10)
br label %12
12: ; preds = %8, %2
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = load i8**, i8*** %3
store i8* null, i8** %16
br label %32
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %19, 1
%21 = call i64 @malloc(i64 %20)
%22 = inttoptr i64 %21 to i8*
%23 = load i8**, i8*** %3
store i8* %22, i8** %23
%24 = icmp eq i8* %22, null
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 @HTMemory_outofmem(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.1, i64 0, i64 0), i32 52)
br label %27
27: ; preds = %25, %17
%28 = load i8**, i8*** %3
%29 = load i8*, i8** %28
%30 = load i8*, i8** %4
%31 = call i32 @strcpy(i8* %29, i8* %30)
br label %32
32: ; preds = %27, %15
%33 = load i8**, i8*** %3
%34 = load i8*, i8** %33
ret i8* %34
}

LLVM IR (-O2):
@.str = [9 x i8] c"HTSACopy\00"
@.str.1 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/BOT-Man-JL/BUPT-Projects/refs/heads/master/0-0-Misc/crawler/third_party/HTParse.c\00"
define i8* @HTSACopy(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @free(i8* %3)
br label %7
7: ; preds = %5, %2
%8 = icmp eq i8* %1, null
br i1 %8, label %9, label %10
9: ; preds = %7
store i8* null, i8** %0
br label %23
10: ; preds = %7
%11 = tail call i64 @strlen(i8* %1)
%12 = add nsw i64 %11, 1
%13 = tail call i64 @malloc(i64 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %0
%15 = icmp eq i64 %13, 0
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = tail call i32 @HTMemory_outofmem(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.1, i64 0, i64 0), i32 52)
%18 = load i8*, i8** %0
br label %19
19: ; preds = %16, %10
%20 = phi i8* [ %18, %16 ], [ %14, %10 ]
%21 = tail call i32 @strcpy(i8* %20, i8* %1)
%22 = load i8*, i8** %0
br label %23
23: ; preds = %19, %9
%24 = phi i8* [ %22, %19 ], [ null, %9 ]
ret i8* %24
}