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

/* Variables and functions */
int /*<<< orphan*/ strlcpy(char *, char const *, int);
char *strtok_r(char *, char *, char **);
char *nextcomp(const char *msgverb) {
  static char lmsgverb[sizeof("label:severity:text:action:tag")], *state;
  char *retval;
  if (*lmsgverb == '\0') {
    strlcpy(lmsgverb, msgverb, sizeof(lmsgverb));
    retval = strtok_r(lmsgverb, ":", &state);
  } else {
    retval = strtok_r(NULL, ":", &state);
  }
  if (retval == NULL)
    *lmsgverb = '\0';
  return (retval);
}


x86 assembly (clang, -O0):
<nextcomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movsbl 0x2f0d(%rip),%eax
cmp    $0x0,%eax
jne    1174 <nextcomp+0x54>
mov    -0x8(%rbp),%rsi
lea    0x2ef9(%rip),%rdi
mov    $0x1f,%edx
call   1040 <strlcpy@plt>
lea    0x2ee8(%rip),%rdi
lea    0xea1(%rip),%rsi
lea    0x2efa(%rip),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x10(%rbp)
jmp    118f <nextcomp+0x6f>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe81(%rip),%rsi
lea    0x2eda(%rip),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a1 <nextcomp+0x81>
movb   $0x0,0x2e9f(%rip)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextcomp>:
push   %rbx
cmpb   $0x0,0x2f18(%rip)
je     112e <nextcomp+0xe>
xor    %ebx,%ebx
jmp    1145 <nextcomp+0x25>
mov    %rdi,%rsi
lea    0x2f08(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1f,%edx
call   1040 <strlcpy@plt>
lea    0xeb4(%rip),%rsi
lea    0x2f0d(%rip),%rdx
mov    %rbx,%rdi
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1162 <nextcomp+0x42>
pop    %rbx
ret
movb   $0x0,0x2ed7(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@nextcomp.lmsgverb = internal global [31 x i8] zeroinitializer
@nextcomp.state = internal global i8* null
@.str = [2 x i8] c":\00"
define i8* @nextcomp(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0)
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @strlcpy(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0), i8* %8, i32 31)
%10 = call i8* @strtok_r(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** @nextcomp.state)
store i8* %10, i8** %3
br label %13
11: ; preds = %1
%12 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** @nextcomp.state)
store i8* %12, i8** %3
br label %13
13: ; preds = %11, %7
%14 = load i8*, i8** %3
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %13
store i8 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0)
br label %17
17: ; preds = %16, %13
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@nextcomp.lmsgverb = internal global [31 x i8] zeroinitializer
@nextcomp.state = internal global i8* null
@.str = [2 x i8] c":\00"
define i8* @nextcomp(i8* %0) {
%2 = load i8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0)
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @strlcpy(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0), i8* %0, i32 31)
br label %6
6: ; preds = %1, %4
%7 = phi i8* [ getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0), %4 ], [ null, %1 ]
%8 = tail call i8* @strtok_r(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** @nextcomp.state)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %6
store i8 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @nextcomp.lmsgverb, i64 0, i64 0)
br label %11
11: ; preds = %10, %6
ret i8* %8
}