#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*/ printf(char *, ...);
int main(void) {
  printf("\ncharstringpointer started\n\n");
  void copyString(char *to, char *from);
  char string1[] = "A string to be copied.";
  char string2[50];
  copyString(string2, string1);
  printf("%s\n", string2);
  copyString(string2, "So is this.");
  printf("%s\n", string2);
  printf("\ncharstringpointer ended\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xf0c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf09(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf07(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xf01(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xef9(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <copyString@plt>
lea    -0x60(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <copyString@plt>
lea    -0x60(%rbp),%rsi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
movaps 0xec8(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x2e646569706f63,%rax
mov    %rax,0xf(%rsp)
lea    0x20(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <copyString@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xead(%rip),%rsi
mov    %rbx,%rdi
call   1030 <copyString@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0Acharstringpointer started\0A\0A\00"
@__const.main.string1 = [23 x i8] c"A string to be copied.\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [12 x i8] c"So is this.\00"
@.str.3 = [27 x i8] c"\0Acharstringpointer ended\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca [50 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%5 = bitcast [23 x i8]* %2 to i8*
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.string1 = [23 x i8] c"A string to be copied.\00"
@.str.2 = [12 x i8] c"So is this.\00"
@str = [28 x i8] c"\0Acharstringpointer started\0A\00"
@str.4 = [26 x i8] c"\0Acharstringpointer ended\0A\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = alloca [50 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%6 = call i32 @puts(i8* %5)
%7 = call i32 @puts(i8* %5)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}