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


x86 assembly (clang, -O0):
<HF_strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rdx
movzbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rdx
movzbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    11c9 <HF_strcasecmp+0x99>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ae <HF_strcasecmp+0x7e>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11b3 <HF_strcasecmp+0x83>
jmp    11c9 <HF_strcasecmp+0x99>
jmp    11b8 <HF_strcasecmp+0x88>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1150 <HF_strcasecmp+0x20>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <HF_cmphash@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rsi
call   1050 <instrumentUpdateCmpMap@plt>
mov    -0x8(%rbp),%rdi
call   1040 <instrumentAddConstStr@plt>
mov    -0x10(%rbp),%rdi
call   1040 <instrumentAddConstStr@plt>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x28(%rbp),%rdx
movzbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rdx
movzbl (%rcx,%rdx,1),%edi
call   *%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HF_strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r12
movzbl (%rdi),%edi
call   *%rdx
mov    %eax,%ebx
movzbl (%r15),%edi
mov    %rbp,0x20(%rsp)
call   *%rbp
cmp    %eax,%ebx
jne    11db <HF_strcasecmp+0xab>
xor    %ebx,%ebx
mov    %r15,0x10(%rsp)
mov    %r12,0x8(%rsp)
mov    0x10(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,(%r12,%rbx,1)
je     11e6 <HF_strcasecmp+0xb6>
cmpb   $0x0,0x0(%rbp,%rbx,1)
je     11f9 <HF_strcasecmp+0xc9>
lea    0x1(%rbx),%r14
lea    (%r12,%rbx,1),%rax
add    $0x1,%rax
mov    %rax,0x8(%rsp)
movzbl 0x1(%r12,%rbx,1),%edi
mov    %r12,%r13
mov    0x20(%rsp),%r12
call   *%r12
mov    %eax,0x1c(%rsp)
lea    (%rbx,%rbp,1),%r15
add    $0x1,%r15
movzbl 0x1(%rbp,%rbx,1),%edi
call   *%r12
mov    %r13,%r12
mov    %r14,%rbx
cmp    %eax,0x1c(%rsp)
je     1180 <HF_strcasecmp+0x50>
mov    0x10(%rsp),%rbp
lea    (%r14,%rbp,1),%r15
jmp    11ee <HF_strcasecmp+0xbe>
xor    %r14d,%r14d
mov    %r12,%r13
mov    %r15,%rbp
jmp    1204 <HF_strcasecmp+0xd4>
mov    %rbx,%r14
mov    0x10(%rsp),%rbp
mov    (%rsp),%rdi
mov    0x8(%rsp),%r13
jmp    1208 <HF_strcasecmp+0xd8>
lea    (%rbx,%rbp,1),%r15
lea    (%r12,%rbx,1),%r13
mov    %rbx,%r14
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1030 <HF_cmphash@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <instrumentUpdateCmpMap@plt>
mov    %r12,%rdi
call   1040 <instrumentAddConstStr@plt>
mov    %rbp,%rdi
call   1040 <instrumentAddConstStr@plt>
movzbl 0x0(%r13),%edi
mov    0x20(%rsp),%rbp
call   *%rbp
mov    %eax,%ebx
movzbl (%r15),%edi
call   *%rbp
sub    %eax,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @HF_strcasecmp(i8* %0, i8* %1, i32 (i32)* nocapture %2, i64 %3) {
%5 = load i8, i8* %0
%6 = zext i8 %5 to i32
%7 = tail call i32 %2(i32 %6)
%8 = load i8, i8* %1
%9 = zext i8 %8 to i32
%10 = tail call i32 %2(i32 %9)
%11 = icmp eq i32 %7, %10
br i1 %11, label %12, label %32
12: ; preds = %4, %21
%13 = phi i8* [ %27, %21 ], [ %1, %4 ]
%14 = phi i8* [ %23, %21 ], [ %0, %4 ]
%15 = phi i64 [ %22, %21 ], [ 0, %4 ]
%16 = load i8, i8* %14
%17 = icmp eq i8 %16, 0
br i1 %17, label %32, label %18
18: ; preds = %12
%19 = load i8, i8* %13
%20 = icmp eq i8 %19, 0
br i1 %20, label %32, label %21
21: ; preds = %18
%22 = add i64 %15, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = tail call i32 %2(i32 %25)
%27 = getelementptr inbounds i8, i8* %1, i64 %22
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = tail call i32 %2(i32 %29)
%31 = icmp eq i32 %26, %30
br i1 %31, label %12, label %32
32: ; preds = %21, %18, %12, %4
%33 = phi i64 [ 0, %4 ], [ %15, %12 ], [ %15, %18 ], [ %22, %21 ]
%34 = phi i8* [ %0, %4 ], [ %14, %12 ], [ %14, %18 ], [ %23, %21 ]
%35 = phi i8* [ %1, %4 ], [ %13, %12 ], [ %13, %18 ], [ %27, %21 ]
%36 = tail call i32 @HF_cmphash(i64 %3, i8* %0, i8* %1)
%37 = tail call i32 @instrumentUpdateCmpMap(i32 %36, i64 %33)
%38 = tail call i32 @instrumentAddConstStr(i8* %0)
%39 = tail call i32 @instrumentAddConstStr(i8* %1)
%40 = load i8, i8* %34
%41 = zext i8 %40 to i32
%42 = tail call i32 %2(i32 %41)
%43 = load i8, i8* %35
%44 = zext i8 %43 to i32
%45 = tail call i32 %2(i32 %44)
%46 = sub nsw i32 %42, %45
ret i32 %46
}