#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*/ ft_memcpy(char *, char *, int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void test_memcpy() {
  printf("-----------------------ft_memcpy\n");
  char str3[20] = "1234567890";
  char str4[20] = "1234567890";
  memcpy(str3, "GOPA", 4);
  ft_memcpy(str4, "GOPA", 4);
  if (memcmp(str3, str4, 10) != 0) {
    printf(">>>>>>>FAIL<<<<<<<\n");
    printf("   memcpy = \"%s\"\n", str3);
    printf("ft_memcpy = \"%s\"\n", str4);
  } else
    printf(">>>>>SUCCESS<<<<<<\n");
}


x86 assembly (clang, -O0):
<test_memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xf23(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf20(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf1e(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xf24(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xf21(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xf1f(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    $0x4,%edx
call   1060 <ft_memcpy@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1211 <test_memcpy+0xd1>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <test_memcpy+0xdf>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memcpy>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe88(%rip),%r15
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1060 <memcpy@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1070 <ft_memcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11fb <test_memcpy+0xab>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe3d(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1207 <test_memcpy+0xb7>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"-----------------------ft_memcpy\0A\00"
@__const.test_memcpy.str3 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@__const.test_memcpy.str4 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [5 x i8] c"GOPA\00"
@.str.2 = [20 x i8] c">>>>>>>FAIL<<<<<<<\0A\00"
@.str.3 = [18 x i8] c" memcpy = \22%s\22\0A\00"
@.str.4 = [18 x i8] c"ft_memcpy = \22%s\22\0A\00"
@.str.5 = [20 x i8] c">>>>>SUCCESS<<<<<<\0A\00"
define void @test_memcpy() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [20 x i8]* %1 to i8*
%5 = bitcast [20 x i8]* %2 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = call i32 @memcpy(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 @ft_memcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i64 @memcmp(i8* %10, i8* %11, i32 10)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@__const.test_memcpy.str4 = [20 x i8] c"1234567890\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [5 x i8] c"GOPA\00"
@.str.3 = [18 x i8] c" memcpy = \22%s\22\0A\00"
@.str.4 = [18 x i8] c"ft_memcpy = \22%s\22\0A\00"
@str = [33 x i8] c"-----------------------ft_memcpy\00"
@str.6 = [19 x i8] c">>>>>SUCCESS<<<<<<\00"
@str.7 = [19 x i8] c">>>>>>>FAIL<<<<<<<\00"
define void @test_memcpy() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 @memcpy(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%7 = call i32 @ft_memcpy(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%8 = call i64 @memcmp(i8* %4, i8* %5, i32 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
ret void
}