#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 *, char *);
char *strtok(char *, char const *);
int main() {
  char str[80] = "Idle|WPos:0.0000,0.0000,0.0000|Bf:15,128|FS:0.0,0|WCO:0.0000,"
                 "0.0000,0.0000";
  const char s[2] = "|";
  char *token;
  token = strtok(str, s);
  while (token != NULL) {
    printf("%s\n", token);
    token = strtok(NULL, s);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
mov    0xef5(%rip),%ax
mov    %ax,-0x62(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x62(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     11a1 <main+0x71>
mov    -0x70(%rbp),%rsi
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
lea    -0x62(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x70(%rbp)
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x7c,0xe(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11aa <main+0x8a>
lea    0xecb(%rip),%r14
lea    0xe(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1190 <main+0x70>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [80 x i8] c"Idle|WPos:0.0000,0.0000,0.0000|Bf:15,128|FS:0.0,0|WCO:0.0000,0.0000,0.0000\00\00\00\00\00\00"
@__const.main.s = [2 x i8] c"|\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [2 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [80 x i8]* %2 to i8*
%6 = bitcast [2 x i8]* %3 to i8*
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%9 = call i8* @strtok(i8* %7, i8* %8)
store i8* %9, i8** %4
br label %10
10: ; preds = %13, %0
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%17 = call i8* @strtok(i8* null, i8* %16)
store i8* %17, i8** %4
br label %10
18: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [80 x i8] c"Idle|WPos:0.0000,0.0000,0.0000|Bf:15,128|FS:0.0,0|WCO:0.0000,0.0000,0.0000\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = alloca i16
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = bitcast i16* %2 to i8*
store i16 124, i16* %2
%5 = call i8* @strtok(i8* %3, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = phi i8* [ %10, %7 ], [ %5, %0 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @strtok(i8* null, i8* %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %0
ret i32 0
}