#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 *, ...);
int /*<<< orphan*/ hexdump(unsigned char const *, size_t);
scalar_t__ memcmp(unsigned char const *, unsigned char const *, size_t);
int /*<<< orphan*/ stderr;
int compare_data(const char *label, const unsigned char *d1, size_t d1_len,
                 const unsigned char *d2, size_t d2_len) {
  if (d1_len != d2_len) {
    fprintf(stderr, "FAIL: got %s with length %zu, want %zu\n", label, d1_len,
            d2_len);
    return -1;
  }
  if (memcmp(d1, d2, d1_len) != 0) {
    fprintf(stderr, "FAIL: %s differs\n", label);
    fprintf(stderr, "got:\n");
    hexdump(d1, d1_len);
    fprintf(stderr, "want:\n");
    hexdump(d2, d2_len);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<compare_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1189 <compare_data+0x59>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121a <compare_data+0xea>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     1213 <compare_data+0xe3>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <hexdump@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <hexdump@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121a <compare_data+0xea>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%r12
cmp    %r8,%rdx
jne    11b5 <compare_data+0x85>
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rsi,%rdi
mov    %rcx,%rsi
mov    %rbx,%rdx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11d9 <compare_data+0xa9>
mov    0x2e7c(%rip),%r13
mov    0x0(%r13),%edi
lea    0xeb9(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xeb6(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <hexdump@plt>
mov    0x0(%r13),%edi
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <hexdump@plt>
jmp    11d2 <compare_data+0xa2>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11db <compare_data+0xab>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [40 x i8] c"FAIL: got %s with length %zu, want %zu\0A\00"
@.str.1 = [18 x i8] c"FAIL: %s differs\0A\00"
@.str.2 = [6 x i8] c"got:\0A\00"
@.str.3 = [7 x i8] c"want:\0A\00"
define i32 @compare_data(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = icmp eq i64 %2, %4
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %2, i64 %4)
br label %22
10: ; preds = %5
%11 = tail call i64 @memcmp(i8* %1, i8* %3, i64 %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @hexdump(i8* %1, i64 %2)
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 @hexdump(i8* %3, i64 %2)
br label %22
22: ; preds = %10, %13, %7
%23 = phi i32 [ -1, %7 ], [ -1, %13 ], [ 0, %10 ]
ret i32 %23
}