#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 towlower(int /*<<< orphan*/);
int wcscasecmp(const wchar_t *s1, const wchar_t *s2) {
  int d = 0;
  for (;;) {
    const int c1 = towlower(*s1++);
    const int c2 = towlower(*s2++);
    if (((d = c1 - c2) != 0) || (c2 == '\0'))
      break;
  }
  return d;
}


x86 assembly (clang, -O0):
<wcscasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%edi
call   1030 <towlower@plt>
mov    %eax,-0x18(%rbp)
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),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1175 <wcscasecmp+0x65>
cmpl   $0x0,-0x1c(%rbp)
jne    117a <wcscasecmp+0x6a>
jmp    117f <wcscasecmp+0x6f>
jmp    1127 <wcscasecmp+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%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    %ebx,%ebx
nop
mov    (%r15,%rbx,1),%edi
call   1030 <towlower@plt>
mov    %eax,%ebp
mov    (%r14,%rbx,1),%edi
call   1030 <towlower@plt>
sub    %eax,%ebp
test   %eax,%eax
je     1142 <wcscasecmp+0x32>
add    $0x4,%rbx
test   %ebp,%ebp
je     1120 <wcscasecmp+0x10>
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** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %8
8: ; preds = %25, %2
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i32 1
store i32* %10, i32** %3
%11 = load i32, i32* %9
%12 = call i32 @towlower(i32 %11)
store i32 %12, i32* %6
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %4
%15 = load i32, i32* %13
%16 = call i32 @towlower(i32 %15)
store i32 %16, i32* %7
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
store i32 %19, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %8
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21, %8
br label %26
25: ; preds = %21
br label %8
26: ; preds = %24
%27 = load i32, i32* %5
ret i32 %27
}

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