#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*/ MYstrcpy(char *, char *);
size_t MYstrlen(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int index;
  char c, buffer[80];
  char *stringPtr, *literal = "This is a literal string";
  printf("Our string literal is %s, \nwhile the unititialized buffer is %s\n",
         literal, buffer);
  printf("\n\n");
  MYstrcpy(buffer, literal);
  printf("Our string literal is %s, \nwhile the now ititialized buffer is %s\n",
         literal, buffer);
  stringPtr = (char *)malloc(MYstrlen(literal));
  MYstrcpy(stringPtr, literal);
  printf("Our string literal is %s, \nwhile the stringPtr is %s\n", literal,
         stringPtr);
  printf("\n\n");
  MYstrcpy(buffer + MYstrlen(buffer), literal);
  printf("Buffer is now %s\n", buffer);
  printf("\n\n");
  MYstrcpy(buffer, literal);
  printf("Buffer is now %s\n", buffer);
  printf("\n\n");
  index = MYstrlen(buffer) + 1;
  buffer[MYstrlen(buffer)] = ' ';
  MYstrcpy(buffer + index, literal);
  printf("Buffer is now %s\n", buffer);
  printf("\n\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1030 <MYstrcpy@plt>
mov    -0x80(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x80(%rbp),%rdi
call   1040 <MYstrlen@plt>
mov    %rax,%rdi
call   1060 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1030 <MYstrcpy@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <MYstrlen@plt>
mov    -0x88(%rbp),%rdi
add    %rax,%rdi
mov    -0x80(%rbp),%rsi
call   1030 <MYstrcpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1030 <MYstrcpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <MYstrlen@plt>
add    $0x1,%rax
mov    %eax,-0x14(%rbp)
lea    -0x70(%rbp),%rdi
call   1040 <MYstrlen@plt>
movb   $0x20,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
mov    -0x80(%rbp),%rsi
call   1030 <MYstrcpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xeb5(%rip),%rdi
lea    0xe95(%rip),%r14
mov    %rsp,%r13
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf19(%rip),%r15
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <MYstrcpy@plt>
lea    0xebe(%rip),%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1040 <MYstrlen@plt>
mov    %rax,%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <MYstrcpy@plt>
lea    0xecf(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1040 <MYstrlen@plt>
lea    (%rsp,%rax,1),%rdi
mov    %r14,%rsi
call   1030 <MYstrcpy@plt>
lea    0xed5(%rip),%r12
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <MYstrcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1040 <MYstrlen@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1040 <MYstrlen@plt>
movb   $0x20,(%rsp,%rax,1)
add    $0x1,%ebx
movslq %ebx,%rax
lea    (%rsp,%rax,1),%rdi
mov    %r14,%rsi
call   1030 <MYstrcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"This is a literal string\00"
@.str.1 = [65 x i8] c"Our string literal is %s, \0Awhile the unititialized buffer is %s\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
@.str.3 = [67 x i8] c"Our string literal is %s, \0Awhile the now ititialized buffer is %s\0A\00"
@.str.4 = [54 x i8] c"Our string literal is %s, \0Awhile the stringPtr is %s\0A\00"
@.str.5 = [18 x i8] c"Buffer is now %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8
%7 = alloca [80 x i8]
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i8*, i8** %9
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%15 = load i8*, i8** %9
%16 = call i32 @MYstrcpy(i8* %14, i8* %15)
%17 = load i8*, i8** %9
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i8*, i8** %9
%21 = call i64 @MYstrlen(i8* %20)
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = call i32 @MYstrcpy(i8* %24, i8* %25)
%27 = load i8*, i8** %9
%28 = load i8*, i8** %8
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%33 = call i64 @MYstrlen(i8* %32)
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8*, i8** %9
%36 = call i32 @MYstrcpy(i8* %34, i8* %35)
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%41 = load i8*, i8** %9
%42 = call i32 @MYstrcpy(i8* %40, i8* %41)
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%47 = call i64 @MYstrlen(i8* %46)
%48 = add i64 %47, 1
%49 = trunc i64 %48 to i32
store i32 %49, i32* %5
%50 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%51 = call i64 @MYstrlen(i8* %50)
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 %51
store i8 32, i8* %52
%53 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8*, i8** %9
%58 = call i32 @MYstrcpy(i8* %56, i8* %57)
%59 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"This is a literal string\00"
@.str.1 = [65 x i8] c"Our string literal is %s, \0Awhile the unititialized buffer is %s\0A\00"
@.str.3 = [67 x i8] c"Our string literal is %s, \0Awhile the now ititialized buffer is %s\0A\00"
@.str.4 = [54 x i8] c"Our string literal is %s, \0Awhile the stringPtr is %s\0A\00"
@.str.5 = [18 x i8] c"Buffer is now %s\0A\00"
@str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 @MYstrcpy(i8* %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = call i64 @MYstrlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%10 = call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
%12 = call i32 @MYstrcpy(i8* %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%15 = call i64 @MYstrlen(i8* %4)
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %15
%17 = call i32 @MYstrcpy(i8* %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%20 = call i32 @MYstrcpy(i8* %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
%23 = call i64 @MYstrlen(i8* %4)
%24 = call i64 @MYstrlen(i8* %4)
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %24
store i8 32, i8* %25
%26 = shl i64 %23, 32
%27 = add i64 %26, 4294967296
%28 = ashr exact i64 %27, 32
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %28
%30 = call i32 @MYstrcpy(i8* %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
ret i32 0
}