#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*/ printf(char *, int, unsigned char, unsigned char);
void data_check(unsigned char *data, unsigned char *rdata) {
  int i;
  for (i = 0; i < 1024; ++i) {
    if (rdata[i] != data[i])
      printf("Data error: offset %d written %02X read %02X.\n", i, data[i],
             rdata[i]);
  }
}


x86 assembly (clang, -O0):
<data_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    1190 <data_check+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     117d <data_check+0x6d>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
lea    0xe8f(%rip),%rdi
movzbl %dl,%edx
movzbl (%rax,%rcx,1),%ecx
call   1030 <printf@plt>
jmp    1182 <data_check+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <data_check+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_check>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
lea    0xed9(%rip),%r12
jmp    113d <data_check+0x2d>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x400,%rbx
je     115d <data_check+0x4d>
movzbl (%r14,%rbx,1),%eax
movzbl (%r15,%rbx,1),%ecx
cmp    %cl,%al
je     1130 <data_check+0x20>
movzbl %cl,%edx
movzbl %al,%ecx
mov    %r12,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1130 <data_check+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Data error: offset %d written %02X read %02X.\0A\00"
define void @data_check(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %37, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 1024
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp ne i32 %15, %21
br i1 %22, label %23, label %36
23: ; preds = %9
%24 = load i32, i32* %5
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %24, i8 zeroext %29, i8 zeroext %34)
br label %36
36: ; preds = %23, %9
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %6
40: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"Data error: offset %d written %02X read %02X.\0A\00"
define void @data_check(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %2, %13
%4 = phi i64 [ 0, %2 ], [ %14, %13 ]
%5 = getelementptr inbounds i8, i8* %1, i64 %4
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %0, i64 %4
%8 = load i8, i8* %7
%9 = icmp eq i8 %6, %8
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = trunc i64 %4 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %11, i8 zeroext %8, i8 zeroext %6)
br label %13
13: ; preds = %3, %10
%14 = add nuw nsw i64 %4, 1
%15 = icmp eq i64 %14, 1024
br i1 %15, label %16, label %3
16: ; preds = %13
ret void
}