#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 */

/* Variables and functions */
char *strnsep(char **, char const *, size_t *);
char *strntok(char *restrict string, const char *restrict delimiters,
              char **restrict state, size_t *restrict maxlen) {
  char *r;
  if (string == NULL)
    *state = string;
  for (;;) {
    r = strnsep(state, delimiters, maxlen);
    if (r == NULL)
      return NULL;
    if (*r)
      return r;
  }
}


x86 assembly (clang, -O0):
<strntok>:
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 <strntok+0x2e>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    1143 <strntok+0x33>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strnsep@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1170 <strntok+0x60>
movq   $0x0,-0x8(%rbp)
jmp    118f <strntok+0x7f>
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     118a <strntok+0x7a>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <strntok+0x7f>
jmp    1143 <strntok+0x33>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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