#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 */
typedef int /*<<< orphan*/ token;

/* Variables and functions */
int issep(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void tokenise(char *str) {
  char *ptr = NULL;
  ptr = str;
  int numchars = 1;
  char token[80];
  int ret = 0;
  while (*str != '\0') {
    ret = issep(ptr);
    if (ret == 0) {
      numchars++;
    } else if (ret == 1) {
      strncpy(token, str, numchars);
      token[numchars + 1] = '\0';
      printf("Token: %s \n", token);
      numchars = 1;
      str = ptr;
    }
    memset(&token[0], 0, sizeof(token));
    ptr++;
  }
}


x86 assembly (clang, -O0):
<tokenise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120d <tokenise+0xcd>
mov    -0x10(%rbp),%rdi
call   1060 <issep@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jne    11a1 <tokenise+0x61>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ec <tokenise+0xac>
cmpl   $0x1,-0x74(%rbp)
jne    11e7 <tokenise+0xa7>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rsi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ec <tokenise+0xac>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116d <tokenise+0x2d>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenise>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
cmpb   $0x0,(%rdi)
je     11cb <tokenise+0x8b>
mov    %rdi,%rbx
mov    $0x1,%r12d
mov    %rsp,%r14
lea    0xe9c(%rip),%r15
mov    %rdi,%rbp
jmp    11b4 <tokenise+0x74>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movslq %r12d,%rax
movb   $0x0,0x1(%rax,%r14,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x1,%r12d
mov    %rbx,%rbp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
add    $0x1,%rbx
cmpb   $0x0,0x0(%rbp)
je     11cb <tokenise+0x8b>
mov    %rbx,%rdi
call   1060 <issep@plt>
cmp    $0x1,%eax
je     1170 <tokenise+0x30>
test   %eax,%eax
jne    119b <tokenise+0x5b>
add    $0x1,%r12d
jmp    119b <tokenise+0x5b>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Token: %s \0A\00"
define void @tokenise(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [80 x i8]
%6 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%7 = load i8*, i8** %2
store i8* %7, i8** %3
store i32 1, i32* %4
store i32 0, i32* %6
br label %8
8: ; preds = %37, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %42
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @issep(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %37
21: ; preds = %13
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%26 = load i8*, i8** %2
%27 = load i32, i32* %4
%28 = call i32 @strncpy(i8* %25, i8* %26, i32 %27)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 %31
store i8 0, i8* %32
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %33)
store i32 1, i32* %4
%35 = load i8*, i8** %3
store i8* %35, i8** %2
br label %36
36: ; preds = %24, %21
br label %37
37: ; preds = %36, %18
%38 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%39 = call i32 @memset(i8* %38, i32 0, i32 80)
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %3
br label %8
42: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"Token: %s \0A\00"
define void @tokenise(i8* %0) {
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %26, label %6
6: ; preds = %1, %19
%7 = phi i32 [ %21, %19 ], [ 1, %1 ]
%8 = phi i8* [ %23, %19 ], [ %0, %1 ]
%9 = phi i8* [ %20, %19 ], [ %0, %1 ]
%10 = call i32 @issep(i8* %8)
switch i32 %10, label %19 [
i32 0, label %11
i32 1, label %13
]
11: ; preds = %6
%12 = add nsw i32 %7, 1
br label %19
13: ; preds = %6
%14 = call i32 @strncpy(i8* %3, i8* %9, i32 %7)
%15 = add nsw i32 %7, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %19
19: ; preds = %6, %13, %11
%20 = phi i8* [ %9, %11 ], [ %8, %13 ], [ %9, %6 ]
%21 = phi i32 [ %12, %11 ], [ 1, %13 ], [ %7, %6 ]
%22 = call i32 @memset(i8* %3, i32 0, i32 80)
%23 = getelementptr inbounds i8, i8* %8, i64 1
%24 = load i8, i8* %20
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %6
26: ; preds = %19, %1
ret void
}