#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 *);
int main() {
  char message[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
  char *word;
  word = strtok(message, " ");
  printf("1st word: %s\n", word);
  word = strtok(NULL, " ");
  printf("2nd word: %s\n", word);
  while ((word = strtok(NULL, " ")) != NULL)
    printf("Next: %s\n", word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x39,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xeda(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xeb6(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe92(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     11cf <main+0x9f>
mov    -0x48(%rbp),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x6c>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movups 0xefb(%rip),%xmm0
movups %xmm0,0x29(%rsp)
movaps 0xee6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xedc(%rip),%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1040 <strtok@plt>
lea    0xecc(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
lea    0xec1(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11ca <main+0xaa>
lea    0xeb1(%rip),%r14
lea    0xe8c(%rip),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    11b0 <main+0x90>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.message = [57 x i8] c"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\00"
@.str = [2 x i8] c" \00"
@.str.1 = [14 x i8] c"1st word: %s\0A\00"
@.str.2 = [14 x i8] c"2nd word: %s\0A\00"
@.str.3 = [10 x i8] c"Next: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [57 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [57 x i8]* %2 to i8*
%5 = getelementptr inbounds [57 x i8], [57 x i8]* %2, i64 0, i64 0
%6 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %15, %0
%13 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %16)
br label %12
18: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@__const.main.message = [57 x i8] c"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\00"
@.str = [2 x i8] c" \00"
@.str.1 = [14 x i8] c"1st word: %s\0A\00"
@.str.2 = [14 x i8] c"2nd word: %s\0A\00"
@.str.3 = [10 x i8] c"Next: %s\0A\00"
define i32 @main() {
%1 = alloca [57 x i8]
%2 = getelementptr inbounds [57 x i8], [57 x i8]* %1, i64 0, i64 0
%3 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%5 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %0, %9
%10 = phi i8* [ %12, %9 ], [ %7, %0 ]
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %9
14: ; preds = %9, %0
ret i32 0
}