#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 */
typedef int wint_t;
typedef int /*<<< orphan*/ wchar_t;

/* Variables and functions */
int towlower(int /*<<< orphan*/);
int wcscasecmp(const wchar_t *s1, const wchar_t *s2) {
  wint_t c1, c2;
  if (s1 == s2)
    return 0;
  do {
    c1 = towlower(*s1++);
    c2 = towlower(*s2++);
    if (c1 == L'\0')
      break;
  } while (c1 == c2);
  return c1 - c2;
}


x86 assembly (clang, -O0):
<wcscasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    113a <wcscasecmp+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    119a <wcscasecmp+0x8a>
jmp    113f <wcscasecmp+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%edi
call   1030 <towlower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%edi
call   1030 <towlower@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1180 <wcscasecmp+0x70>
jmp    1191 <wcscasecmp+0x81>
jmp    1185 <wcscasecmp+0x75>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     113f <wcscasecmp+0x2f>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    %rsi,%rdi
je     1154 <wcscasecmp+0x44>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,1),%edi
call   1030 <towlower@plt>
mov    %eax,%ebp
mov    (%r14,%rbx,1),%edi
call   1030 <towlower@plt>
test   %ebp,%ebp
je     1150 <wcscasecmp+0x40>
add    $0x4,%rbx
cmp    %eax,%ebp
je     1130 <wcscasecmp+0x20>
sub    %eax,%ebp
jmp    1156 <wcscasecmp+0x46>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @wcscasecmp(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %4
%9 = load i32*, i32** %5
%10 = icmp eq i32* %8, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %34
12: ; preds = %2
br label %13
13: ; preds = %26, %12
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i32 1
store i32* %15, i32** %4
%16 = load i32, i32* %14
%17 = call i32 @towlower(i32 %16)
store i32 %17, i32* %6
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %5
%20 = load i32, i32* %18
%21 = call i32 @towlower(i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %13
br label %30
25: ; preds = %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = icmp eq i32 %27, %28
br i1 %29, label %13, label %30
30: ; preds = %26, %24
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %3
br label %34
34: ; preds = %30, %11
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @wcscasecmp(i32* %0, i32* %1) {
%3 = icmp eq i32* %0, %1
br i1 %3, label %18, label %4
4: ; preds = %2, %4
%5 = phi i32* [ %12, %4 ], [ %1, %2 ]
%6 = phi i32* [ %13, %4 ], [ %0, %2 ]
%7 = load i32, i32* %6
%8 = tail call i32 @towlower(i32 %7)
%9 = load i32, i32* %5
%10 = tail call i32 @towlower(i32 %9)
%11 = icmp ne i32 %8, 0
%12 = getelementptr inbounds i32, i32* %5, i64 1
%13 = getelementptr inbounds i32, i32* %6, i64 1
%14 = icmp eq i32 %8, %10
%15 = select i1 %11, i1 %14, i1 false
br i1 %15, label %4, label %16
16: ; preds = %4
%17 = sub nsw i32 %8, %10
br label %18
18: ; preds = %2, %16
%19 = phi i32 [ %17, %16 ], [ 0, %2 ]
ret i32 %19
}