#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 memcmp(void const *const, void const *const, size_t);
size_t objp_to_size(void *);
int ordering_err_2();
int compare_memr(void *context, const void *const *check,
                 const void *const *baseline) {
  size_t n;
  if (!check || !baseline)
    return ordering_err_2();
  if (!*check || !*baseline)
    return ordering_err_2();
  n = objp_to_size(context);
  if (n <= 0)
    return (
        ((((((0))) !=
           (((int)-(((int)0x37ED)
                    << (8 * (((!!(((!!(sizeof(int))) * ((sizeof(int)) - 1)))) *
                              ((((!!(sizeof(int))) * ((sizeof(int)) - 1))) -
                               1)))))))) &&
          ((((0))) !=
           (((int)-(((int)0x37EE)
                    << (8 * (((!!(((!!(sizeof(int))) * ((sizeof(int)) - 1)))) *
                              ((((!!(sizeof(int))) * ((sizeof(int)) - 1))) -
                               1))))))))))
            ? ((0))
            : (((((((0)))) <= ((0)))
                    ? ((((((0)))) < ((0)))
                           ? (((((int)-(((int)0x37EF)
                                        << (8 * (((!!(((!!(sizeof(int))) *
                                                       ((sizeof(int)) - 1)))) *
                                                  ((((!!(sizeof(int))) *
                                                     ((sizeof(int)) - 1))) -
                                                   1)))))))))
                           : (((0))))
                    : (((((int)-(((int)-(((int)0x37EF)
                                         << (8 * (((!!(((!!(sizeof(int))) *
                                                        ((sizeof(int)) - 1)))) *
                                                   ((((!!(sizeof(int))) *
                                                      ((sizeof(int)) - 1))) -
                                                    1))))))))))))));
  return (
      (((((memcmp(*check, *baseline, n))) !=
         (((int)-(((int)0x37ED)
                  << (8 * (((!!(((!!(sizeof(int))) * ((sizeof(int)) - 1)))) *
                            ((((!!(sizeof(int))) * ((sizeof(int)) - 1))) -
                             1)))))))) &&
        (((memcmp(*check, *baseline, n))) !=
         (((int)-(((int)0x37EE)
                  << (8 * (((!!(((!!(sizeof(int))) * ((sizeof(int)) - 1)))) *
                            ((((!!(sizeof(int))) * ((sizeof(int)) - 1))) -
                             1))))))))))
          ? (memcmp(*check, *baseline, n))
          : ((((((memcmp(*check, *baseline, n)))) <= ((0)))
                  ? (((((memcmp(*check, *baseline, n)))) < ((0)))
                         ? (((((int)-(((int)0x37EF)
                                      << (8 * (((!!(((!!(sizeof(int))) *
                                                     ((sizeof(int)) - 1)))) *
                                                ((((!!(sizeof(int))) *
                                                   ((sizeof(int)) - 1))) -
                                                 1)))))))))
                         : (((0))))
                  : (((((int)-(((int)-(
                        ((int)0x37EF)
                        << (8 *
                            (((!!(((!!(sizeof(int))) * ((sizeof(int)) - 1)))) *
                              ((((!!(sizeof(int))) * ((sizeof(int)) - 1))) -
                               1))))))))))))));
}


x86 assembly (clang, -O0):
<compare_memr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     115a <compare_memr+0x2a>
cmpq   $0x0,-0x20(%rbp)
jne    1169 <compare_memr+0x39>
mov    $0x0,%al
call   1040 <ordering_err_2@plt>
mov    %eax,-0x4(%rbp)
jmp    1282 <compare_memr+0x152>
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1185 <compare_memr+0x55>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1194 <compare_memr+0x64>
mov    $0x0,%al
call   1040 <ordering_err_2@plt>
mov    %eax,-0x4(%rbp)
jmp    1282 <compare_memr+0x152>
mov    -0x10(%rbp),%rdi
call   1050 <objp_to_size@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
ja     11b8 <compare_memr+0x88>
movl   $0x0,-0x4(%rbp)
jmp    1282 <compare_memr+0x152>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0xc8130000,%eax
je     121b <compare_memr+0xeb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0xc8120000,%eax
je     121b <compare_memr+0xeb>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <memcmp@plt>
mov    %eax,-0x2c(%rbp)
jmp    127c <compare_memr+0x14c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <memcmp@plt>
cmp    $0x0,%eax
jg     1269 <compare_memr+0x139>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <memcmp@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xc8110000,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x30(%rbp)
jmp    1276 <compare_memr+0x146>
mov    $0x37ef0000,%eax
mov    %eax,-0x30(%rbp)
jmp    1276 <compare_memr+0x146>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_memr>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     117f <compare_memr+0x4f>
mov    %rdx,%r14
test   %rdx,%rdx
je     117f <compare_memr+0x4f>
mov    %rsi,%rbx
cmpq   $0x0,(%rsi)
je     117f <compare_memr+0x4f>
cmpq   $0x0,(%r14)
je     117f <compare_memr+0x4f>
call   1050 <objp_to_size@plt>
test   %rax,%rax
je     118d <compare_memr+0x5d>
mov    (%rbx),%rdi
mov    (%r14),%rsi
mov    %rax,%rdx
call   1030 <memcmp@plt>
mov    %eax,%ecx
or     $0x10000,%ecx
cmp    $0xc8130000,%ecx
jne    118f <compare_memr+0x5f>
mov    $0xc8110000,%eax
jmp    118f <compare_memr+0x5f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <ordering_err_2@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @compare_memr(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = load i8**, i8*** %6
%10 = icmp ne i8** %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8**, i8*** %7
%13 = icmp ne i8** %12, null
br i1 %13, label %16, label %14
14: ; preds = %11, %3
%15 = call i32 (...) @ordering_err_2()
store i32 %15, i32* %4
br label %78
16: ; preds = %11
%17 = load i8**, i8*** %6
%18 = load i8*, i8** %17
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8**, i8*** %7
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %26, label %24
24: ; preds = %20, %16
%25 = call i32 (...) @ordering_err_2()
store i32 %25, i32* %4
br label %78
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = call i64 @objp_to_size(i8* %27)
store i64 %28, i64* %8
%29 = load i64, i64* %8
%30 = icmp ule i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 0, i32* %4
br label %78
32: ; preds = %26
%33 = load i8**, i8*** %6
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %7
%36 = load i8*, i8** %35
%37 = load i64, i64* %8
%38 = call i32 @memcmp(i8* %34, i8* %36, i64 %37)
%39 = icmp ne i32 %38, -938278912
br i1 %39, label %40, label %55
40: ; preds = %32
%41 = load i8**, i8*** %6
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %7
%44 = load i8*, i8** %43
%45 = load i64, i64* %8
%46 = call i32 @memcmp(i8* %42, i8* %44, i64 %45)
%47 = icmp ne i32 %46, -938344448
br i1 %47, label %48, label %55
48: ; preds = %40
%49 = load i8**, i8*** %6
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %7
%52 = load i8*, i8** %51
%53 = load i64, i64* %8
%54 = call i32 @memcmp(i8* %50, i8* %52, i64 %53)
br label %76
55: ; preds = %40, %32
%56 = load i8**, i8*** %6
%57 = load i8*, i8** %56
%58 = load i8**, i8*** %7
%59 = load i8*, i8** %58
%60 = load i64, i64* %8
%61 = call i32 @memcmp(i8* %57, i8* %59, i64 %60)
%62 = icmp sle i32 %61, 0
br i1 %62, label %63, label %73
63: ; preds = %55
%64 = load i8**, i8*** %6
%65 = load i8*, i8** %64
%66 = load i8**, i8*** %7
%67 = load i8*, i8** %66
%68 = load i64, i64* %8
%69 = call i32 @memcmp(i8* %65, i8* %67, i64 %68)
%70 = icmp slt i32 %69, 0
%71 = zext i1 %70 to i64
%72 = select i1 %70, i32 -938409984, i32 0
br label %74
73: ; preds = %55
br label %74
74: ; preds = %73, %63
%75 = phi i32 [ %72, %63 ], [ 938409984, %73 ]
br label %76
76: ; preds = %74, %48
%77 = phi i32 [ %54, %48 ], [ %75, %74 ]
store i32 %77, i32* %4
br label %78
78: ; preds = %76, %31, %24, %14
%79 = load i32, i32* %4
ret i32 %79
}

LLVM IR (-O2):
define i32 @compare_memr(i8* %0, i8** %1, i8** %2) {
%4 = icmp ne i8** %1, null
%5 = icmp ne i8** %2, null
%6 = and i1 %4, %5
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 (...) @ordering_err_2()
br label %25
9: ; preds = %3
%10 = load i8*, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12, %9
%16 = tail call i32 (...) @ordering_err_2()
br label %25
17: ; preds = %12
%18 = tail call i64 @objp_to_size(i8* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i8*, i8** %1
%22 = load i8*, i8** %2
%23 = tail call i32 @memcmp(i8* %21, i8* %22, i64 %18)
switch i32 %23, label %25 [
i32 -938278912, label %24
i32 -938344448, label %24
]
24: ; preds = %20, %20
br label %25
25: ; preds = %24, %20, %17, %15, %7
%26 = phi i32 [ %16, %15 ], [ %8, %7 ], [ 0, %17 ], [ -938409984, %24 ], [ %23, %20 ]
ret i32 %26
}