#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_equal_str(char *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
char *pl_cpy(char *, int /*<<< orphan*/ *);
void test_strcpy_no_alloc() {
  char the_string[] = "spam, eggs, and ham";
  char *ret_val;
  ret_val = pl_cpy(the_string, NULL);
  assert_equal_str("spam, eggs, and ham", ret_val, "test_strcpy_no_alloc",
                   "The strings are not equal.");
  free(ret_val);
}


x86 assembly (clang, -O0):
<test_strcpy_no_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <pl_cpy@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xea1(%rip),%rdi
lea    0xeae(%rip),%rdx
lea    0xebc(%rip),%rcx
call   1040 <assert_equal_str@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strcpy_no_alloc>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x6d6168,0x10(%rsp)
lea    0xeaf(%rip),%r14
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <pl_cpy@plt>
mov    %rax,%rbx
lea    0xeaf(%rip),%rdx
lea    0xebd(%rip),%rcx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <assert_equal_str@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_strcpy_no_alloc.the_string = [20 x i8] c"spam, eggs, and ham\00"
@.str = [20 x i8] c"spam, eggs, and ham\00"
@.str.1 = [21 x i8] c"test_strcpy_no_alloc\00"
@.str.2 = [27 x i8] c"The strings are not equal.\00"
define void @test_strcpy_no_alloc() {
%1 = alloca [20 x i8]
%2 = alloca i8*
%3 = bitcast [20 x i8]* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = call i8* @pl_cpy(i8* %4, i32* null)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @assert_equal_str(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%8 = load i8*, i8** %2
%9 = call i32 @free(i8* %8)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"spam, eggs, and ham\00"
@.str.1 = [21 x i8] c"test_strcpy_no_alloc\00"
@.str.2 = [27 x i8] c"The strings are not equal.\00"
define void @test_strcpy_no_alloc() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i8* @pl_cpy(i8* %2, i32* null)
%4 = call i32 @assert_equal_str(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @free(i8* %3)
ret void
}