#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 scalar_t__ uint8_t;

/* Variables and functions */
scalar_t__ memcmp(scalar_t__ *, scalar_t__ *, int);
int /*<<< orphan*/ ts_LOGf(char *, ...);
void ts_compare_data(char *prefix, uint8_t *a, uint8_t *b, int size) {
  if (!a) {
    ts_LOGf("%s: !a\n", prefix);
    return;
  }
  if (!b) {
    ts_LOGf("%s: !b\n", prefix);
    return;
  }
  if (memcmp(a, b, size) == 0) {
    ts_LOGf("   **** %s generator is correct ****\n", prefix);
  } else {
    int i;
    for (i = 0; i < size; i++) {
      ts_LOGf("%03d - %02x %02x | %s\n", i, a[i], b[i],
              a[i] == b[i] ? "ok" : "err");
    }
  }
}


x86 assembly (clang, -O0):
<ts_compare_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1159 <ts_compare_data+0x39>
mov    -0x8(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <ts_LOGf@plt>
jmp    1228 <ts_compare_data+0x108>
cmpq   $0x0,-0x18(%rbp)
jne    117b <ts_compare_data+0x5b>
mov    -0x8(%rbp),%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <ts_LOGf@plt>
jmp    1228 <ts_compare_data+0x108>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11ac <ts_compare_data+0x8c>
mov    -0x8(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <ts_LOGf@plt>
jmp    1228 <ts_compare_data+0x108>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1223 <ts_compare_data+0x103>
mov    -0x20(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rdi
mov    (%rax,%rdi,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%r8
mov    (%rax,%r8,8),%r9
lea    0xe57(%rip),%r8
lea    0xe4d(%rip),%rax
cmp    %r9,%rdi
cmove  %rax,%r8
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <ts_LOGf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b3 <ts_compare_data+0x93>
jmp    1228 <ts_compare_data+0x108>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_compare_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
test   %rsi,%rsi
je     11ad <ts_compare_data+0x8d>
mov    %rdx,%r14
test   %rdx,%rdx
je     11b6 <ts_compare_data+0x96>
mov    %ecx,%ebx
mov    %rsi,%r12
mov    %rsi,%rdi
mov    %r14,%rsi
mov    %ecx,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11bf <ts_compare_data+0x9f>
test   %ebx,%ebx
jle    119e <ts_compare_data+0x7e>
mov    %ebx,%r13d
lea    0xef0(%rip),%rbp
lea    0xecf(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rdx
mov    (%r14,%rbx,8),%rcx
cmp    %rcx,%rdx
mov    %rbp,%r8
lea    0xec8(%rip),%rax
cmove  %rax,%r8
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <ts_LOGf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <ts_compare_data+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe4c(%rip),%rdi
jmp    11c6 <ts_compare_data+0xa6>
lea    0xe4b(%rip),%rdi
jmp    11c6 <ts_compare_data+0xa6>
lea    0xe4a(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <ts_LOGf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s: !a\0A\00"
@.str.1 = [8 x i8] c"%s: !b\0A\00"
@.str.2 = [38 x i8] c" **** %s generator is correct ****\0A\00"
@.str.3 = [23 x i8] c"%03d - %02x %02x | %s\0A\00"
@.str.4 = [3 x i8] c"ok\00"
@.str.5 = [4 x i8] c"err\00"
define void @ts_compare_data(i8* %0, i64* %1, i64* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i64* %1, i64** %6
store i64* %2, i64** %7
store i32 %3, i32* %8
%10 = load i64*, i64** %6
%11 = icmp ne i64* %10, null
br i1 %11, label %15, label %12
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = call i32 (i8*, ...) @ts_LOGf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %65
15: ; preds = %4
%16 = load i64*, i64** %7
%17 = icmp ne i64* %16, null
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @ts_LOGf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %65
21: ; preds = %15
%22 = load i64*, i64** %6
%23 = load i64*, i64** %7
%24 = load i32, i32* %8
%25 = call i64 @memcmp(i64* %22, i64* %23, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i8*, i8** %5
%29 = call i32 (i8*, ...) @ts_LOGf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %65
30: ; preds = %21
store i32 0, i32* %9
br label %31
31: ; preds = %61, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %64
35: ; preds = %31
%36 = load i32, i32* %9
%37 = load i64*, i64** %6
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i64, i64* %37, i64 %39
%41 = load i64, i64* %40
%42 = load i64*, i64** %7
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i64, i64* %42, i64 %44
%46 = load i64, i64* %45
%47 = load i64*, i64** %6
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i64, i64* %47, i64 %49
%51 = load i64, i64* %50
%52 = load i64*, i64** %7
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i64, i64* %52, i64 %54
%56 = load i64, i64* %55
%57 = icmp eq i64 %51, %56
%58 = zext i1 %57 to i64
%59 = select i1 %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%60 = call i32 (i8*, ...) @ts_LOGf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %36, i64 %41, i64 %46, i8* %59)
br label %61
61: ; preds = %35
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %31
64: ; preds = %31
br label %65
65: ; preds = %12, %18, %64, %27
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s: !a\0A\00"
@.str.1 = [8 x i8] c"%s: !b\0A\00"
@.str.2 = [38 x i8] c" **** %s generator is correct ****\0A\00"
@.str.3 = [23 x i8] c"%03d - %02x %02x | %s\0A\00"
@.str.4 = [3 x i8] c"ok\00"
@.str.5 = [4 x i8] c"err\00"
define void @ts_compare_data(i8* %0, i64* %1, i64* %2, i32 %3) {
%5 = icmp eq i64* %1, null
br i1 %5, label %27, label %6
6: ; preds = %4
%7 = icmp eq i64* %2, null
br i1 %7, label %27, label %8
8: ; preds = %6
%9 = tail call i64 @memcmp(i64* %1, i64* %2, i32 %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %8
%12 = icmp sgt i32 %3, 0
br i1 %12, label %13, label %30
13: ; preds = %11
%14 = zext i32 %3 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %25, %15 ]
%17 = getelementptr inbounds i64, i64* %1, i64 %16
%18 = load i64, i64* %17
%19 = getelementptr inbounds i64, i64* %2, i64 %16
%20 = load i64, i64* %19
%21 = icmp eq i64 %18, %20
%22 = select i1 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%23 = trunc i64 %16 to i32
%24 = tail call i32 (i8*, ...) @ts_LOGf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %23, i64 %18, i64 %20, i8* %22)
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, %14
br i1 %26, label %30, label %15
27: ; preds = %8, %6, %4
%28 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), %8 ]
%29 = tail call i32 (i8*, ...) @ts_LOGf(i8* %28, i8* %0)
br label %30
30: ; preds = %15, %27, %11
ret void
}