#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 */
struct clad_test {
  int dummy;
};

/* Variables and functions */
struct clad_test *clad_test_assert(struct clad_test *, int, char *, void *,
                                   void *, char const *);
struct clad_test *clad_test_fail(struct clad_test *, char *, void *, void *,
                                 char const *);
scalar_t__ memcmp(void *, void *, size_t);
struct clad_test *clad_test_memeq(struct clad_test *test, void *m1, size_t n,
                                  void *m2, const char *explain) {
  if (!m2)
    return clad_test_fail(
        test, "Memory should be equal but pointer was null: %p %p; %s", m1, m2,
        explain);
  return clad_test_assert(test, memcmp(m1, m2, n) == 0,
                          "Memory should be equal: %p %p; %s ", m1, m2,
                          explain);
}


x86 assembly (clang, -O0):
<clad_test_memeq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    117c <clad_test_memeq+0x4c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe92(%rip),%rsi
call   1040 <clad_test_fail@plt>
mov    %rax,-0x8(%rbp)
jmp    11c1 <clad_test_memeq+0x91>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <memcmp@plt>
mov    -0x38(%rbp),%rdi
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%esi
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe7f(%rip),%rdx
call   1050 <clad_test_assert@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clad_test_memeq>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rsi,%r15
mov    %rdi,%r12
test   %rcx,%rcx
je     1180 <clad_test_memeq+0x50>
mov    %rcx,%rbx
mov    %r15,%rdi
mov    %rcx,%rsi
call   1030 <memcmp@plt>
xor    %esi,%esi
test   %rax,%rax
sete   %sil
lea    0xed3(%rip),%rdx
mov    %r12,%rdi
mov    %r15,%rcx
mov    %rbx,%r8
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <clad_test_assert@plt>
lea    0xe79(%rip),%rsi
mov    %r12,%rdi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %r14,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <clad_test_fail@plt>

LLVM IR (-O0):
%struct.clad_test = type { i32 }
@.str = [55 x i8] c"Memory should be equal but pointer was null: %p %p; %s\00"
@.str.1 = [35 x i8] c"Memory should be equal: %p %p; %s \00"
define %struct.clad_test* @clad_test_memeq(%struct.clad_test* %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca %struct.clad_test*
%7 = alloca %struct.clad_test*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
store %struct.clad_test* %0, %struct.clad_test** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%12 = load i8*, i8** %10
%13 = icmp ne i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %5
%15 = load %struct.clad_test*, %struct.clad_test** %7
%16 = load i8*, i8** %8
%17 = load i8*, i8** %10
%18 = load i8*, i8** %11
%19 = call %struct.clad_test* @clad_test_fail(%struct.clad_test* %15, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18)
store %struct.clad_test* %19, %struct.clad_test** %6
br label %32
20: ; preds = %5
%21 = load %struct.clad_test*, %struct.clad_test** %7
%22 = load i8*, i8** %8
%23 = load i8*, i8** %10
%24 = load i64, i64* %9
%25 = call i64 @memcmp(i8* %22, i8* %23, i64 %24)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = load i8*, i8** %8
%29 = load i8*, i8** %10
%30 = load i8*, i8** %11
%31 = call %struct.clad_test* @clad_test_assert(%struct.clad_test* %21, i32 %27, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29, i8* %30)
store %struct.clad_test* %31, %struct.clad_test** %6
br label %32
32: ; preds = %20, %14
%33 = load %struct.clad_test*, %struct.clad_test** %6
ret %struct.clad_test* %33
}

LLVM IR (-O2):
%struct.clad_test = type { i32 }
@.str = [55 x i8] c"Memory should be equal but pointer was null: %p %p; %s\00"
@.str.1 = [35 x i8] c"Memory should be equal: %p %p; %s \00"
define %struct.clad_test* @clad_test_memeq(%struct.clad_test* %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = icmp eq i8* %3, null
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call %struct.clad_test* @clad_test_fail(%struct.clad_test* %0, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %1, i8* null, i8* %4)
br label %14
9: ; preds = %5
%10 = tail call i64 @memcmp(i8* %1, i8* %3, i64 %2)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call %struct.clad_test* @clad_test_assert(%struct.clad_test* %0, i32 %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %3, i8* %4)
br label %14
14: ; preds = %9, %7
%15 = phi %struct.clad_test* [ %13, %9 ], [ %8, %7 ]
ret %struct.clad_test* %15
}