#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 memcmp(void *, void *, size_t);
int /*<<< orphan*/ memcmp_print(void *, void *, size_t);
int /*<<< orphan*/ printf(char *, ...);
int memcmp_inspect(void *a, char *aname, void *b, char *bname, size_t size) {
  int ret = memcmp(a, b, size);
  if (ret) {
    char *ac = a, *bc = b;
    printf("- %s -\n", aname);
    memcmp_print(a, b, size);
    printf("- %s -\n", bname);
    memcmp_print(b, a, size);
    printf("\n");
  }
  return ret;
}


x86 assembly (clang, -O0):
<memcmp_inspect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <memcmp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11ce <memcmp_inspect+0x9e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcmp_print@plt>
mov    -0x20(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcmp_print@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcmp_inspect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%rbx
mov    %rdx,%rsi
mov    %r8,%rdx
call   1050 <memcmp@plt>
mov    %eax,%r14d
test   %eax,%eax
je     11b4 <memcmp_inspect+0x74>
lea    0xe8d(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1060 <memcmp_print@plt>
lea    0xe6e(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1060 <memcmp_print@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"- %s -\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @memcmp_inspect(i8* %0, i8* %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i64 %4, i64* %10
%14 = load i8*, i8** %6
%15 = load i8*, i8** %8
%16 = load i64, i64* %10
%17 = call i32 @memcmp(i8* %14, i8* %15, i64 %16)
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %5
%21 = load i8*, i8** %6
store i8* %21, i8** %12
%22 = load i8*, i8** %8
store i8* %22, i8** %13
%23 = load i8*, i8** %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = load i8*, i8** %8
%27 = load i64, i64* %10
%28 = call i32 @memcmp_print(i8* %25, i8* %26, i64 %27)
%29 = load i8*, i8** %9
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i8*, i8** %8
%32 = load i8*, i8** %6
%33 = load i64, i64* %10
%34 = call i32 @memcmp_print(i8* %31, i8* %32, i64 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %20, %5
%37 = load i32, i32* %11
ret i32 %37
}

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