#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
char *strtok(char *, char *);
int main(void) {
  char text[80];
  char *array[80];
  int i = 0;
  char *token;
  int maxlen = 80;
  puts("Enter some text :");
  fgets(text, maxlen, stdin);
  token = strtok(text, " ");
  while (token != NULL) {
    printf("Token = %s\n", token);
    array[i] = token;
    token = strtok(NULL, " ");
    printf("Array %d is %s\n", i, array[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2e4(%rbp)
movl   $0x50,-0x2f4(%rbp)
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
mov    -0x2f4(%rbp),%esi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
lea    -0x60(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x2f0(%rbp)
cmpq   $0x0,-0x2f0(%rbp)
je     1228 <main+0xe8>
mov    -0x2f0(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2f0(%rbp),%rcx
movslq -0x2e4(%rbp),%rax
mov    %rcx,-0x2e0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x2f0(%rbp)
mov    -0x2e4(%rbp),%esi
movslq -0x2e4(%rbp),%rax
mov    -0x2e0(%rbp,%rax,8),%rdx
ff
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2e4(%rbp)
jmp    11a1 <main+0x61>
xor    %eax,%eax
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     11e4 <main+0xa4>
mov    %rax,%rbx
lea    0xe83(%rip),%r14
lea    0xe7a(%rip),%r15
lea    0xe81(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    %r13,%rbx
test   %r13,%r13
jne    11b0 <main+0x70>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter some text :\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [12 x i8] c"Token = %s\0A\00"
@.str.3 = [16 x i8] c"Array %d is %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca [80 x i8*]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 80, i32* %6
%7 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %6
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %8, i32 %9, i32 %10)
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %5
br label %14
14: ; preds = %17, %0
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %5
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [80 x i8*], [80 x i8*]* %3, i64 0, i64 %22
store i8* %20, i8** %23
%24 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %24, i8** %5
%25 = load i32, i32* %4
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [80 x i8*], [80 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %29)
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %14
33: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter some text :\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c" \00"
@.str.2 = [12 x i8] c"Token = %s\0A\00"
@.str.3 = [16 x i8] c"Array %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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 80, i32 %4)
%6 = call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %14, %8 ], [ 0, %0 ]
%10 = phi i8* [ %12, %8 ], [ %6, %0 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %9, i8* %10)
%14 = add nuw nsw i32 %9, 1
%15 = icmp eq i8* %12, null
br i1 %15, label %16, label %8
16: ; preds = %8, %0
ret i32 0
}