#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*/ puts(char *);
char *strcpy(char *, char const *);
int main(void) {
  const char *orig = "Test";
  char copy[40] = "This is a String.";
  char *ps;
  puts("Test");
  puts(copy);
  ps = strcpy(copy + 8, orig);
  puts(copy);
  puts(ps);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xebb(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    -0x40(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x40(%rbp),%rdi
add    $0x8,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x48(%rbp),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xf02(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xee6(%rip),%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%r14
movl   $0x74736554,0x8(%rsp)
74
movb   $0x0,0xc(%rsp)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Test\00"
@__const.main.copy = [40 x i8] c"This is a String.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [40 x i8]
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = bitcast [40 x i8]* %3 to i8*
%6 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%8 = call i32 @puts(i8* %7)
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds i8, i8* %9, i64 8
%11 = load i8*, i8** %2
%12 = call i8* @strcpy(i8* %10, i8* %11)
store i8* %12, i8** %4
%13 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%14 = call i32 @puts(i8* %13)
%15 = load i8*, i8** %4
%16 = call i32 @puts(i8* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"Test\00"
@__const.main.copy = [40 x i8] c"This is a String.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* %2)
%5 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 8
%6 = call i32 @puts(i8* %2)
%7 = call i32 @puts(i8* %5)
ret i32 0
}