#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*/ k_memcpy(char *, char *, int);
int test_memcpy_1() {
  char src[] = {'a', 'b', 'c', 'd'};
  char dst[] = {'x', 'x', 'x', 'x'};
  k_memcpy(dst, src, 4);
  if (dst[0] != 'a' || dst[1] != 'b' || dst[2] != 'c' || dst[3] != 'd')
    return (1);
  if (src[0] != 'a' || src[1] != 'b' || src[2] != 'c' || src[3] != 'd')
    return (2);
  return (0);
}


x86 assembly (clang, -O0):
<test_memcpy_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xee2(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xedd(%rip),%eax
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <k_memcpy@plt>
movsbl -0xc(%rbp),%eax
cmp    $0x61,%eax
jne    1170 <test_memcpy_1+0x60>
movsbl -0xb(%rbp),%eax
cmp    $0x62,%eax
jne    1170 <test_memcpy_1+0x60>
movsbl -0xa(%rbp),%eax
cmp    $0x63,%eax
jne    1170 <test_memcpy_1+0x60>
movsbl -0x9(%rbp),%eax
cmp    $0x64,%eax
je     117c <test_memcpy_1+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <test_memcpy_1+0xb3>
movsbl -0x8(%rbp),%eax
cmp    $0x61,%eax
jne    11b0 <test_memcpy_1+0xa0>
movsbl -0x7(%rbp),%eax
cmp    $0x62,%eax
jne    11b0 <test_memcpy_1+0xa0>
movsbl -0x6(%rbp),%eax
cmp    $0x63,%eax
jne    11b0 <test_memcpy_1+0xa0>
movsbl -0x5(%rbp),%eax
cmp    $0x64,%eax
je     11bc <test_memcpy_1+0xac>
movl   $0x2,-0x4(%rbp)
jmp    11c3 <test_memcpy_1+0xb3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memcpy_1>:
push   %rax
movl   $0x64636261,0x4(%rsp)
64
movl   $0x78787878,(%rsp)
mov    %rsp,%rdi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1030 <k_memcpy@plt>
movd   (%rsp),%xmm0
movd   %xmm0,%eax
movd   0x4(%rsp),%xmm0
movd   %xmm0,%ecx
xor    %edx,%edx
cmp    $0x64636261,%ecx
setne  %dl
add    %edx,%edx
cmp    $0x64636261,%eax
mov    $0x1,%eax
cmove  %edx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.test_memcpy_1.src = [4 x i8] c"abcd"
@__const.test_memcpy_1.dst = [4 x i8] c"xxxx"
define i32 @test_memcpy_1() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i8]
%4 = bitcast [4 x i8]* %2 to i8*
%5 = bitcast [4 x i8]* %3 to i8*
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%8 = call i32 @k_memcpy(i8* %6, i8* %7, i32 4)
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 97
br i1 %12, label %28, label %13
13: ; preds = %0
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 98
br i1 %17, label %28, label %18
18: ; preds = %13
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 99
br i1 %22, label %28, label %23
23: ; preds = %18
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 100
br i1 %27, label %28, label %29
28: ; preds = %23, %18, %13, %0
store i32 1, i32* %1
br label %51
29: ; preds = %23
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 97
br i1 %33, label %49, label %34
34: ; preds = %29
%35 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 98
br i1 %38, label %49, label %39
39: ; preds = %34
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 2
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 99
br i1 %43, label %49, label %44
44: ; preds = %39
%45 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 100
br i1 %48, label %49, label %50
49: ; preds = %44, %39, %34, %29
store i32 2, i32* %1
br label %51
50: ; preds = %44
store i32 0, i32* %1
br label %51
51: ; preds = %50, %49, %28
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
define i32 @test_memcpy_1() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1684234849, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2021161080, i32* %2
%5 = call i32 @k_memcpy(i8* %4, i8* %3, i32 4)
%6 = bitcast i32* %2 to <4 x i8>*
%7 = load <4 x i8>, <4 x i8>* %6
%8 = freeze <4 x i8> %7
%9 = bitcast <4 x i8> %8 to i32
%10 = icmp eq i32 %9, 1684234849
%11 = bitcast i32* %1 to <4 x i8>*
%12 = load <4 x i8>, <4 x i8>* %11
%13 = freeze <4 x i8> %12
%14 = bitcast <4 x i8> %13 to i32
%15 = icmp eq i32 %14, 1684234849
%16 = select i1 %15, i32 0, i32 2
%17 = select i1 %10, i32 %16, i32 1
ret i32 %17
}