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

/* Variables and functions */
size_t wcslen(int /*<<< orphan*/ const *);
scalar_t__ wmemcasecmp(int /*<<< orphan*/ const *, int /*<<< orphan*/ const *,
                       size_t);
wchar_t *(wcscasestarts)(const wchar_t *string, const wchar_t *desired) {
  size_t n = wcslen(string);
  size_t m = wcslen(desired);
  if (n < m)
    return NULL;
  return wmemcasecmp(string, desired, m) ? NULL : string;
}


x86 assembly (clang, -O0):
<wcscasestarts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <wcslen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <wcslen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1165 <wcscasestarts+0x45>
movq   $0x0,-0x8(%rbp)
jmp    119b <wcscasestarts+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <wmemcasecmp@plt>
cmp    $0x0,%rax
je     118b <wcscasestarts+0x6b>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    1193 <wcscasestarts+0x73>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcscasestarts>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <wcslen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <wcslen@plt>
cmp    %rax,%rbx
jae    1144 <wcscasestarts+0x24>
xor    %eax,%eax
jmp    115e <wcscasestarts+0x3e>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rax,%rdx
call   1040 <wmemcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
cmove  %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @wcscasestarts(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %4
%9 = call i64 @wcslen(i32* %8)
store i64 %9, i64* %6
%10 = load i32*, i32** %5
%11 = call i64 @wcslen(i32* %10)
store i64 %11, i64* %7
%12 = load i64, i64* %6
%13 = load i64, i64* %7
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %2
store i32* null, i32** %3
br label %27
16: ; preds = %2
%17 = load i32*, i32** %4
%18 = load i32*, i32** %5
%19 = load i64, i64* %7
%20 = call i64 @wmemcasecmp(i32* %17, i32* %18, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
br label %25
23: ; preds = %16
%24 = load i32*, i32** %4
br label %25
25: ; preds = %23, %22
%26 = phi i32* [ null, %22 ], [ %24, %23 ]
store i32* %26, i32** %3
br label %27
27: ; preds = %25, %15
%28 = load i32*, i32** %3
ret i32* %28
}

LLVM IR (-O2):
define i32* @wcscasestarts(i32* %0, i32* %1) {
%3 = tail call i64 @wcslen(i32* %0)
%4 = tail call i64 @wcslen(i32* %1)
%5 = icmp ult i64 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i64 @wmemcasecmp(i32* %0, i32* %1, i64 %4)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i32* %0, i32* null
br label %10
10: ; preds = %2, %6
%11 = phi i32* [ %9, %6 ], [ null, %2 ]
ret i32* %11
}