#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*/ const);
int wcsicmp(const wchar_t *s1, const wchar_t *s2) {
  for (;;) {
    int lc1 = towlower(*s1);
    int lc2 = towlower(*s2);
    int diff = lc1 - lc2;
    if (diff != 0)
      return diff;
    if (!lc1)
      return 0;
    ++s1;
    ++s2;
  }
  return -1;
}


x86 assembly (clang, -O0):
<wcsicmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <towlower@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1030 <towlower@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     115a <wcsicmp+0x4a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118d <wcsicmp+0x7d>
cmpl   $0x0,-0x1c(%rbp)
jne    1170 <wcsicmp+0x60>
movl   $0x0,-0x4(%rbp)
jmp    118d <wcsicmp+0x7d>
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <wcsicmp+0x10>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsicmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%edi
call   1030 <towlower@plt>
mov    %eax,%ebp
mov    (%r14),%edi
call   1030 <towlower@plt>
mov    %eax,%ecx
mov    %ebp,%eax
sub    %ecx,%eax
test   %ebp,%ebp
je     1176 <wcsicmp+0x66>
test   %eax,%eax
jne    1176 <wcsicmp+0x66>
mov    $0x4,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,1),%edi
call   1030 <towlower@plt>
mov    %eax,%ebp
mov    (%r14,%rbx,1),%edi
call   1030 <towlower@plt>
mov    %eax,%ecx
mov    %ebp,%eax
sub    %ecx,%eax
test   %ebp,%ebp
je     1176 <wcsicmp+0x66>
add    $0x4,%rbx
test   %eax,%eax
je     1150 <wcsicmp+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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