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

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int towlower(int /*<<< orphan*/ const);
int wcscasecmp(const wchar_t *s1, const wchar_t *s2) {
  assert(s1 != NULL);
  assert(s2 != NULL);
  for (;;) {
    int lc1 = towlower(*s1);
    int lc2 = towlower(*s2);
    int diff = lc1 - lc2;
    if (diff != 0)
      return diff;
    if (!lc1)
      return 0;
    ++s1;
    ++s2;
  }
}


x86 assembly (clang, -O0):
<wcscasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1040 <towlower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1040 <towlower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     118e <wcscasecmp+0x6e>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <wcscasecmp+0xa1>
cmpl   $0x0,-0x1c(%rbp)
jne    11a4 <wcscasecmp+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <wcscasecmp+0xa1>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1154 <wcscasecmp+0x34>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscasecmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    (%r15),%edi
call   1040 <towlower@plt>
mov    %eax,%ebp
mov    (%r14),%edi
call   1040 <towlower@plt>
mov    %eax,%ecx
mov    %ebp,%eax
sub    %ecx,%eax
test   %ebp,%ebp
je     1196 <wcscasecmp+0x76>
test   %eax,%eax
jne    1196 <wcscasecmp+0x76>
mov    $0x4,%ebx
xchg   %ax,%ax
mov    (%r15,%rbx,1),%edi
call   1040 <towlower@plt>
mov    %eax,%ebp
mov    (%r14,%rbx,1),%edi
call   1040 <towlower@plt>
mov    %eax,%ecx
mov    %ebp,%eax
sub    %ecx,%eax
test   %ebp,%ebp
je     1196 <wcscasecmp+0x76>
add    $0x4,%rbx
test   %eax,%eax
je     1170 <wcscasecmp+0x50>
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
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
br label %17
17: ; preds = %35, %2
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = call i32 @towlower(i32 %19)
store i32 %20, i32* %6
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = call i32 @towlower(i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = load i32, i32* %8
store i32 %30, i32* %3
br label %40
31: ; preds = %17
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %31
store i32 0, i32* %3
br label %40
35: ; preds = %31
%36 = load i32*, i32** %4
%37 = getelementptr inbounds i32, i32* %36, i32 1
store i32* %37, i32** %4
%38 = load i32*, i32** %5
%39 = getelementptr inbounds i32, i32* %38, i32 1
store i32* %39, i32** %5
br label %17
40: ; preds = %34, %29
%41 = load i32, i32* %3
ret i32 %41
}

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