#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*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_cmpeq_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ _mm_extract_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_loadu_si128(int /*<<< orphan*/ *);
int check(void *src1, void *src2, size_t size) {
  size_t offset = size & 15;
  for (size_t i = 0; i < size; i += 16) {
    __m128i reg1 = _mm_loadu_si128((__m128i *)src1);
    __m128i reg2 = _mm_loadu_si128((__m128i *)src2);
    __m128i res = _mm_cmpeq_epi8(reg1, reg2);
    if (_mm_extract_epi16(res, 7) == 0) {
      return 0;
    }
  }
  for (size_t i = size - offset; i < size; i++) {
    const char *cp1 = (const char *)src1 + i;
    const char *cp2 = (const char *)src2 + i;
    if (*cp1 != *cp2) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
and    $0xf,%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11c5 <check+0x95>
mov    -0x10(%rbp),%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1050 <_mm_cmpeq_epi8@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x7,%esi
call   1030 <_mm_extract_epi16@plt>
cmp    $0x0,%rax
jne    11af <check+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    1236 <check+0x106>
jmp    11b4 <check+0x84>
mov    -0x30(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
jmp    1158 <check+0x28>
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    122f <check+0xff>
mov    -0x10(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
movsbl (%rax),%eax
mov    -0x58(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1219 <check+0xe9>
movl   $0x0,-0x4(%rbp)
jmp    1236 <check+0x106>
jmp    121e <check+0xee>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11d1 <check+0xa1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
test   %rdx,%rdx
je     1185 <check+0x55>
xor    %r14d,%r14d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r12,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <_mm_loadu_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_cmpeq_epi8@plt>
mov    %eax,%edi
mov    $0x7,%esi
call   1030 <_mm_extract_epi16@plt>
test   %rax,%rax
je     11b9 <check+0x89>
add    $0x10,%rbx
cmp    %r13,%rbx
jb     1150 <check+0x20>
mov    %r13,%rax
and    $0xfffffffffffffff0,%rax
mov    $0x1,%r14d
cmp    %r13,%rax
jae    11b9 <check+0x89>
nopw   0x0(%rax,%rax,1)
movzbl (%r12,%rax,1),%ecx
cmp    (%r15,%rax,1),%cl
jne    11b6 <check+0x86>
add    $0x1,%rax
cmp    %r13,%rax
jb     11a0 <check+0x70>
jmp    11b9 <check+0x89>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%16 = load i64, i64* %7
%17 = and i64 %16, 15
store i64 %17, i64* %8
store i64 0, i64* %9
br label %18
18: ; preds = %37, %3
%19 = load i64, i64* %9
%20 = load i64, i64* %7
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = bitcast i8* %23 to i32*
%25 = call i32 @_mm_loadu_si128(i32* %24)
store i32 %25, i32* %10
%26 = load i8*, i8** %6
%27 = bitcast i8* %26 to i32*
%28 = call i32 @_mm_loadu_si128(i32* %27)
store i32 %28, i32* %11
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = call i32 @_mm_cmpeq_epi8(i32 %29, i32 %30)
store i32 %31, i32* %12
%32 = load i32, i32* %12
%33 = call i64 @_mm_extract_epi16(i32 %32, i32 7)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %22
store i32 0, i32* %4
br label %68
36: ; preds = %22
br label %37
37: ; preds = %36
%38 = load i64, i64* %9
%39 = add i64 %38, 16
store i64 %39, i64* %9
br label %18
40: ; preds = %18
%41 = load i64, i64* %7
%42 = load i64, i64* %8
%43 = sub i64 %41, %42
store i64 %43, i64* %13
br label %44
44: ; preds = %64, %40
%45 = load i64, i64* %13
%46 = load i64, i64* %7
%47 = icmp ult i64 %45, %46
br i1 %47, label %48, label %67
48: ; preds = %44
%49 = load i8*, i8** %5
%50 = load i64, i64* %13
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8* %51, i8** %14
%52 = load i8*, i8** %6
%53 = load i64, i64* %13
%54 = getelementptr inbounds i8, i8* %52, i64 %53
store i8* %54, i8** %15
%55 = load i8*, i8** %14
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = load i8*, i8** %15
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp ne i32 %57, %60
br i1 %61, label %62, label %63
62: ; preds = %48
store i32 0, i32* %4
br label %68
63: ; preds = %48
br label %64
64: ; preds = %63
%65 = load i64, i64* %13
%66 = add i64 %65, 1
store i64 %66, i64* %13
br label %44
67: ; preds = %44
store i32 1, i32* %4
br label %68
68: ; preds = %67, %62, %35
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
define i32 @check(i8* %0, i8* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = bitcast i8* %0 to i32*
%7 = bitcast i8* %1 to i32*
br label %10
8: ; preds = %10
%9 = icmp ult i64 %17, %2
br i1 %9, label %10, label %18
10: ; preds = %5, %8
%11 = phi i64 [ 0, %5 ], [ %17, %8 ]
%12 = tail call i32 @_mm_loadu_si128(i32* %6)
%13 = tail call i32 @_mm_loadu_si128(i32* %7)
%14 = tail call i32 @_mm_cmpeq_epi8(i32 %12, i32 %13)
%15 = tail call i64 @_mm_extract_epi16(i32 %14, i32 7)
%16 = icmp eq i64 %15, 0
%17 = add i64 %11, 16
br i1 %16, label %31, label %8
18: ; preds = %8, %3
%19 = and i64 %2, -16
%20 = icmp ult i64 %19, %2
br i1 %20, label %23, label %31
21: ; preds = %23
%22 = icmp ult i64 %30, %2
br i1 %22, label %23, label %31
23: ; preds = %18, %21
%24 = phi i64 [ %30, %21 ], [ %19, %18 ]
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = getelementptr inbounds i8, i8* %1, i64 %24
%27 = load i8, i8* %25
%28 = load i8, i8* %26
%29 = icmp eq i8 %27, %28
%30 = add nuw i64 %24, 1
br i1 %29, label %21, label %31
31: ; preds = %10, %21, %23, %18
%32 = phi i32 [ 1, %18 ], [ 1, %21 ], [ 0, %23 ], [ 0, %10 ]
ret i32 %32
}