#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 EOF;
int /*<<< orphan*/ getch();
int getchar();
int /*<<< orphan*/ printf(char *, char *);
char *strtok(char *, char *);
main() {
  char str[1000000];
  int i, c;
  for (i = 0; i <= 1000000 && (c = getchar()) != EOF; ++i) {
    str[i] = c;
  }
  char delims[] = " ";
  char *result = NULL;
  result = strtok(str, delims);
  while (result != NULL) {
    printf("result is \"%s\"\n", result);
    result = strtok(NULL, delims);
  }
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4270,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4254(%rbp)
xor    %eax,%eax
cmpl   $0xf4240,-0xf4254(%rbp)
mov    %al,-0xf4269(%rbp)
jg     1193 <main+0x53>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xf4258(%rbp)
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0xf4269(%rbp)
mov    -0xf4269(%rbp),%al
test   $0x1,%al
jne    11a6 <main+0x66>
jmp    11d0 <main+0x90>
mov    -0xf4258(%rbp),%eax
mov    %al,%cl
movslq -0xf4254(%rbp),%rax
mov    %cl,-0xf4250(%rbp,%rax,1)
mov    -0xf4254(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4254(%rbp)
jmp    115c <main+0x1c>
mov    0xe29(%rip),%ax
mov    %ax,-0xf425a(%rbp)
movq   $0x0,-0xf4268(%rbp)
lea    -0xf4250(%rbp),%rdi
lea    -0xf425a(%rbp),%rsi
call   1060 <strtok@plt>
mov    %rax,-0xf4268(%rbp)
cmpq   $0x0,-0xf4268(%rbp)
je     1240 <main+0x100>
mov    -0xf4268(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
lea    -0xf425a(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1060 <strtok@plt>
mov    %rax,-0xf4268(%rbp)
jmp    1203 <main+0xc3>
mov    $0x0,%al
call   1050 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0xf4270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xf4258,%rsp
mov    0x2e97(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     117d <main+0x3d>
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xf4241,%rbx
jne    1160 <main+0x20>
movw   $0x20,0xe(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     11ca <main+0x8a>
lea    0xe61(%rip),%r14
lea    0xe(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11b0 <main+0x70>
xor    %eax,%eax
call   1050 <getch@plt>
xor    %eax,%eax
add    $0xf4258,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@__const.main.delims = [2 x i8] c" \00"
@.str = [16 x i8] c"result is \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8]
%6 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %3
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 1000000
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = call i32 (...) @getchar()
store i32 %11, i32* %4
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %11, %12
br label %14
14: ; preds = %10, %7
%15 = phi i1 [ false, %7 ], [ %13, %10 ]
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = load i32, i32* %4
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %14
%26 = bitcast [2 x i8]* %5 to i8*
store i8* null, i8** %6
%27 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%29 = call i8* @strtok(i8* %27, i8* %28)
store i8* %29, i8** %6
br label %30
30: ; preds = %33, %25
%31 = load i8*, i8** %6
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = load i8*, i8** %6
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%37 = call i8* @strtok(i8* null, i8* %36)
store i8* %37, i8** %6
br label %30
38: ; preds = %30
%39 = call i32 (...) @getch()
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [16 x i8] c"result is \22%s\22\0A\00"
define i32 @main() {
%1 = alloca [1000000 x i8]
%2 = alloca i16
%3 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %9
%5 = phi i64 [ 0, %0 ], [ %12, %9 ]
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = trunc i32 %6 to i8
%11 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %1, i64 0, i64 %5
store i8 %10, i8* %11
%12 = add nuw nsw i64 %5, 1
%13 = icmp eq i64 %12, 1000001
br i1 %13, label %14, label %4
14: ; preds = %9, %4
%15 = bitcast i16* %2 to i8*
store i16 32, i16* %2
%16 = call i8* @strtok(i8* %3, i8* %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %23, label %18
18: ; preds = %14, %18
%19 = phi i8* [ %21, %18 ], [ %16, %14 ]
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i8* @strtok(i8* null, i8* %15)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %18
23: ; preds = %18, %14
%24 = call i32 (...) @getch()
ret i32 0
}