#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 scalar_t__ wchar_t;

/* Variables and functions */
scalar_t__ *wcsnsep(scalar_t__ **, scalar_t__ const *, size_t *);
wchar_t *wcsntok(wchar_t *restrict string, const wchar_t *restrict delimiters,
                 wchar_t **restrict state, size_t *restrict maxlen) {
  wchar_t *r;
  if (string == NULL)
    *state = string;
  for (;;) {
    r = wcsnsep(state, delimiters, maxlen);
    if (r == NULL)
      return NULL;
    if (*r)
      return r;
  }
}


x86 assembly (clang, -O0):
<wcsntok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113e <wcsntok+0x2e>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1143 <wcsntok+0x33>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <wcsnsep@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1170 <wcsntok+0x60>
movq   $0x0,-0x8(%rbp)
jmp    1190 <wcsntok+0x80>
mov    -0x30(%rbp),%rax
cmpq   $0x0,(%rax)
je     118b <wcsntok+0x7b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1190 <wcsntok+0x80>
jmp    1143 <wcsntok+0x33>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcsntok>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
test   %rdi,%rdi
jne    1130 <wcsntok+0x20>
movq   $0x0,(%rbx)
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <wcsnsep@plt>
test   %rax,%rax
je     1149 <wcsntok+0x39>
cmpq   $0x0,(%rax)
je     1130 <wcsntok+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64* @wcsntok(i64* noalias %0, i64* noalias %1, i64** noalias %2, i64* noalias %3) {
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64*
%8 = alloca i64**
%9 = alloca i64*
%10 = alloca i64*
store i64* %0, i64** %6
store i64* %1, i64** %7
store i64** %2, i64*** %8
store i64* %3, i64** %9
%11 = load i64*, i64** %6
%12 = icmp eq i64* %11, null
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i64*, i64** %6
%15 = load i64**, i64*** %8
store i64* %14, i64** %15
br label %16
16: ; preds = %13, %4
br label %17
17: ; preds = %31, %16
%18 = load i64**, i64*** %8
%19 = load i64*, i64** %7
%20 = load i64*, i64** %9
%21 = call i64* @wcsnsep(i64** %18, i64* %19, i64* %20)
store i64* %21, i64** %10
%22 = load i64*, i64** %10
%23 = icmp eq i64* %22, null
br i1 %23, label %24, label %25
24: ; preds = %17
store i64* null, i64** %5
br label %32
25: ; preds = %17
%26 = load i64*, i64** %10
%27 = load i64, i64* %26
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load i64*, i64** %10
store i64* %30, i64** %5
br label %32
31: ; preds = %25
br label %17
32: ; preds = %29, %24
%33 = load i64*, i64** %5
ret i64* %33
}

LLVM IR (-O2):
define i64* @wcsntok(i64* noalias readnone %0, i64* noalias %1, i64** noalias %2, i64* noalias %3) {
%5 = icmp eq i64* %0, null
br i1 %5, label %6, label %7
6: ; preds = %4
store i64* null, i64** %2
br label %7
7: ; preds = %6, %4
br label %8
8: ; preds = %7, %11
%9 = tail call i64* @wcsnsep(i64** %2, i64* %1, i64* %3)
%10 = icmp eq i64* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i64, i64* %9
%13 = icmp eq i64 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %11, %8
ret i64* %9
}