#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*/ HF_cmphash(uintptr_t, char const *, char const *);
int /*<<< orphan*/ instrumentAddConstStr(char const *);
int /*<<< orphan*/ instrumentUpdateCmpMap(int /*<<< orphan*/, size_t);
int HF_strcmp(const char *s1, const char *s2, uintptr_t addr) {
  size_t i;
  for (i = 0; s1[i] == s2[i]; i++) {
    if (s1[i] == '\0' || s2[i] == '\0') {
      break;
    }
  }
  instrumentUpdateCmpMap(HF_cmphash(addr, s1, s2), i);
  instrumentAddConstStr(s1);
  instrumentAddConstStr(s2);
  return (unsigned char)s1[i] - (unsigned char)s2[i];
}


x86 assembly (clang, -O0):
<HF_strcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11b1 <HF_strcmp+0x81>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1196 <HF_strcmp+0x66>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    119b <HF_strcmp+0x6b>
jmp    11b1 <HF_strcmp+0x81>
jmp    11a0 <HF_strcmp+0x70>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <HF_strcmp+0x1c>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <HF_cmphash@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rsi
call   1050 <instrumentUpdateCmpMap@plt>
mov    -0x8(%rbp),%rdi
call   1040 <instrumentAddConstStr@plt>
mov    -0x10(%rbp),%rdi
call   1040 <instrumentAddConstStr@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movzbl (%rcx,%rdx,1),%ecx
sub    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HF_strcmp>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r8
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x1(%r14,%rax,1),%ecx
lea    0x1(%rax),%rbx
test   %cl,%cl
je     116f <HF_strcmp+0x3f>
movzbl 0x1(%r15,%rax,1),%edx
test   %dl,%dl
je     116f <HF_strcmp+0x3f>
mov    %rbx,%rax
cmp    %cl,%dl
je     1150 <HF_strcmp+0x20>
mov    %r8,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <HF_cmphash@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <instrumentUpdateCmpMap@plt>
mov    %r15,%rdi
call   1040 <instrumentAddConstStr@plt>
mov    %r14,%rdi
call   1040 <instrumentAddConstStr@plt>
movzbl (%r15,%rbx,1),%eax
movzbl (%r14,%rbx,1),%ecx
sub    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @HF_strcmp(i8* %0, i8* %1, i64 %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i64 [ 0, %3 ], [ %15, %4 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %1, i64 %5
%9 = load i8, i8* %8
%10 = icmp ne i8 %7, %9
%11 = icmp eq i8 %7, 0
%12 = or i1 %11, %10
%13 = icmp eq i8 %9, 0
%14 = or i1 %13, %12
%15 = add i64 %5, 1
br i1 %14, label %16, label %4
16: ; preds = %4
%17 = getelementptr inbounds i8, i8* %0, i64 %5
%18 = getelementptr inbounds i8, i8* %1, i64 %5
%19 = tail call i32 @HF_cmphash(i64 %2, i8* %0, i8* %1)
%20 = tail call i32 @instrumentUpdateCmpMap(i32 %19, i64 %5)
%21 = tail call i32 @instrumentAddConstStr(i8* %0)
%22 = tail call i32 @instrumentAddConstStr(i8* %1)
%23 = load i8, i8* %17
%24 = zext i8 %23 to i32
%25 = load i8, i8* %18
%26 = zext i8 %25 to i32
%27 = sub nsw i32 %24, %26
ret i32 %27
}