#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*/ __tokencap_dump(char const *, int /*<<< orphan*/, int);
scalar_t__ __tokencap_is_ro(char const *);
int /*<<< orphan*/ strlen(char const *);
unsigned char tolower(char const);
int strcasecmp(const char *str1, const char *str2) {
  if (__tokencap_is_ro(str1))
    __tokencap_dump(str1, strlen(str1), 1);
  if (__tokencap_is_ro(str2))
    __tokencap_dump(str2, strlen(str2), 1);
  while (1) {
    unsigned char c1 = tolower(*str1), c2 = tolower(*str2);
    if (c1 != c2)
      return (c1 > c2) ? 1 : -1;
    if (!c1)
      return 0;
    str1++;
    str2++;
  }
}


x86 assembly (clang, -O0):
<strcasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <__tokencap_is_ro@plt>
cmp    $0x0,%rax
je     1184 <strcasecmp+0x44>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
mov    -0x18(%rbp),%rdi
call   1050 <__tokencap_is_ro@plt>
cmp    $0x0,%rax
je     11b8 <strcasecmp+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
jmp    11bd <strcasecmp+0x7d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1060 <tolower@plt>
mov    %al,-0x1a(%rbp)
movzbl -0x19(%rbp),%eax
movzbl -0x1a(%rbp),%ecx
cmp    %ecx,%eax
je     120a <strcasecmp+0xca>
movzbl -0x19(%rbp),%edx
movzbl -0x1a(%rbp),%esi
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovg  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    123d <strcasecmp+0xfd>
cmpb   $0x0,-0x19(%rbp)
jne    1220 <strcasecmp+0xe0>
movl   $0x0,-0x4(%rbp)
jmp    123d <strcasecmp+0xfd>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11bd <strcasecmp+0x7d>
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,%r14
mov    %rdi,%r15
call   1050 <__tokencap_is_ro@plt>
test   %rax,%rax
je     116e <strcasecmp+0x2e>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
mov    %r14,%rdi
call   1050 <__tokencap_is_ro@plt>
test   %rax,%rax
je     1192 <strcasecmp+0x52>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1030 <__tokencap_dump@plt>
movsbl (%r15),%edi
call   1060 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1060 <tolower@plt>
cmp    %al,%bpl
jne    11d4 <strcasecmp+0x94>
mov    $0x1,%ebx
test   %bpl,%bpl
je     11e4 <strcasecmp+0xa4>
movsbl (%r15,%rbx,1),%edi
call   1060 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14,%rbx,1),%edi
call   1060 <tolower@plt>
add    $0x1,%rbx
cmp    %al,%bpl
je     11b0 <strcasecmp+0x70>
xor    %ecx,%ecx
cmp    %al,%bpl
seta   %cl
lea    (%rcx,%rcx,1),%eax
add    $0xffffffff,%eax
jmp    11e6 <strcasecmp+0xa6>
xor    %eax,%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 i8
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i64 @__tokencap_is_ro(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @__tokencap_dump(i8* %12, i32 %14, i32 1)
br label %16
16: ; preds = %11, %2
%17 = load i8*, i8** %5
%18 = call i64 @__tokencap_is_ro(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @__tokencap_dump(i8* %21, i32 %23, i32 1)
br label %25
25: ; preds = %20, %16
br label %26
26: ; preds = %25, %50
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = call zeroext i8 @tolower(i8 signext %28)
store i8 %29, i8* %6
%30 = load i8*, i8** %5
%31 = load i8, i8* %30
%32 = call zeroext i8 @tolower(i8 signext %31)
store i8 %32, i8* %7
%33 = load i8, i8* %6
%34 = zext i8 %33 to i32
%35 = load i8, i8* %7
%36 = zext i8 %35 to i32
%37 = icmp ne i32 %34, %36
br i1 %37, label %38, label %46
38: ; preds = %26
%39 = load i8, i8* %6
%40 = zext i8 %39 to i32
%41 = load i8, i8* %7
%42 = zext i8 %41 to i32
%43 = icmp sgt i32 %40, %42
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 1, i32 -1
store i32 %45, i32* %3
br label %55
46: ; preds = %26
%47 = load i8, i8* %6
%48 = icmp ne i8 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
store i32 0, i32* %3
br label %55
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %5
br label %26
55: ; preds = %49, %38
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
define i32 @strcasecmp(i8* %0, i8* %1) {
%3 = tail call i64 @__tokencap_is_ro(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @__tokencap_dump(i8* %0, i32 %6, i32 1)
br label %8
8: ; preds = %5, %2
%9 = tail call i64 @__tokencap_is_ro(i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %1)
%13 = tail call i32 @__tokencap_dump(i8* %1, i32 %12, i32 1)
br label %14
14: ; preds = %11, %8
%15 = load i8, i8* %0
%16 = tail call zeroext i8 @tolower(i8 signext %15)
%17 = load i8, i8* %1
%18 = tail call zeroext i8 @tolower(i8 signext %17)
%19 = icmp eq i8 %16, %18
br i1 %19, label %25, label %20
20: ; preds = %30, %14
%21 = phi i8 [ %16, %14 ], [ %34, %30 ]
%22 = phi i8 [ %18, %14 ], [ %36, %30 ]
%23 = icmp ugt i8 %21, %22
%24 = select i1 %23, i32 1, i32 -1
br label %38
25: ; preds = %14, %30
%26 = phi i8 [ %34, %30 ], [ %16, %14 ]
%27 = phi i8* [ %31, %30 ], [ %0, %14 ]
%28 = phi i8* [ %32, %30 ], [ %1, %14 ]
%29 = icmp eq i8 %26, 0
br i1 %29, label %38, label %30
30: ; preds = %25
%31 = getelementptr inbounds i8, i8* %27, i64 1
%32 = getelementptr inbounds i8, i8* %28, i64 1
%33 = load i8, i8* %31
%34 = tail call zeroext i8 @tolower(i8 signext %33)
%35 = load i8, i8* %32
%36 = tail call zeroext i8 @tolower(i8 signext %35)
%37 = icmp eq i8 %34, %36
br i1 %37, label %25, label %20
38: ; preds = %25, %20
%39 = phi i32 [ %24, %20 ], [ 0, %25 ]
ret i32 %39
}