#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 */
struct node {
  int dummy;
};

/* Variables and functions */
char *strtok(char const *, char *);
struct node *updateList(struct node *, char *);
struct node *addTokensToList(struct node *p, const char *sentence) {
  char *tokenPtr;
  tokenPtr = strtok(sentence, " .,;:?");
  while (tokenPtr != NULL) {
    p = updateList(p, tokenPtr);
    tokenPtr = strtok(NULL, " .,;:?");
  }
  return (p);
}


x86 assembly (clang, -O0):
<addTokensToList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1179 <addTokensToList+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <updateList@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe95(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    1144 <addTokensToList+0x24>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addTokensToList>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
mov    %rax,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     116d <addTokensToList+0x4d>
lea    0xebb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <updateList@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   1040 <strtok@plt>
test   %rax,%rax
jne    1150 <addTokensToList+0x30>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@.str = [7 x i8] c" .,;:?\00"
define %struct.node* @addTokensToList(%struct.node* %0, i8* %1) {
%3 = alloca %struct.node*
%4 = alloca i8*
%5 = alloca i8*
store %struct.node* %0, %struct.node** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %5
br label %8
8: ; preds = %11, %2
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load %struct.node*, %struct.node** %3
%13 = load i8*, i8** %5
%14 = call %struct.node* @updateList(%struct.node* %12, i8* %13)
store %struct.node* %14, %struct.node** %3
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %5
br label %8
16: ; preds = %8
%17 = load %struct.node*, %struct.node** %3
ret %struct.node* %17
}

LLVM IR (-O2):
%struct.node = type { i32 }
@.str = [7 x i8] c" .,;:?\00"
define %struct.node* @addTokensToList(%struct.node* %0, i8* %1) {
%3 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2, %5
%6 = phi i8* [ %9, %5 ], [ %3, %2 ]
%7 = phi %struct.node* [ %8, %5 ], [ %0, %2 ]
%8 = tail call %struct.node* @updateList(%struct.node* %7, i8* %6)
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %5
11: ; preds = %5, %2
%12 = phi %struct.node* [ %0, %2 ], [ %8, %5 ]
ret %struct.node* %12
}