#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 *);
main() {
  char str[] = "- This, a   sample       string... .";
  char *pch;
  printf("Splitting string \"%s\" into tokens:\n", str);
  pch = strtok(str, " ,.-");
  while (pch != NULL) {
    printf("%s", pch);
    pch = strtok(NULL, " ,.-");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x25,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rsi
lea    0xec6(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xeda(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11ac <main+0x7c>
mov    -0x38(%rbp),%rsi
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xeab(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x38(%rbp)
jmp    1178 <main+0x48>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xee2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x2e202e2e2e676e,%rax
mov    %rax,0x1d(%rsp)
lea    0xed1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xee3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11aa <main+0x8a>
lea    0xed4(%rip),%r14
lea    0xec8(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   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    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [37 x i8] c"- This, a sample string... .\00"
@.str = [36 x i8] c"Splitting string \22%s\22 into tokens:\0A\00"
@.str.1 = [5 x i8] c" ,.-\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [37 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [37 x i8]* %2 to i8*
%5 = getelementptr inbounds [37 x i8], [37 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [37 x i8], [37 x i8]* %2, i64 0, i64 0
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %3
br label %9
9: ; preds = %12, %0
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %15, i8** %3
br label %9
16: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [37 x i8] c"- This, a sample string... .\00"
@.str = [36 x i8] c"Splitting string \22%s\22 into tokens:\0A\00"
@.str.1 = [5 x i8] c" ,.-\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [37 x i8]
%2 = getelementptr inbounds [37 x i8], [37 x i8]* %1, i64 0, i64 0
%3 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %0, %6
%7 = phi i8* [ %9, %6 ], [ %4, %0 ]
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %6
11: ; preds = %6, %0
ret i32 0
}