#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 */
char *gettype(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
int strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void tokenise(char *str) {
  char *ptr = NULL;
  ptr = str + 1;
  int numchars = 1;
  char token[80];
  char *typestr = NULL;
  char *typestr1 = NULL;
  int comp;
  while (*str != '\0') {
    typestr = gettype(str);
    typestr1 = gettype(ptr);
    comp = strcmp(typestr, typestr1);
    if (comp == 0) {
      numchars++;
    } else if (comp != 0) {
      strncpy(token, str, numchars);
      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    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1244 <tokenise+0xf4>
mov    -0x8(%rbp),%rdi
call   1070 <gettype@plt>
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <gettype@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jne    11e2 <tokenise+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1223 <tokenise+0xd3>
cmpl   $0x0,-0x84(%rbp)
je     121e <tokenise+0xce>
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
lea    -0x70(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1223 <tokenise+0xd3>
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    118a <tokenise+0x3a>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tokenise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmpb   $0x0,(%rdi)
je     11e4 <tokenise+0x94>
mov    %rdi,%r12
lea    0x1(%rdi),%rbx
mov    $0x1,%r13d
mov    %rsp,%r14
lea    0xe82(%rip),%r15
jmp    11bc <tokenise+0x6c>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    $0x1,%r13d
mov    %rbx,%r12
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
add    $0x1,%rbx
cmpb   $0x0,(%r12)
je     11e4 <tokenise+0x94>
mov    %r12,%rdi
call   1070 <gettype@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <gettype@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1180 <tokenise+0x30>
add    $0x1,%r13d
jmp    11a2 <tokenise+0x52>
add    $0x58,%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 i32
%5 = alloca [80 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %10, i8** %3
store i32 1, i32* %4
store i8* null, i8** %6
store i8* null, i8** %7
br label %11
11: ; preds = %41, %1
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %46
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = call i8* @gettype(i8* %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %3
%20 = call i8* @gettype(i8* %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %6
%22 = load i8*, i8** %7
%23 = call i32 @strcmp(i8* %21, i8* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %41
29: ; preds = %16
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%34 = load i8*, i8** %2
%35 = load i32, i32* %4
%36 = call i32 @strncpy(i8* %33, i8* %34, i32 %35)
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %37)
store i32 1, i32* %4
%39 = load i8*, i8** %3
store i8* %39, i8** %2
br label %40
40: ; preds = %32, %29
br label %41
41: ; preds = %40, %26
%42 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%43 = call i32 @memset(i8* %42, i32 0, i32 80)
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
br label %11
46: ; preds = %11
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, %20
%7 = phi i8* [ %10, %20 ], [ %0, %1 ]
%8 = phi i8* [ %22, %20 ], [ %0, %1 ]
%9 = phi i32 [ %21, %20 ], [ 1, %1 ]
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = call i8* @gettype(i8* %8)
%12 = call i8* @gettype(i8* %10)
%13 = call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(1) %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = add nsw i32 %9, 1
br label %20
17: ; preds = %6
%18 = call i32 @strncpy(i8* %3, i8* %8, i32 %9)
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %20
20: ; preds = %17, %15
%21 = phi i32 [ %16, %15 ], [ 1, %17 ]
%22 = phi i8* [ %8, %15 ], [ %10, %17 ]
%23 = call i32 @memset(i8* %3, i32 0, i32 80)
%24 = load i8, i8* %22
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %6
26: ; preds = %20, %1
ret void
}