#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*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char array_a[11] = "0123456789";
  char array_b[11];
  printf("array_a (before memcpy) = [%s]\n", array_a);
  printf("array_b (before memcpy) = [%s]\n", array_b);
  memcpy(array_b, array_a, 10);
  printf("array_a (after memcpy) = [%s]\n", array_a);
  printf("array_b (after memcpy) = [%s]\n", array_b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xec7(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xebf(%rip),%al
mov    %al,-0x5(%rbp)
lea    -0xf(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rdi
lea    -0xf(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcpy@plt>
lea    -0xf(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1a(%rbp),%rsi
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,(%rsp)
movl   $0x393837,0x7(%rsp)
lea    0xec7(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0xd(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1040 <memcpy@plt>
lea    0xed1(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.array_a = [11 x i8] c"0123456789\00"
@.str = [32 x i8] c"array_a (before memcpy) = [%s]\0A\00"
@.str.1 = [32 x i8] c"array_b (before memcpy) = [%s]\0A\00"
@.str.2 = [31 x i8] c"array_a (after memcpy) = [%s]\0A\00"
@.str.3 = [31 x i8] c"array_b (after memcpy) = [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i8]
%3 = alloca [11 x i8]
store i32 0, i32* %1
%4 = bitcast [11 x i8]* %2 to i8*
%5 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%11 = call i32 @memcpy(i8* %9, i8* %10, i32 10)
%12 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array_a = [11 x i8] c"0123456789\00"
@.str = [32 x i8] c"array_a (before memcpy) = [%s]\0A\00"
@.str.1 = [32 x i8] c"array_b (before memcpy) = [%s]\0A\00"
@.str.2 = [31 x i8] c"array_a (after memcpy) = [%s]\0A\00"
@.str.3 = [31 x i8] c"array_b (after memcpy) = [%s]\0A\00"
define i32 @main() {
%1 = alloca [11 x i8]
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 @memcpy(i8* %4, i8* %3, i32 10)
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%9 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}