#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 *strtok(char *, char *);
int main() {
  char *mystuff[80];
  int i = 0;
  char *token;
  char text[80] = "Peter Piper picked a peck of pickled peppers.";
  token = strtok(text, " ");
  while (token != NULL) {
    printf("Token = %s\n", token);
    mystuff[i] = token;
    token = strtok(NULL, " ");
    printf("Array element %d is %s\n", i, mystuff[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x294(%rbp)
lea    -0x2f0(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
lea    -0x2f0(%rbp),%rdi
lea    0xede(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x2a0(%rbp)
cmpq   $0x0,-0x2a0(%rbp)
je     1205 <main+0xd5>
mov    -0x2a0(%rbp),%rsi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2a0(%rbp),%rcx
movslq -0x294(%rbp),%rax
mov    %rcx,-0x290(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe8e(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x2a0(%rbp)
mov    -0x294(%rbp),%esi
movslq -0x294(%rbp),%rax
mov    -0x290(%rbp,%rax,8),%rdx
ff
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x294(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x294(%rbp)
jmp    117e <main+0x4e>
xor    %eax,%eax
add    $0x2f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movaps 0xf0b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeef(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee0(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11d4 <main+0xb4>
mov    %rax,%rbx
lea    0xecb(%rip),%r14
lea    0xec2(%rip),%r15
lea    0xec9(%rip),%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
mov    %r13,%rbx
test   %r13,%r13
jne    11a0 <main+0x80>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.text = [80 x i8] c"Peter Piper picked a peck of pickled peppers.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c" \00"
@.str.1 = [12 x i8] c"Token = %s\0A\00"
@.str.2 = [24 x i8] c"Array element %d is %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8*]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [80 x i8]
store i32 0, i32* %1
store i32 0, i32* %3
%6 = bitcast [80 x i8]* %5 to i8*
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%8 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
br label %9
9: ; preds = %12, %0
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %4
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [80 x i8*], [80 x i8*]* %2, i64 0, i64 %17
store i8* %15, i8** %18
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
%20 = load i32, i32* %3
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [80 x i8*], [80 x i8*]* %2, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %20, i8* %24)
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %9
28: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.text = [80 x i8] c"Peter Piper picked a peck of pickled peppers.\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c" \00"
@.str.1 = [12 x i8] c"Token = %s\0A\00"
@.str.2 = [24 x i8] c"Array element %d is %s\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 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 = icmp eq i8* %3, null
br i1 %4, label %13, label %5
5: ; preds = %0, %5
%6 = phi i8* [ %9, %5 ], [ %3, %0 ]
%7 = phi i32 [ %11, %5 ], [ 0, %0 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %7, i8* %6)
%11 = add nuw nsw i32 %7, 1
%12 = icmp eq i8* %9, null
br i1 %12, label %13, label %5
13: ; preds = %5, %0
ret i32 0
}