#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__ *wcssep(scalar_t__ **, scalar_t__ const *);
wchar_t *wcstok(wchar_t *restrict string, const wchar_t *restrict delimiters,
                wchar_t **restrict state) {
  wchar_t *r;
  if (string == NULL)
    *state = string;
  for (;;) {
    r = wcssep(state, delimiters);
    if (r == NULL)
      return NULL;
    if (*r)
      return r;
  }
}


x86 assembly (clang, -O0):
<wcstok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <wcstok+0x2a>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    113f <wcstok+0x2f>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <wcssep@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1168 <wcstok+0x58>
movq   $0x0,-0x8(%rbp)
jmp    1188 <wcstok+0x78>
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1183 <wcstok+0x73>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1188 <wcstok+0x78>
jmp    113f <wcstok+0x2f>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wcstok>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
test   %rdi,%rdi
jne    1130 <wcstok+0x20>
movq   $0x0,(%rbx)
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <wcssep@plt>
test   %rax,%rax
je     1146 <wcstok+0x36>
cmpq   $0x0,(%rax)
je     1130 <wcstok+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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