#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 issep(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void tokenise(char *str) {
  char *ptr = NULL;
  ptr = str;
  char token[40][80];
  int tokptr = 0;
  int numchars = 0;
  int ret;
  while (*ptr != '\0') {
    ret = issep(*ptr);
    if (ret == 0) {
      numchars++;
    } else if (ret == 1) {
      strncpy(token[tokptr], str, numchars);
      token[tokptr][numchars + 1] = '\0';
      printf("Token: %s \n", token[tokptr]);
      numchars = 1;
      tokptr++;
      str = ptr;
    }
    ptr++;
  }
}


x86 assembly (clang, -O0):
<tokenise>:
push   %rbp
mov    %rsp,%rbp
sub    $0xca0,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xc94(%rbp)
movl   $0x0,-0xc98(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1254 <tokenise+0x124>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <issep@plt>
mov    %eax,-0xc9c(%rbp)
cmpl   $0x0,-0xc9c(%rbp)
jne    11a6 <tokenise+0x76>
mov    -0xc98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc98(%rbp)
jmp    1243 <tokenise+0x113>
cmpl   $0x1,-0xc9c(%rbp)
jne    123e <tokenise+0x10e>
movslq -0xc94(%rbp),%rax
lea    -0xc90(%rbp),%rdi
imul   $0x50,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc98(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0xc94(%rbp),%rcx
lea    -0xc90(%rbp),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
mov    -0xc98(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movslq -0xc94(%rbp),%rax
lea    -0xc90(%rbp),%rsi
imul   $0x50,%rax,%rax
add    %rax,%rsi
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0xc98(%rbp)
mov    -0xc94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc94(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1243 <tokenise+0x113>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1163 <tokenise+0x33>
add    $0xca0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc88,%rsp
mov    (%rdi),%al
test   %al,%al
je     11c0 <tokenise+0x90>
mov    %rdi,%r15
xor    %r13d,%r13d
lea    0xeac(%rip),%r14
xor    %r12d,%r12d
mov    %rdi,%rbp
jmp    11a9 <tokenise+0x79>
nopl   0x0(%rax)
movslq %r12d,%r12
lea    (%r12,%r12,4),%rax
shl    $0x4,%rax
lea    (%rsp,%rax,1),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
movslq %r13d,%rax
movb   $0x0,0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x1,%r12d
mov    $0x1,%r13d
mov    %rbp,%r15
movzbl 0x1(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     11c0 <tokenise+0x90>
movsbl %al,%edi
call   1050 <issep@plt>
cmp    $0x1,%eax
je     1160 <tokenise+0x30>
test   %eax,%eax
jne    119d <tokenise+0x6d>
add    $0x1,%r13d
jmp    119d <tokenise+0x6d>
add    $0xc88,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 [40 x [80 x i8]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%8 = load i8*, i8** %2
store i8* %8, i8** %3
store i32 0, i32* %5
store i32 0, i32* %6
br label %9
9: ; preds = %50, %1
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %53
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = call i32 @issep(i8 signext %16)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %50
23: ; preds = %14
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %49
26: ; preds = %23
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [40 x [80 x i8]], [40 x [80 x i8]]* %4, i64 0, i64 %28
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %29, i64 0, i64 0
%31 = load i8*, i8** %2
%32 = load i32, i32* %6
%33 = call i32 @strncpy(i8* %30, i8* %31, i32 %32)
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [40 x [80 x i8]], [40 x [80 x i8]]* %4, i64 0, i64 %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %36, i64 0, i64 %39
store i8 0, i8* %40
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [40 x [80 x i8]], [40 x [80 x i8]]* %4, i64 0, i64 %42
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %43, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %44)
store i32 1, i32* %6
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
%48 = load i8*, i8** %3
store i8* %48, i8** %2
br label %49
49: ; preds = %26, %23
br label %50
50: ; preds = %49, %20
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %3
br label %9
53: ; preds = %9
ret void
}

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