#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*/ fail(char const *, int, char *);
int /*<<< orphan*/ pass(char const *);
int /*<<< orphan*/ print_buffer(void const *, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ putstr(char *);
void check_mem(const void *actual, const void *expect, int bytes,
               const char *func, int line) {
  for (int i = 0; i < bytes; ++i) {
    if (((unsigned char *)actual)[i] != ((unsigned char *)expect)[i]) {
      fail(func, line, "");
      putstr("\texpect: ");
      print_buffer(expect, bytes);
      putstr("\n\tactual: ");
      print_buffer(actual, bytes);
      putchar('\n');
      return;
    }
  }
  pass(func);
}


x86 assembly (clang, -O0):
<check_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1203 <check_mem+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11f0 <check_mem+0xa0>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xe68(%rip),%rdx
call   1040 <fail@plt>
lea    0xe48(%rip),%rdi
call   1060 <putstr@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <print_buffer@plt>
lea    0xe3a(%rip),%rdi
call   1060 <putstr@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <print_buffer@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    120c <check_mem+0xbc>
jmp    11f5 <check_mem+0xa5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1172 <check_mem+0x22>
mov    -0x20(%rbp),%rdi
call   1050 <pass@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_mem>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1184 <check_mem+0x34>
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %edx,%eax
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rdx,1),%ebx
cmp    0x0(%rbp,%rdx,1),%bl
jne    1196 <check_mem+0x46>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1170 <check_mem+0x20>
mov    %rcx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <pass@plt>
lea    0xe77(%rip),%rdx
mov    %rcx,%rdi
mov    %r8d,%esi
call   1040 <fail@plt>
lea    0xe51(%rip),%rdi
call   1060 <putstr@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1070 <print_buffer@plt>
lea    0xe44(%rip),%rdi
call   1060 <putstr@plt>
mov    %r15,%rdi
mov    %r14d,%esi
call   1070 <print_buffer@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"\09expect: \00"
@.str.2 = [11 x i8] c"\0A\09actual: \00"
define void @check_mem(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %12
12: ; preds = %44, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %47
16: ; preds = %12
%17 = load i8*, i8** %6
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = load i8*, i8** %7
%24 = load i32, i32* %11
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %22, %28
br i1 %29, label %30, label %43
30: ; preds = %16
%31 = load i8*, i8** %9
%32 = load i32, i32* %10
%33 = call i32 @fail(i8* %31, i32 %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%34 = call i32 @putstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%35 = load i8*, i8** %7
%36 = load i32, i32* %8
%37 = call i32 @print_buffer(i8* %35, i32 %36)
%38 = call i32 @putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%39 = load i8*, i8** %6
%40 = load i32, i32* %8
%41 = call i32 @print_buffer(i8* %39, i32 %40)
%42 = call i32 @putchar(i8 signext 10)
br label %50
43: ; preds = %16
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
%46 = add nsw i32 %45, 1
store i32 %46, i32* %11
br label %12
47: ; preds = %12
%48 = load i8*, i8** %9
%49 = call i32 @pass(i8* %48)
br label %50
50: ; preds = %47, %30
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"\09expect: \00"
@.str.2 = [11 x i8] c"\0A\09actual: \00"
define void @check_mem(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %18, %8
br i1 %10, label %26, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %18, %9 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds i8, i8* %1, i64 %12
%16 = load i8, i8* %15
%17 = icmp eq i8 %14, %16
%18 = add nuw nsw i64 %12, 1
br i1 %17, label %9, label %19
19: ; preds = %11
%20 = tail call i32 @fail(i8* %3, i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @putstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @print_buffer(i8* %1, i32 %2)
%23 = tail call i32 @putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @print_buffer(i8* %0, i32 %2)
%25 = tail call i32 @putchar(i8 signext 10)
br label %28
26: ; preds = %9, %5
%27 = tail call i32 @pass(i8* %3)
br label %28
28: ; preds = %19, %26
ret void
}