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


x86 assembly (clang, -O0):
<strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
jne    1167 <strcasecmp+0x47>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1177 <strcasecmp+0x57>
jmp    11f8 <strcasecmp+0xd8>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
je     11dd <strcasecmp+0xbd>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1209 <strcasecmp+0xe9>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <strcasecmp+0x18>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %ebx,%ebx
nop
movzbl (%r14,%rbx,1),%eax
test   %al,%al
jne    1140 <strcasecmp+0x20>
cmpb   $0x0,(%r15,%rbx,1)
je     1182 <strcasecmp+0x62>
movsbl %al,%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
cmp    %eax,%ebp
jne    1168 <strcasecmp+0x48>
mov    $0x1,%edi
call   1030 <interceptor_increaseBy@plt>
add    $0x1,%rbx
jmp    1130 <strcasecmp+0x10>
movsbl (%r14,%rbx,1),%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
movsbl (%r15,%rbx,1),%edi
call   1040 <tolower@plt>
sub    %eax,%ebp
jmp    118e <strcasecmp+0x6e>
mov    $0x5,%edi
call   1030 <interceptor_increaseBy@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strcasecmp(i8* nocapture %0, i8* nocapture %1) {
br label %3
3: ; preds = %18, %2
%4 = phi i64 [ 0, %2 ], [ %20, %18 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = getelementptr inbounds i8, i8* %1, i64 %4
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %3, %8
%13 = tail call i32 @tolower(i8 signext %6)
%14 = getelementptr inbounds i8, i8* %1, i64 %4
%15 = load i8, i8* %14
%16 = tail call i32 @tolower(i8 signext %15)
%17 = icmp eq i32 %13, %16
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = tail call i32 @interceptor_increaseBy(i32 1)
%20 = add i64 %4, 1
br label %3
21: ; preds = %12
%22 = getelementptr inbounds i8, i8* %0, i64 %4
%23 = getelementptr inbounds i8, i8* %1, i64 %4
%24 = load i8, i8* %22
%25 = tail call i32 @tolower(i8 signext %24)
%26 = load i8, i8* %23
%27 = tail call i32 @tolower(i8 signext %26)
%28 = sub nsw i32 %25, %27
br label %31
29: ; preds = %8
%30 = tail call i32 @interceptor_increaseBy(i32 5)
br label %31
31: ; preds = %21, %29
%32 = phi i32 [ %28, %21 ], [ 0, %29 ]
ret i32 %32
}