#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*/ fprintf(int /*<<< orphan*/, char *, int, unsigned char,
                           unsigned char);
int /*<<< orphan*/ stderr;
int do_memcmp(unsigned char *s1, unsigned char *s2, size_t n) {
  int i;
  for (i = 0; i < n; i++) {
    if (*s1 != *s2)
      goto missing;
    s1++;
    s2++;
  }
  return 0;
missing:
  fprintf(stderr, "off %x, right/current %x/%x\n", i, *s2, *s1);
  return -1;
}


x86 assembly (clang, -O0):
<do_memcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117a <do_memcmp+0x6a>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
je     1154 <do_memcmp+0x44>
jmp    1186 <do_memcmp+0x76>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112b <do_memcmp+0x1b>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <do_memcmp+0xa6>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
lea    0xe5d(%rip),%rsi
movzbl %cl,%ecx
movzbl (%rax),%r8d
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_memcmp>:
push   %rax
test   %rdx,%rdx
je     1135 <do_memcmp+0x25>
mov    %rdx,%r8
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movzbl (%rdi,%rdx,1),%eax
movzbl (%rsi,%rdx,1),%ecx
cmp    %cl,%al
jne    1139 <do_memcmp+0x29>
add    $0x1,%rdx
cmp    %rdx,%r8
jne    1120 <do_memcmp+0x10>
xor    %eax,%eax
pop    %rcx
ret
mov    0x2ea0(%rip),%rsi
mov    (%rsi),%edi
movzbl %cl,%ecx
movzbl %al,%r8d
lea    0xeb0(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"off %x, right/current %x/%x\0A\00"
define i32 @do_memcmp(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i32 0, i32* %8
br label %9
9: ; preds = %28, %3
%10 = load i32, i32* %8
%11 = sext i32 %10 to i64
%12 = load i64, i64* %7
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = load i8*, i8** %6
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %17, %20
br i1 %21, label %22, label %23
22: ; preds = %14
br label %32
23: ; preds = %14
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
br label %28
28: ; preds = %23
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %9
31: ; preds = %9
store i32 0, i32* %4
br label %40
32: ; preds = %22
%33 = load i32, i32* @stderr
%34 = load i32, i32* %8
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
%38 = load i8, i8* %37
%39 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %34, i8 zeroext %36, i8 zeroext %38)
store i32 -1, i32* %4
br label %40
40: ; preds = %32, %31
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"off %x, right/current %x/%x\0A\00"
define i32 @do_memcmp(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %21, label %5
5: ; preds = %3, %12
%6 = phi i64 [ %15, %12 ], [ 0, %3 ]
%7 = phi i8* [ %14, %12 ], [ %1, %3 ]
%8 = phi i8* [ %13, %12 ], [ %0, %3 ]
%9 = load i8, i8* %8
%10 = load i8, i8* %7
%11 = icmp eq i8 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %5
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = add nuw i64 %6, 1
%16 = icmp eq i64 %15, %2
br i1 %16, label %21, label %5
17: ; preds = %5
%18 = trunc i64 %6 to i32
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18, i8 zeroext %10, i8 zeroext %9)
br label %21
21: ; preds = %12, %3, %17
%22 = phi i32 [ -1, %17 ], [ 0, %3 ], [ 0, %12 ]
ret i32 %22
}