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

/* Variables and functions */
scalar_t__ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, size_t);
char *osmo_hexdump_nospc(int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ printf(char *, char *);
int _compare_mem(uint8_t *x, uint8_t *y, size_t len) {
  if (0 != memcmp(x, y, len)) {
    printf("X: %s\t", osmo_hexdump_nospc(x, len));
    printf("Y: %s\n", osmo_hexdump_nospc(y, len));
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<_compare_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11a7 <_compare_mem+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <osmo_hexdump_nospc@plt>
mov    %rax,%rsi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <osmo_hexdump_nospc@plt>
mov    %rax,%rsi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ae <_compare_mem+0x7e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_compare_mem>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <memcmp@plt>
test   %rax,%rax
je     1180 <_compare_mem+0x50>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <osmo_hexdump_nospc@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <osmo_hexdump_nospc@plt>
lea    0xe93(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    1185 <_compare_mem+0x55>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"X: %s\09\00"
@.str.1 = [7 x i8] c"Y: %s\0A\00"
define i32 @_compare_mem(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i64 %2, i64* %7
%8 = load i32*, i32** %5
%9 = load i32*, i32** %6
%10 = load i64, i64* %7
%11 = call i64 @memcmp(i32* %8, i32* %9, i64 %10)
%12 = icmp ne i64 0, %11
br i1 %12, label %13, label %22
13: ; preds = %3
%14 = load i32*, i32** %5
%15 = load i64, i64* %7
%16 = call i8* @osmo_hexdump_nospc(i32* %14, i64 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32*, i32** %6
%19 = load i64, i64* %7
%20 = call i8* @osmo_hexdump_nospc(i32* %18, i64 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
store i32 0, i32* %4
br label %23
22: ; preds = %3
store i32 1, i32* %4
br label %23
23: ; preds = %22, %13
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [7 x i8] c"X: %s\09\00"
@.str.1 = [7 x i8] c"Y: %s\0A\00"
define i32 @_compare_mem(i32* %0, i32* %1, i64 %2) {
%4 = tail call i64 @memcmp(i32* %0, i32* %1, i64 %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i8* @osmo_hexdump_nospc(i32* %0, i64 %2)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = tail call i8* @osmo_hexdump_nospc(i32* %1, i64 %2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %3, %6
%12 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %12
}