#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 *, unsigned char const);
char print_cmp(const unsigned char *const a, const unsigned char *const b) {
  char count = 0;
  for (unsigned char i = 0; i < 20; i++) {
    if (a[i] != b[i])
      printf("%02x", a[i]);
    else {
      printf("\x1B[7;32m%02x\x1B[0m", a[i]);
      count++;
    }
  }
  return count;
}


x86 assembly (clang, -O0):
<print_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movb   $0x0,-0x12(%rbp)
movzbl -0x12(%rbp),%eax
cmp    $0x14,%eax
jge    11a4 <print_cmp+0x94>
mov    -0x8(%rbp),%rax
movzbl -0x12(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movzbl -0x12(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1172 <print_cmp+0x62>
mov    -0x8(%rbp),%rax
movzbl -0x12(%rbp),%ecx
lea    0xe9c(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
jmp    1192 <print_cmp+0x82>
mov    -0x8(%rbp),%rax
movzbl -0x12(%rbp),%ecx
lea    0xe84(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1030 <printf@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1197 <print_cmp+0x87>
mov    -0x12(%rbp),%al
add    $0x1,%al
mov    %al,-0x12(%rbp)
jmp    1128 <print_cmp+0x18>
movsbl -0x11(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
xor    %ebp,%ebp
lea    0xedb(%rip),%r15
lea    0xecf(%rip),%r12
xor    %ebx,%ebx
jmp    1158 <print_cmp+0x48>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl %al,%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%bl
add    $0x1,%rbp
cmp    $0x14,%rbp
je     1171 <print_cmp+0x61>
movzbl 0x0(%r13,%rbp,1),%eax
cmp    (%r14,%rbp,1),%al
je     1140 <print_cmp+0x30>
movzbl %al,%esi
mov    %r12,%rdi
call   1030 <printf@plt>
jmp    114e <print_cmp+0x3e>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [16 x i8] c"\1B[7;32m%02x\1B[0m\00"
define signext i8 @print_cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8 0, i8* %5
store i8 0, i8* %6
br label %7
7: ; preds = %42, %2
%8 = load i8, i8* %6
%9 = zext i8 %8 to i32
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %45
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %6
%14 = zext i8 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = load i8*, i8** %4
%19 = load i8, i8* %6
%20 = zext i8 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %17, %23
br i1 %24, label %25, label %32
25: ; preds = %11
%26 = load i8*, i8** %3
%27 = load i8, i8* %6
%28 = zext i8 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %30)
br label %41
32: ; preds = %11
%33 = load i8*, i8** %3
%34 = load i8, i8* %6
%35 = zext i8 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %37)
%39 = load i8, i8* %5
%40 = add i8 %39, 1
store i8 %40, i8* %5
br label %41
41: ; preds = %32, %25
br label %42
42: ; preds = %41
%43 = load i8, i8* %6
%44 = add i8 %43, 1
store i8 %44, i8* %6
br label %7
45: ; preds = %7
%46 = load i8, i8* %5
ret i8 %46
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [16 x i8] c"\1B[7;32m%02x\1B[0m\00"
define signext i8 @print_cmp(i8* nocapture %0, i8* nocapture %1) {
br label %4
3: ; preds = %17
ret i8 %18
4: ; preds = %2, %17
%5 = phi i64 [ 0, %2 ], [ %19, %17 ]
%6 = phi i8 [ 0, %2 ], [ %18, %17 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 %5
%10 = load i8, i8* %9
%11 = icmp eq i8 %8, %10
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %8)
br label %17
14: ; preds = %4
%15 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %8)
%16 = add i8 %6, 1
br label %17
17: ; preds = %12, %14
%18 = phi i8 [ %6, %12 ], [ %16, %14 ]
%19 = add nuw nsw i64 %5, 1
%20 = icmp eq i64 %19, 20
br i1 %20, label %3, label %4
}