#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char s[] = "ID=rna3;Parent=gene3;Dbxref=GeneID:106560213,Genbank:XM_"
             "014126719.1;Name=XM_014126719.1;gbkey=mRNA;           "
             "gene=LOC106560213;partial=true;product=phospholipase B1%2C "
             "membrane-associated-like;start_range=.,3827;transcript_id=XM_"
             "014126719.1";
  printf("String to look at:\n%s\n", s);
  char t[] = ":,=;";
  char *tk = strtok(s, t);
  printf("\n");
  if (tk == NULL) {
    printf("strtok returned NULL\n");
  } else
    printf("First strtok: \"%s\" (size=%zu)\n", tk, strlen(tk));
  while ((tk = strtok(NULL, t)) != NULL) {
    printf("\"%s\" (size=%zu)\n", tk, strlen(tk));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0xf2,%edx
call   1050 <memcpy@plt>
lea    -0x110(%rbp),%rsi
lea    0xf73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xf7d(%rip),%eax
mov    %eax,-0x115(%rbp)
mov    0xf75(%rip),%al
mov    %al,-0x111(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x115(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x120(%rbp)
lea    0xf82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x120(%rbp)
jne    11e7 <main+0xa7>
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1218 <main+0xd8>
mov    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121d <main+0xdd>
lea    -0x115(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0x120(%rbp)
cmp    $0x0,%rax
je     1274 <main+0x134>
mov    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x130(%rbp),%rsi
mov    %eax,%edx
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121d <main+0xdd>
xor    %eax,%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0xe8d(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    $0xf2,%edx
mov    %rbx,%rdi
call   1070 <memcpy@plt>
lea    0xf66(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x0,0xc(%rsp)
movl   $0x3b3d2c3a,0x8(%rsp)
3b
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strtok@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
je     11df <main+0x7f>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xf3d(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11eb <main+0x8b>
lea    0xf47(%rip),%rdi
call   1040 <puts@plt>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1080 <strtok@plt>
test   %rax,%rax
je     1239 <main+0xd9>
mov    %rax,%rbx
lea    0xf16(%rip),%r14
lea    0x8(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1080 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1210 <main+0xb0>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s = [242 x i8] c"ID=rna3;Parent=gene3;Dbxref=GeneID:106560213,Genbank:XM_014126719.1;Name=XM_014126719.1;gbkey=mRNA; gene=LOC106560213;partial=true;product=phospholipase B1%2C membrane-associated-like;start_range=.,3827;transcript_id=XM_014126719.1\00"
@.str = [23 x i8] c"String to look at:\0A%s\0A\00"
@__const.main.t = [5 x i8] c":,=;\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [22 x i8] c"strtok returned NULL\0A\00"
@.str.3 = [31 x i8] c"First strtok: \22%s\22 (size=%zu)\0A\00"
@.str.4 = [17 x i8] c"\22%s\22 (size=%zu)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [242 x i8]
%7 = alloca [5 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [242 x i8]* %6 to i8*
%10 = getelementptr inbounds [242 x i8], [242 x i8]* %6, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = bitcast [5 x i8]* %7 to i8*
%13 = getelementptr inbounds [242 x i8], [242 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%15 = call i8* @strtok(i8* %13, i8* %14)
store i8* %15, i8** %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %8
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %26
21: ; preds = %2
%22 = load i8*, i8** %8
%23 = load i8*, i8** %8
%24 = call i32 @strlen(i8* %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %22, i32 %24)
br label %26
26: ; preds = %21, %19
br label %27
27: ; preds = %31, %26
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%29 = call i8* @strtok(i8* null, i8* %28)
store i8* %29, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8*, i8** %8
%33 = load i8*, i8** %8
%34 = call i32 @strlen(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %32, i32 %34)
br label %27
36: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [242 x i8] c"ID=rna3;Parent=gene3;Dbxref=GeneID:106560213,Genbank:XM_014126719.1;Name=XM_014126719.1;gbkey=mRNA; gene=LOC106560213;partial=true;product=phospholipase B1%2C membrane-associated-like;start_range=.,3827;transcript_id=XM_014126719.1\00"
@.str = [23 x i8] c"String to look at:\0A%s\0A\00"
@__const.main.t = [5 x i8] c":,=;\00"
@.str.3 = [31 x i8] c"First strtok: \22%s\22 (size=%zu)\0A\00"
@.str.4 = [17 x i8] c"\22%s\22 (size=%zu)\0A\00"
@str = [21 x i8] c"strtok returned NULL\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [242 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [242 x i8], [242 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = call i8* @strtok(i8* %5, i8* %7)
%9 = call i32 @putchar(i32 10)
%10 = icmp eq i8* %8, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %16
13: ; preds = %2
%14 = call i32 @strlen(i8* %8)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %8, i32 %14)
br label %16
16: ; preds = %13, %11
%17 = call i8* @strtok(i8* null, i8* %7)
%18 = icmp eq i8* %17, null
br i1 %18, label %25, label %19
19: ; preds = %16, %19
%20 = phi i8* [ %23, %19 ], [ %17, %16 ]
%21 = call i32 @strlen(i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %20, i32 %21)
%23 = call i8* @strtok(i8* null, i8* %7)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %19
25: ; preds = %19, %16
ret i32 0
}