#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*/ exit(int);
int /*<<< orphan*/ printf(char *);
void verify(void *region, int c, size_t len) {
  char *r = region;
  while (len--)
    if (*(r++) != (char)c) {
      printf("Memeory failed to contain correct value!\n");
      exit(1);
    }
}


x86 assembly (clang, -O0):
<verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     118f <verify+0x6f>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%eax
mov    -0xc(%rbp),%ecx
movsbl %cl,%ecx
cmp    %ecx,%eax
je     118a <verify+0x6a>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    113b <verify+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify>:
push   %rax
movsbl %sil,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
cmp    %rcx,%rdx
je     1157 <verify+0x37>
movsbl (%rdi,%rcx,1),%esi
add    $0x1,%rcx
cmp    %esi,%eax
je     1130 <verify+0x10>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Memeory failed to contain correct value!\0A\00"
define void @verify(i8* %0, i32 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i64 %2, i64* %6
%8 = load i8*, i8** %4
store i8* %8, i8** %7
br label %9
9: ; preds = %25, %3
%10 = load i64, i64* %6
%11 = add i64 %10, -1
store i64 %11, i64* %6
%12 = icmp ne i64 %10, 0
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %7
%16 = load i8, i8* %14
%17 = sext i8 %16 to i32
%18 = load i32, i32* %5
%19 = trunc i32 %18 to i8
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %17, %20
br i1 %21, label %22, label %25
22: ; preds = %13
%23 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %13
br label %9
26: ; preds = %9
ret void
}

LLVM IR (-O2):
@str = [41 x i8] c"Memeory failed to contain correct value!\00"
define void @verify(i8* nocapture %0, i32 %1, i64 %2) {
%4 = shl i32 %1, 24
%5 = ashr exact i32 %4, 24
br label %6
6: ; preds = %10, %3
%7 = phi i64 [ %2, %3 ], [ %11, %10 ]
%8 = phi i8* [ %0, %3 ], [ %12, %10 ]
%9 = icmp eq i64 %7, 0
br i1 %9, label %19, label %10
10: ; preds = %6
%11 = add i64 %7, -1
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %8
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %5, %14
br i1 %15, label %6, label %16
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %6
ret void
}