#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*/ memcmp(char *, char *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
void checkData(char *bufferIn, char *bufferOut, unsigned int elems) {
  int i;
  if (!memcmp(bufferIn, bufferOut, elems * sizeof(char))) {
    printf("DMA Ok!\n");
  } else {
    for (i = 0; i < elems; i++)
      printf("%d\t%d\t%d\t%d\n", i, bufferIn[i], bufferOut[i],
             (i == 0 ? 0 : bufferOut[i] - bufferOut[i - 1]));
  }
}


x86 assembly (clang, -O0):
<checkData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x0,%rax
mov    %eax,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    1165 <checkData+0x45>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1200 <checkData+0xe0>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11fb <checkData+0xdb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11b0 <checkData+0x90>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    11d2 <checkData+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%r8d
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <checkData+0x4c>
jmp    1200 <checkData+0xe0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
call   1050 <memcmp@plt>
test   %eax,%eax
je     11b2 <checkData+0x82>
test   %ebp,%ebp
je     11a9 <checkData+0x79>
movsbl (%r14),%edx
movsbl (%rbx),%ecx
lea    0xea5(%rip),%rdi
xor    %esi,%esi
xor    %r8d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebp
je     11a9 <checkData+0x79>
mov    %ebp,%r12d
mov    $0x1,%ebp
lea    0xe85(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbp,1),%edx
movsbl (%rbx,%rbp,1),%ecx
movsbl -0x1(%rbx,%rbp,1),%eax
mov    %ecx,%r8d
sub    %eax,%r8d
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1180 <checkData+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe54(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"DMA Ok!\0A\00"
@.str.1 = [13 x i8] c"%d\09%d\09%d\09%d\0A\00"
define void @checkData(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = zext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i32 @memcmp(i8* %8, i8* %9, i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %62
18: ; preds = %3
store i32 0, i32* %7
br label %19
19: ; preds = %58, %18
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %61
23: ; preds = %19
%24 = load i32, i32* %7
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %23
br label %55
40: ; preds = %23
%41 = load i8*, i8** %5
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = load i8*, i8** %5
%48 = load i32, i32* %7
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = sub nsw i32 %46, %53
br label %55
55: ; preds = %40, %39
%56 = phi i32 [ 0, %39 ], [ %54, %40 ]
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %30, i32 %36, i32 %56)
br label %58
58: ; preds = %55
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %19
61: ; preds = %19
br label %62
62: ; preds = %61, %16
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"%d\09%d\09%d\09%d\0A\00"
@str = [8 x i8] c"DMA Ok!\00"
define void @checkData(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @memcmp(i8* %0, i8* %1, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = icmp eq i32 %2, 0
br i1 %7, label %35, label %8
8: ; preds = %6
%9 = zext i32 %2 to i64
%10 = load i8, i8* %0
%11 = sext i8 %10 to i32
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %11, i32 %13, i32 0)
%15 = icmp eq i32 %2, 1
br i1 %15, label %35, label %18
16: ; preds = %3
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %35
18: ; preds = %8, %18
%19 = phi i64 [ %33, %18 ], [ 1, %8 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = getelementptr inbounds i8, i8* %1, i64 %19
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = add nsw i64 %19, -1
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %25, %29
%31 = trunc i64 %19 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %22, i32 %25, i32 %30)
%33 = add nuw nsw i64 %19, 1
%34 = icmp eq i64 %33, %9
br i1 %34, label %35, label %18
35: ; preds = %18, %8, %6, %16
ret void
}