#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*/ cm_print_error(char *, int, ...);
int memory_equal_display_error(const char *const a, const char *const b,
                               const size_t size) {
  int differences = 0;
  size_t i;
  for (i = 0; i < size; i++) {
    const char l = a[i];
    const char r = b[i];
    if (l != r) {
      cm_print_error("difference at offset %"
                     "zd"
                     " 0x%02x 0x%02x\n",
                     i, l, r);
      differences++;
    }
  }
  if (differences) {
    cm_print_error("%d bytes of %s and %s differ\n", differences, a, b);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<memory_equal_display_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a8 <memory_equal_display_error+0x98>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x32(%rbp)
movsbl -0x31(%rbp),%eax
movsbl -0x32(%rbp),%ecx
cmp    %ecx,%eax
je     1192 <memory_equal_display_error+0x82>
mov    -0x30(%rbp),%rax
mov    %eax,%esi
movsbl -0x31(%rbp),%edx
movsbl -0x32(%rbp),%ecx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <cm_print_error@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1197 <memory_equal_display_error+0x87>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1133 <memory_equal_display_error+0x23>
cmpl   $0x0,-0x24(%rbp)
je     11d7 <memory_equal_display_error+0xc7>
mov    -0x24(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <cm_print_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    11de <memory_equal_display_error+0xce>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memory_equal_display_error>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%r14d
test   %rdx,%rdx
je     118c <memory_equal_display_error+0x7c>
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xeca(%rip),%r13
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1149 <memory_equal_display_error+0x39>
nopl   (%rax)
add    $0x1,%r14
cmp    %r14,%rbp
je     1169 <memory_equal_display_error+0x59>
movsbl (%r12,%r14,1),%edx
movsbl (%r15,%r14,1),%ecx
cmp    %cl,%dl
je     1140 <memory_equal_display_error+0x30>
mov    %r13,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <cm_print_error@plt>
add    $0x1,%ebx
jmp    1140 <memory_equal_display_error+0x30>
test   %ebx,%ebx
mov    $0x1,%r14d
je     118c <memory_equal_display_error+0x7c>
lea    0xeae(%rip),%rdi
xor    %r14d,%r14d
mov    %ebx,%esi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <cm_print_error@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"difference at offset %zd 0x%02x 0x%02x\0A\00"
@.str.1 = [30 x i8] c"%d bytes of %s and %s differ\0A\00"
define i32 @memory_equal_display_error(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i32 0, i32* %8
store i64 0, i64* %9
br label %12
12: ; preds = %41, %3
%13 = load i64, i64* %9
%14 = load i64, i64* %7
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = load i64, i64* %9
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = load i8, i8* %19
store i8 %20, i8* %10
%21 = load i8*, i8** %6
%22 = load i64, i64* %9
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i8, i8* %23
store i8 %24, i8* %11
%25 = load i8, i8* %10
%26 = sext i8 %25 to i32
%27 = load i8, i8* %11
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %26, %28
br i1 %29, label %30, label %40
30: ; preds = %16
%31 = load i64, i64* %9
%32 = trunc i64 %31 to i32
%33 = load i8, i8* %10
%34 = sext i8 %33 to i32
%35 = load i8, i8* %11
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, i32, ...) @cm_print_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %34, i32 %36)
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %40
40: ; preds = %30, %16
br label %41
41: ; preds = %40
%42 = load i64, i64* %9
%43 = add i64 %42, 1
store i64 %43, i64* %9
br label %12
44: ; preds = %12
%45 = load i32, i32* %8
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* %8
%49 = load i8*, i8** %5
%50 = load i8*, i8** %6
%51 = call i32 (i8*, i32, ...) @cm_print_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %48, i8* %49, i8* %50)
store i32 0, i32* %4
br label %53
52: ; preds = %44
store i32 1, i32* %4
br label %53
53: ; preds = %52, %47
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
@.str = [40 x i8] c"difference at offset %zd 0x%02x 0x%02x\0A\00"
@.str.1 = [30 x i8] c"%d bytes of %s and %s differ\0A\00"
define i32 @memory_equal_display_error(i8* %0, i8* %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %27, label %5
5: ; preds = %3, %19
%6 = phi i32 [ %20, %19 ], [ 0, %3 ]
%7 = phi i64 [ %21, %19 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %1, i64 %7
%11 = load i8, i8* %10
%12 = icmp eq i8 %9, %11
br i1 %12, label %19, label %13
13: ; preds = %5
%14 = sext i8 %11 to i32
%15 = sext i8 %9 to i32
%16 = trunc i64 %7 to i32
%17 = tail call i32 (i8*, i32, ...) @cm_print_error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %15, i32 %14)
%18 = add nsw i32 %6, 1
br label %19
19: ; preds = %13, %5
%20 = phi i32 [ %18, %13 ], [ %6, %5 ]
%21 = add nuw i64 %7, 1
%22 = icmp eq i64 %21, %2
br i1 %22, label %23, label %5
23: ; preds = %19
%24 = icmp eq i32 %20, 0
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 (i8*, i32, ...) @cm_print_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %20, i8* %0, i8* %1)
br label %27
27: ; preds = %3, %23, %25
%28 = phi i32 [ 0, %25 ], [ 1, %23 ], [ 1, %3 ]
ret i32 %28
}