#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 */
scalar_t__ isspace(char);
int get_type_token(char *token, char string_buffer[], int position) {
  for (; isspace(string_buffer[position]); ++position)
    ;
  for (; !isspace(*token = string_buffer[position]) && *token != '\0';
       ++token, ++position)
    ;
  *token = '\0';
  return position;
}


x86 assembly (clang, -O0):
<get_type_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1151 <get_type_token+0x41>
jmp    1143 <get_type_token+0x33>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <get_type_token+0x13>
jmp    1156 <get_type_token+0x46>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x8(%rbp),%rcx
mov    %al,(%rcx)
movsbl %al,%edi
call   1030 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x15(%rbp)
jne    1191 <get_type_token+0x81>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11a1 <get_type_token+0x91>
jmp    11c0 <get_type_token+0xb0>
jmp    11a6 <get_type_token+0x96>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <get_type_token+0x46>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type_token>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movslq %edx,%rax
lea    -0x1(%rax),%rbx
shl    $0x20,%rax
movabs $0xffffffff00000000,%r12
ff ff ff
add    %rax,%r12
movabs $0x100000000,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %r13,%r12
movsbl 0x1(%r15,%rbx,1),%edi
call   1030 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <get_type_token+0x40>
sar    $0x20,%r12
movsbl (%r15,%r12,1),%edi
mov    %dil,(%r14)
call   1030 <isspace@plt>
test   %rax,%rax
je     1190 <get_type_token+0x80>
mov    %rbx,%r12
jmp    11b2 <get_type_token+0xa2>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,(%r14)
je     11b2 <get_type_token+0xa2>
movsbl 0x1(%r15,%r12,1),%edi
add    $0x1,%r12
mov    %dil,0x1(%r14)
add    $0x1,%r14
call   1030 <isspace@plt>
test   %rax,%rax
je     1190 <get_type_token+0x80>
movb   $0x0,(%r14)
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_type_token(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
br label %7
7: ; preds = %16, %3
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = call i64 @isspace(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %7
br label %16
16: ; preds = %15
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %7
19: ; preds = %7
br label %20
20: ; preds = %37, %19
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = load i8*, i8** %4
store i8 %25, i8* %26
%27 = call i64 @isspace(i8 signext %25)
%28 = icmp ne i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %20
%30 = load i8*, i8** %4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br label %34
34: ; preds = %29, %20
%35 = phi i1 [ false, %20 ], [ %33, %29 ]
br i1 %35, label %36, label %42
36: ; preds = %34
br label %37
37: ; preds = %36
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %4
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %20
42: ; preds = %34
%43 = load i8*, i8** %4
store i8 0, i8* %43
%44 = load i32, i32* %6
ret i32 %44
}

LLVM IR (-O2):
define i32 @get_type_token(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = sext i32 %2 to i64
br label %5
5: ; preds = %5, %3
%6 = phi i64 [ %11, %5 ], [ %4, %3 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp eq i64 %9, 0
%11 = add i64 %6, 1
br i1 %10, label %12, label %5
12: ; preds = %5
%13 = shl i64 %6, 32
%14 = ashr exact i64 %13, 32
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
store i8 %16, i8* %0
%17 = tail call i64 @isspace(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %31
19: ; preds = %12, %24
%20 = phi i64 [ %26, %24 ], [ %14, %12 ]
%21 = phi i8* [ %25, %24 ], [ %0, %12 ]
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %19
%25 = getelementptr inbounds i8, i8* %21, i64 1
%26 = add i64 %20, 1
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = load i8, i8* %27
store i8 %28, i8* %25
%29 = tail call i64 @isspace(i8 signext %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %19, label %31
31: ; preds = %19, %24, %12
%32 = phi i8* [ %0, %12 ], [ %25, %24 ], [ %21, %19 ]
%33 = phi i64 [ %6, %12 ], [ %26, %24 ], [ %20, %19 ]
%34 = trunc i64 %33 to i32
store i8 0, i8* %32
ret i32 %34
}