#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 towupper(int /*<<< orphan*/);
int wcscasecmp(const wchar_t *str1, const wchar_t *str2) {
  int c1;
  int c2;
  do {
    c1 = towupper(*(str1++));
    c2 = towupper(*(str2++));
  } while ((c1 != L'\0') && (c1 == c2));
  return (c1 - c2);
}


x86 assembly (clang, -O0):
<wcscasecmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%edi
call   1030 <towupper@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%edi
call   1030 <towupper@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x19(%rbp)
je     116d <wcscasecmp+0x5d>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1120 <wcscasecmp+0x10>
mov    -0x14(%rbp),%eax
sub    -0x18(%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 <towupper@plt>
mov    %eax,%ebp
mov    (%r14,%rbx,1),%edi
call   1030 <towupper@plt>
test   %ebp,%ebp
je     1140 <wcscasecmp+0x30>
add    $0x4,%rbx
cmp    %eax,%ebp
je     1120 <wcscasecmp+0x10>
sub    %eax,%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
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %7
7: ; preds = %23, %2
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i32 1
store i32* %9, i32** %3
%10 = load i32, i32* %8
%11 = call i32 @towupper(i32 %10)
store i32 %11, i32* %5
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i32 1
store i32* %13, i32** %4
%14 = load i32, i32* %12
%15 = call i32 @towupper(i32 %14)
store i32 %15, i32* %6
br label %16
16: ; preds = %7
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = icmp eq i32 %20, %21
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %7, label %25
25: ; preds = %23
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = sub nsw i32 %26, %27
ret i32 %28
}

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 @towupper(i32 %7)
%9 = getelementptr inbounds i32, i32* %4, i64 1
%10 = load i32, i32* %4
%11 = tail call i32 @towupper(i32 %10)
%12 = icmp ne i32 %8, 0
%13 = icmp eq i32 %8, %11
%14 = select i1 %12, i1 %13, i1 false
br i1 %14, label %3, label %15
15: ; preds = %3
%16 = sub nsw i32 %8, %11
ret i32 %16
}