#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*/ interceptor_increaseBy(int);
__attribute__((optimize("0"))) int __memcmp(const void *m1, const void *m2,
                                            size_t n) {
  const char *s1 = (const char *)m1;
  const char *s2 = (const char *)m2;
  for (size_t i = 0; i < n; i++) {
    if (s1[i] != s2[i]) {
      return (s1[i] - s2[i]);
    }
    interceptor_increaseBy(1);
  }
  interceptor_increaseBy(5);
  return 0;
}


x86 assembly (clang, -O0):
<__memcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11a7 <__memcmp+0x97>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     118c <__memcmp+0x7c>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <__memcmp+0xa8>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    113c <__memcmp+0x2c>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__memcmp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1151 <__memcmp+0x41>
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%eax
movsbl (%r14,%rbx,1),%ecx
cmp    %cl,%al
jne    115f <__memcmp+0x4f>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <__memcmp+0x20>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
xor    %eax,%eax
jmp    1161 <__memcmp+0x51>
sub    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @__memcmp(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%11 = load i8*, i8** %5
store i8* %11, i8** %8
%12 = load i8*, i8** %6
store i8* %12, i8** %9
store i64 0, i64* %10
br label %13
13: ; preds = %43, %3
%14 = load i64, i64* %10
%15 = load i64, i64* %7
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %46
17: ; preds = %13
%18 = load i8*, i8** %8
%19 = load i64, i64* %10
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = load i8*, i8** %9
%24 = load i64, i64* %10
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %22, %27
br i1 %28, label %29, label %41
29: ; preds = %17
%30 = load i8*, i8** %8
%31 = load i64, i64* %10
%32 = getelementptr inbounds i8, i8* %30, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i8*, i8** %9
%36 = load i64, i64* %10
%37 = getelementptr inbounds i8, i8* %35, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = sub nsw i32 %34, %39
store i32 %40, i32* %4
br label %48
41: ; preds = %17
%42 = call i32 @interceptor_increaseBy(i32 1)
br label %43
43: ; preds = %41
%44 = load i64, i64* %10
%45 = add i64 %44, 1
store i64 %45, i64* %10
br label %13
46: ; preds = %13
%47 = call i32 @interceptor_increaseBy(i32 5)
store i32 0, i32* %4
br label %48
48: ; preds = %46, %29
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
define i32 @__memcmp(i8* nocapture %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %20, label %5
5: ; preds = %3, %16
%6 = phi i64 [ %18, %16 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %1, i64 %6
%10 = load i8, i8* %9
%11 = icmp eq i8 %8, %10
br i1 %11, label %16, label %12
12: ; preds = %5
%13 = sext i8 %10 to i32
%14 = sext i8 %8 to i32
%15 = sub nsw i32 %14, %13
br label %22
16: ; preds = %5
%17 = tail call i32 @interceptor_increaseBy(i32 1)
%18 = add nuw i64 %6, 1
%19 = icmp eq i64 %18, %2
br i1 %19, label %20, label %5
20: ; preds = %16, %3
%21 = tail call i32 @interceptor_increaseBy(i32 5)
br label %22
22: ; preds = %12, %20
%23 = phi i32 [ 0, %20 ], [ %15, %12 ]
ret i32 %23
}