#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 */
typedef int /*<<< orphan*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
char *strdup(char *);
int main(int argc, char *argv[]) {
  char tmp[] = "tsmjkfrjsdlkfjpoer";
  char tmp2[] = "sdlfkcskdjfroizoro";
  char *str;
  memcpy(NULL, NULL, 0);
  str = strdup(tmp);
  printf("str => %s | ", str);
  str = memcpy(str, tmp2, sizeof(tmp) - 1);
  printf("str -> %s\n", str);
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9d(%rip),%ax
mov    %ax,-0x20(%rbp)
mov    0xe95(%rip),%al
mov    %al,-0x1e(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe93(%rip),%ax
mov    %ax,-0x40(%rbp)
mov    0xe8b(%rip),%al
mov    %al,-0x3e(%rbp)
xor    %edx,%edx
mov    %edx,%esi
mov    %rsi,%rdi
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
mov    -0x58(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x12,%edx
call   1050 <memcpy@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rsi
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x72656f,0x2f(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x6f726f,0xf(%rsp)
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <memcpy@plt>
lea    0x20(%rsp),%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x12,%edx
call   1050 <memcpy@plt>
mov    %rax,%rbx
lea    0xe93(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.tmp = [19 x i8] c"tsmjkfrjsdlkfjpoer\00"
@__const.main.tmp2 = [19 x i8] c"sdlfkcskdjfroizoro\00"
@.str = [13 x i8] c"str => %s | \00"
@.str.1 = [11 x i8] c"str -> %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [19 x i8]
%7 = alloca [19 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [19 x i8]* %6 to i8*
%10 = bitcast [19 x i8]* %7 to i8*
%11 = call i8* @memcpy(i8* null, i8* null, i32 0)
%12 = getelementptr inbounds [19 x i8], [19 x i8]* %6, i64 0, i64 0
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %8
%17 = getelementptr inbounds [19 x i8], [19 x i8]* %7, i64 0, i64 0
%18 = call i8* @memcpy(i8* %16, i8* %17, i32 18)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %8
%22 = call i32 @free(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.tmp = [19 x i8] c"tsmjkfrjsdlkfjpoer\00"
@__const.main.tmp2 = [19 x i8] c"sdlfkcskdjfroizoro\00"
@.str = [13 x i8] c"str => %s | \00"
@.str.1 = [11 x i8] c"str -> %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [19 x i8]
%4 = alloca [19 x i8]
%5 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %4, i64 0, i64 0
%7 = tail call i8* @memcpy(i8* null, i8* null, i32 0)
%8 = call i8* @strdup(i8* %5)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @memcpy(i8* %8, i8* %6, i32 18)
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @free(i8* %10)
ret i32 0
}