#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*/ print_data(char const *, size_t);
int /*<<< orphan*/ stderr;
void check_data(int *err, const char *have, const char *want, size_t len,
                const char *test) {
  fprintf(stderr, "  %s: ", test);
  for (size_t i = 0; i < len; i++) {
    if (have[i] != want[i]) {
      fprintf(stderr, "FAIL\n    Want:");
      print_data(want, len);
      fprintf(stderr, "\n    Have:");
      print_data(have, len);
      fprintf(stderr, "\n");
      (*err)++;
      return;
    }
  }
  fprintf(stderr, "OK\n");
}


x86 assembly (clang, -O0):
<check_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xeb0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1212 <check_data+0xf2>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11fc <check_data+0xdc>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <print_data@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <print_data@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1229 <check_data+0x109>
jmp    1201 <check_data+0xe1>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    115f <check_data+0x3f>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_data>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2ea4(%rip),%r13
mov    0x0(%r13),%edi
lea    0xeb9(%rip),%rsi
mov    %r8,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r12,%r12
je     1173 <check_data+0x53>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rax,1),%ecx
cmp    (%rbx,%rax,1),%cl
jne    118e <check_data+0x6e>
add    $0x1,%rax
cmp    %rax,%r12
jne    1160 <check_data+0x40>
mov    0x0(%r13),%edi
lea    0xea3(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <print_data@plt>
mov    0x0(%r13),%edi
lea    0xe60(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <print_data@plt>
mov    0x0(%r13),%edi
lea    0xe50(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
addl   $0x1,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [7 x i8] c" %s: \00"
@.str.1 = [15 x i8] c"FAIL\0A Want:\00"
@.str.2 = [11 x i8] c"\0A Have:\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [4 x i8] c"OK\0A\00"
define void @check_data(i32* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %10
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %13)
store i64 0, i64* %11
br label %15
15: ; preds = %48, %5
%16 = load i64, i64* %11
%17 = load i64, i64* %9
%18 = icmp ult i64 %16, %17
br i1 %18, label %19, label %51
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = load i64, i64* %11
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = load i8*, i8** %8
%26 = load i64, i64* %11
%27 = getelementptr inbounds i8, i8* %25, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %24, %29
br i1 %30, label %31, label %47
31: ; preds = %19
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%34 = load i8*, i8** %8
%35 = load i64, i64* %9
%36 = call i32 @print_data(i8* %34, i64 %35)
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = load i8*, i8** %7
%40 = load i64, i64* %9
%41 = call i32 @print_data(i8* %39, i64 %40)
%42 = load i32, i32* @stderr
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32*, i32** %6
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
store i32 %46, i32* %44
br label %54
47: ; preds = %19
br label %48
48: ; preds = %47
%49 = load i64, i64* %11
%50 = add i64 %49, 1
store i64 %50, i64* %11
br label %15
51: ; preds = %15
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %31
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [7 x i8] c" %s: \00"
@.str.1 = [15 x i8] c"FAIL\0A Want:\00"
@.str.2 = [11 x i8] c"\0A Have:\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [4 x i8] c"OK\0A\00"
define void @check_data(i32* nocapture %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = icmp eq i64 %3, 0
br i1 %8, label %30, label %11
9: ; preds = %11
%10 = icmp eq i64 %18, %3
br i1 %10, label %30, label %11
11: ; preds = %5, %9
%12 = phi i64 [ %18, %9 ], [ 0, %5 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %2, i64 %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %14, %16
%18 = add nuw i64 %12, 1
br i1 %17, label %9, label %19
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @print_data(i8* %2, i64 %3)
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @print_data(i8* %1, i64 %3)
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* %0
%29 = add nsw i32 %28, 1
store i32 %29, i32* %0
br label %33
30: ; preds = %9, %5
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %19, %30
ret void
}