#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*/ printf(char *, ...);
void memcmp_print(void *a, void *b, size_t size) {
  char *ac = a, *bc = b;
  for (size_t i = 0; i < size; i++) {
    if (i > 0 && i % 4 == 0)
      printf(" ");
    if (i > 0 && i % 32 == 0)
      printf("\n");
    if (ac[i] == bc[i])
      printf("%02X", (unsigned char)ac[i]);
    else
      printf("\e[1;31m"
             "%02X"
             "\e[0m",
             (unsigned char)ac[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<memcmp_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    120f <memcmp_print+0xff>
cmpq   $0x0,-0x30(%rbp)
jbe    1175 <memcmp_print+0x65>
mov    -0x30(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
jne    1175 <memcmp_print+0x65>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
jbe    11a0 <memcmp_print+0x90>
mov    -0x30(%rbp),%rax
and    $0x1f,%rax
cmp    $0x0,%rax
jne    11a0 <memcmp_print+0x90>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11df <memcmp_print+0xcf>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <memcmp_print+0xe9>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fe <memcmp_print+0xee>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    113c <memcmp_print+0x2c>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcmp_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     11a5 <memcmp_print+0x85>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec0(%rip),%r12
lea    0xebe(%rip),%r13
xor    %ebp,%ebp
jmp    1160 <memcmp_print+0x40>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
je     11a5 <memcmp_print+0x85>
test   %rbp,%rbp
je     1179 <memcmp_print+0x59>
mov    %ebp,%eax
and    $0x3,%eax
test   %rax,%rax
jne    1179 <memcmp_print+0x59>
mov    $0x20,%edi
call   1030 <putchar@plt>
test   %rbp,%rbp
je     1192 <memcmp_print+0x72>
mov    %ebp,%eax
and    $0x1f,%eax
test   %rax,%rax
jne    1192 <memcmp_print+0x72>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl (%r15,%rbp,1),%esi
mov    %r12,%rdi
cmp    (%r14,%rbp,1),%sil
je     1150 <memcmp_print+0x30>
mov    %r13,%rdi
jmp    1150 <memcmp_print+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [16 x i8] c"\1B[1;31m%02X\1B[0m\00"
define void @memcmp_print(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%10 = load i8*, i8** %4
store i8* %10, i8** %7
%11 = load i8*, i8** %5
store i8* %11, i8** %8
store i64 0, i64* %9
br label %12
12: ; preds = %61, %3
%13 = load i64, i64* %9
%14 = load i64, i64* %6
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %64
16: ; preds = %12
%17 = load i64, i64* %9
%18 = icmp ugt i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i64, i64* %9
%21 = urem i64 %20, 4
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %19, %16
%26 = load i64, i64* %9
%27 = icmp ugt i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i64, i64* %9
%30 = urem i64 %29, 32
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %28, %25
%35 = load i8*, i8** %7
%36 = load i64, i64* %9
%37 = getelementptr inbounds i8, i8* %35, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = load i8*, i8** %8
%41 = load i64, i64* %9
%42 = getelementptr inbounds i8, i8* %40, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %39, %44
br i1 %45, label %46, label %53
46: ; preds = %34
%47 = load i8*, i8** %7
%48 = load i64, i64* %9
%49 = getelementptr inbounds i8, i8* %47, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %51)
br label %60
53: ; preds = %34
%54 = load i8*, i8** %7
%55 = load i64, i64* %9
%56 = getelementptr inbounds i8, i8* %54, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %53, %46
br label %61
61: ; preds = %60
%62 = load i64, i64* %9
%63 = add i64 %62, 1
store i64 %63, i64* %9
br label %12
64: ; preds = %12
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [16 x i8] c"\1B[1;31m%02X\1B[0m\00"
define void @memcmp_print(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %21, %3
%6 = tail call i32 @putchar(i32 10)
ret void
7: ; preds = %3, %21
%8 = phi i64 [ %30, %21 ], [ 0, %3 ]
%9 = icmp ne i64 %8, 0
%10 = and i64 %8, 3
%11 = icmp eq i64 %10, 0
%12 = and i1 %9, %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @putchar(i32 32)
br label %15
15: ; preds = %13, %7
%16 = and i64 %8, 31
%17 = icmp eq i64 %16, 0
%18 = and i1 %9, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @putchar(i32 10)
br label %21
21: ; preds = %19, %15
%22 = getelementptr inbounds i8, i8* %0, i64 %8
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %1, i64 %8
%25 = load i8, i8* %24
%26 = icmp eq i8 %23, %25
%27 = zext i8 %23 to i32
%28 = select i1 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i32 %27)
%30 = add nuw i64 %8, 1
%31 = icmp eq i64 %30, %2
br i1 %31, label %5, label %7
}