#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 str[] = "Life is like, a box of chocolate, you never, know what you're, "
               "gonna get";
  char delims[] = ",";
  char *result;
  for (result = strtok(str, delims); result != NULL;
       result = strtok(NULL, delims))
    printf("%s \n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x49,%edx
call   1040 <memcpy@plt>
mov    0xeee(%rip),%ax
mov    %ax,-0x52(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x52(%rbp),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     11a1 <main+0x71>
mov    -0x60(%rbp),%rsi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
lea    -0x52(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <strtok@plt>
mov    %rax,-0x60(%rbp)
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
movups 0xf0b(%rip),%xmm0
movups %xmm0,0x49(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x2c,0xe(%rsp)
lea    0x10(%rsp),%rdi
lea    0xe(%rsp),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     11aa <main+0x8a>
lea    0xec4(%rip),%r14
lea    0xe(%rsp),%rbx
nopw   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    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [73 x i8] c"Life is like, a box of chocolate, you never, know what you're, gonna get\00"
@__const.main.delims = [2 x i8] c",\00"
@.str = [5 x i8] c"%s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [73 x i8]
%3 = alloca [2 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [73 x i8]* %2 to i8*
%6 = bitcast [2 x i8]* %3 to i8*
%7 = getelementptr inbounds [73 x i8], [73 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%9 = call i8* @strtok(i8* %7, i8* %8)
store i8* %9, i8** %4
br label %10
10: ; preds = %16, %0
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i8*, i8** %4
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%18 = call i8* @strtok(i8* null, i8* %17)
store i8* %18, i8** %4
br label %10
19: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [73 x i8] c"Life is like, a box of chocolate, you never, know what you're, gonna get\00"
@.str = [5 x i8] c"%s \0A\00"
define i32 @main() {
%1 = alloca [73 x i8]
%2 = alloca i16
%3 = getelementptr inbounds [73 x i8], [73 x i8]* %1, i64 0, i64 0
%4 = bitcast i16* %2 to i8*
store i16 44, i16* %2
%5 = call i8* @strtok(i8* %3, i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %0, %7
%8 = phi i8* [ %10, %7 ], [ %5, %0 ]
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i8* @strtok(i8* null, i8* %4)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %0
ret i32 0
}