#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 */
scalar_t__ memcmp(void const *, void const *, size_t);
int /*<<< orphan*/ test_fail_memory_message(int /*<<< orphan*/ *, char const *,
                                            int, char *, char const *,
                                            char const *, char *, void const *,
                                            size_t, void const *, size_t);
int test_mem_eq(const char *file, int line, const char *st1, const char *st2,
                const void *s1, size_t n1, const void *s2, size_t n2) {
  if (s1 == NULL && s2 == NULL)
    return 1;
  if (n1 != n2 || s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {
    test_fail_memory_message(NULL, file, line, "memory", st1, st2, "==", s1, n1,
                             s2, n2);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_mem_eq>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    116c <test_mem_eq+0x4c>
cmpq   $0x0,0x10(%rbp)
jne    116c <test_mem_eq+0x4c>
movl   $0x1,-0x14(%rbp)
jmp    120c <test_mem_eq+0xec>
mov    -0x48(%rbp),%rax
cmp    0x18(%rbp),%rax
jne    11ab <test_mem_eq+0x8b>
cmpq   $0x0,-0x40(%rbp)
je     11ab <test_mem_eq+0x8b>
cmpq   $0x0,0x10(%rbp)
je     11ab <test_mem_eq+0x8b>
mov    -0x40(%rbp),%rdi
mov    0x10(%rbp),%rsi
mov    -0x48(%rbp),%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1205 <test_mem_eq+0xe5>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x40(%rbp),%rbx
mov    -0x48(%rbp),%r11
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edi
lea    0xe2b(%rip),%rcx
lea    0xe2b(%rip),%r14
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1030 <test_fail_memory_message@plt>
movl   $0x0,-0x14(%rbp)
jmp    120c <test_mem_eq+0xec>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mem_eq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    0x50(%rsp),%r13
mov    $0x1,%r14d
mov    %r8,%rax
or     %r13,%rax
je     11bf <test_mem_eq+0x9f>
mov    %r9,%r15
mov    %rcx,%r9
mov    %rdx,%r8
mov    %esi,%edx
mov    %rdi,%r12
mov    0x58(%rsp),%rbp
test   %r13,%r13
je     1195 <test_mem_eq+0x75>
test   %rbx,%rbx
je     1195 <test_mem_eq+0x75>
cmp    %rbp,%r15
jne    1195 <test_mem_eq+0x75>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %edx,0x4(%rsp)
mov    %r15,%rdx
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
call   1040 <memcmp@plt>
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%r8
mov    0x10(%rsp),%r9
test   %rax,%rax
je     11bf <test_mem_eq+0x9f>
sub    $0x8,%rsp
lea    0xe67(%rip),%rax
lea    0xe59(%rip),%rcx
xor    %r14d,%r14d
xor    %edi,%edi
mov    %r12,%rsi
push   %rbp
push   %r13
push   %r15
push   %rbx
push   %rax
call   1030 <test_fail_memory_message@plt>
add    $0x30,%rsp
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"memory\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_mem_eq(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i64 %5, i8* %6, i64 %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i64
store i8* %0, i8** %10
store i32 %1, i32* %11
store i8* %2, i8** %12
store i8* %3, i8** %13
store i8* %4, i8** %14
store i64 %5, i64* %15
store i8* %6, i8** %16
store i64 %7, i64* %17
%18 = load i8*, i8** %14
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %8
%21 = load i8*, i8** %16
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %9
br label %51
24: ; preds = %20, %8
%25 = load i64, i64* %15
%26 = load i64, i64* %17
%27 = icmp ne i64 %25, %26
br i1 %27, label %40, label %28
28: ; preds = %24
%29 = load i8*, i8** %14
%30 = icmp eq i8* %29, null
br i1 %30, label %40, label %31
31: ; preds = %28
%32 = load i8*, i8** %16
%33 = icmp eq i8* %32, null
br i1 %33, label %40, label %34
34: ; preds = %31
%35 = load i8*, i8** %14
%36 = load i8*, i8** %16
%37 = load i64, i64* %15
%38 = call i64 @memcmp(i8* %35, i8* %36, i64 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %34, %31, %28, %24
%41 = load i8*, i8** %10
%42 = load i32, i32* %11
%43 = load i8*, i8** %12
%44 = load i8*, i8** %13
%45 = load i8*, i8** %14
%46 = load i64, i64* %15
%47 = load i8*, i8** %16
%48 = load i64, i64* %17
%49 = call i32 @test_fail_memory_message(i32* null, i8* %41, i32 %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %43, i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %45, i64 %46, i8* %47, i64 %48)
store i32 0, i32* %9
br label %51
50: ; preds = %34
store i32 1, i32* %9
br label %51
51: ; preds = %50, %40, %23
%52 = load i32, i32* %9
ret i32 %52
}

LLVM IR (-O2):
@.str = [7 x i8] c"memory\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_mem_eq(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i64 %5, i8* %6, i64 %7) {
%9 = icmp eq i8* %4, null
%10 = icmp eq i8* %6, null
%11 = and i1 %9, %10
br i1 %11, label %21, label %12
12: ; preds = %8
%13 = icmp ne i64 %5, %7
%14 = or i1 %9, %13
%15 = or i1 %10, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = tail call i64 @memcmp(i8* %4, i8* %6, i64 %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16, %12
%20 = tail call i32 @test_fail_memory_message(i32* null, i8* %0, i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4, i64 %5, i8* %6, i64 %7)
br label %21
21: ; preds = %16, %8, %19
%22 = phi i32 [ 0, %19 ], [ 1, %8 ], [ 1, %16 ]
ret i32 %22
}