#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*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, ...);
scalar_t__ memcmp(unsigned char const *, unsigned char const *, size_t);
int /*<<< orphan*/ stderr;
int compare_buffers(const unsigned char *b1, const unsigned char *b2, size_t l1,
                    size_t l2, const char *name1, const char *name2,
                    const char *func) {
  if (l1 != l2) {
    fprintf(stderr, "%s : EOF on %s\n", func, l1 < l2 ? name1 : name2);
    return -1;
  }
  if (memcmp(b1, b2, l1) != 0) {
    fprintf(stderr, "%s : difference between %s and %s\n", func, name1, name2);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare_buffers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     11ae <compare_buffers+0x8e>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1181 <compare_buffers+0x61>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1189 <compare_buffers+0x69>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdx
mov    -0x44(%rbp),%edi
mov    -0x50(%rbp),%rcx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <compare_buffers+0xdf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11f8 <compare_buffers+0xd8>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ff <compare_buffers+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_buffers>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%rbx
mov    %r8,%r15
mov    0x20(%rsp),%r14
cmp    %rcx,%rdx
jne    1161 <compare_buffers+0x41>
call   1030 <memcmp@plt>
test   %rax,%rax
je     1189 <compare_buffers+0x69>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    1182 <compare_buffers+0x62>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
cmovb  %r15,%rbx
lea    0xe8b(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    118b <compare_buffers+0x6b>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"%s : EOF on %s\0A\00"
@.str.1 = [35 x i8] c"%s : difference between %s and %s\0A\00"
define i32 @compare_buffers(i8* %0, i8* %1, i64 %2, i64 %3, i8* %4, i8* %5, i8* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %9
store i8* %1, i8** %10
store i64 %2, i64* %11
store i64 %3, i64* %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i8* %6, i8** %15
%16 = load i64, i64* %11
%17 = load i64, i64* %12
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %32
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %15
%22 = load i64, i64* %11
%23 = load i64, i64* %12
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = load i8*, i8** %13
br label %29
27: ; preds = %19
%28 = load i8*, i8** %14
br label %29
29: ; preds = %27, %25
%30 = phi i8* [ %26, %25 ], [ %28, %27 ]
%31 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %30)
store i32 -1, i32* %8
br label %45
32: ; preds = %7
%33 = load i8*, i8** %9
%34 = load i8*, i8** %10
%35 = load i64, i64* %11
%36 = call i64 @memcmp(i8* %33, i8* %34, i64 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %32
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %15
%41 = load i8*, i8** %13
%42 = load i8*, i8** %14
%43 = call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %41, i8* %42)
store i32 -1, i32* %8
br label %45
44: ; preds = %32
store i32 0, i32* %8
br label %45
45: ; preds = %44, %38, %29
%46 = load i32, i32* %8
ret i32 %46
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"%s : EOF on %s\0A\00"
@.str.1 = [35 x i8] c"%s : difference between %s and %s\0A\00"
define i32 @compare_buffers(i8* %0, i8* %1, i64 %2, i64 %3, i8* %4, i8* %5, i8* %6) {
%8 = icmp eq i64 %2, %3
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = load i32, i32* @stderr
%11 = icmp ult i64 %2, %3
%12 = select i1 %11, i8* %4, i8* %5
%13 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %12)
br label %20
14: ; preds = %7
%15 = tail call i64 @memcmp(i8* %0, i8* %1, i64 %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %4, i8* %5)
br label %20
20: ; preds = %14, %17, %9
%21 = phi i32 [ -1, %9 ], [ -1, %17 ], [ 0, %14 ]
ret i32 %21
}