#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 */
char **split_tokens(char *s) {
  const char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7',
                         '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  static char *token_list[32];
  int checksum = 0, counter = 0;
  if (*s++ != '$') {
    ;
    return NULL;
  }
  token_list[0] = s;
  while (*s) {
    if (*s == '*') {
      *s = 0;
      token_list[++counter] = 0;
      if ((*++s != hexmap[checksum >> 4]) ||
          (*++s != hexmap[checksum & 0x0F])) {
        ;
        return NULL;
      }
      if ((*++s != '\r') || (*++s != '\n')) {
        ;
        return NULL;
      }
      return token_list;
    }
    checksum ^= *s;
    if (*s == ',') {
      *s = 0;
      token_list[++counter] = s + 1;
    }
    s++;
  };
  return NULL;
}


x86 assembly (clang, -O0):
<split_tokens>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    0xef1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeee(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x24,%eax
je     1154 <split_tokens+0x54>
movq   $0x0,-0x8(%rbp)
jmp    12ae <split_tokens+0x1ae>
mov    -0x10(%rbp),%rax
mov    %rax,0x2ed1(%rip)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     12a6 <split_tokens+0x1a6>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    1252 <split_tokens+0x152>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movslq %eax,%rcx
lea    0x2e9a(%rip),%rax
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    -0x24(%rbp),%ecx
sar    $0x4,%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    11f0 <split_tokens+0xf0>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    -0x24(%rbp),%ecx
and    $0xf,%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
je     11fd <split_tokens+0xfd>
movq   $0x0,-0x8(%rbp)
jmp    12ae <split_tokens+0x1ae>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0xd,%eax
jne    1235 <split_tokens+0x135>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
je     1242 <split_tokens+0x142>
movq   $0x0,-0x8(%rbp)
jmp    12ae <split_tokens+0x1ae>
lea    0x2de7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ae <split_tokens+0x1ae>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
xor    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    1295 <split_tokens+0x195>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdx
add    $0x1,%rdx
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movslq %eax,%rcx
lea    0x2d9f(%rip),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115f <split_tokens+0x5f>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_tokens>:
xor    %eax,%eax
cmpb   $0x24,(%rdi)
jne    11a1 <split_tokens+0xa1>
lea    0x1(%rdi),%rcx
mov    %rcx,0x2f1a(%rip)
add    $0x2,%rdi
lea    0x2f0f(%rip),%r9
xor    %edx,%edx
jmp    1136 <split_tokens+0x36>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %esi,%eax
add    $0x1,%rdi
movsbl -0x1(%rdi),%esi
test   %esi,%esi
je     119f <split_tokens+0x9f>
cmp    $0x2a,%sil
je     115b <split_tokens+0x5b>
cmp    $0x2c,%sil
jne    1130 <split_tokens+0x30>
movb   $0x0,-0x1(%rdi)
movslq %edx,%rcx
add    $0x1,%edx
mov    %rdi,0x8(%r9,%rcx,8)
jmp    1130 <split_tokens+0x30>
movb   $0x0,-0x1(%rdi)
movslq %edx,%rdx
movq   $0x0,0x8(%r9,%rdx,8)
mov    (%rdi),%dl
mov    %eax,%esi
sar    $0x4,%esi
movslq %esi,%rsi
lea    0xe84(%rip),%r8
cmp    (%rsi,%r8,1),%dl
jne    119f <split_tokens+0x9f>
mov    0x1(%rdi),%dl
and    $0xf,%eax
cmp    (%rax,%r8,1),%dl
jne    119f <split_tokens+0x9f>
cmpb   $0xd,0x2(%rdi)
jne    119f <split_tokens+0x9f>
xor    %eax,%eax
cmpb   $0xa,0x3(%rdi)
cmove  %r9,%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@__const.split_tokens.hexmap = [16 x i8] c"0123456789ABCDEF"
@split_tokens.token_list = internal global [32 x i8*] zeroinitializer
define i8** @split_tokens(i8* %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca [16 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [16 x i8]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %6
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %8
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 36
br i1 %12, label %13, label %14
13: ; preds = %1
store i8** null, i8*** %2
br label %91
14: ; preds = %1
%15 = load i8*, i8** %3
store i8* %15, i8** getelementptr inbounds ([32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 0)
br label %16
16: ; preds = %87, %14
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %90
20: ; preds = %16
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 42
br i1 %24, label %25, label %69
25: ; preds = %20
%26 = load i8*, i8** %3
store i8 0, i8* %26
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 %29
store i8* null, i8** %30
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i32, i32* %5
%36 = ashr i32 %35, 4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %34, %40
br i1 %41, label %54, label %42
42: ; preds = %25
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = load i32, i32* %5
%48 = and i32 %47, 15
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %46, %52
br i1 %53, label %54, label %55
54: ; preds = %42, %25
store i8** null, i8*** %2
br label %91
55: ; preds = %42
%56 = load i8*, i8** %3
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %3
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 13
br i1 %60, label %67, label %61
61: ; preds = %55
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %3
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 10
br i1 %66, label %67, label %68
67: ; preds = %61, %55
store i8** null, i8*** %2
br label %91
68: ; preds = %61
store i8** getelementptr inbounds ([32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 0), i8*** %2
br label %91
69: ; preds = %20
%70 = load i8*, i8** %3
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = load i32, i32* %5
%74 = xor i32 %73, %72
store i32 %74, i32* %5
%75 = load i8*, i8** %3
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 44
br i1 %78, label %79, label %87
79: ; preds = %69
%80 = load i8*, i8** %3
store i8 0, i8* %80
%81 = load i8*, i8** %3
%82 = getelementptr inbounds i8, i8* %81, i64 1
%83 = load i32, i32* %6
%84 = add nsw i32 %83, 1
store i32 %84, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 %85
store i8* %82, i8** %86
br label %87
87: ; preds = %79, %69
%88 = load i8*, i8** %3
%89 = getelementptr inbounds i8, i8* %88, i32 1
store i8* %89, i8** %3
br label %16
90: ; preds = %16
store i8** null, i8*** %2
br label %91
91: ; preds = %90, %68, %67, %54, %13
%92 = load i8**, i8*** %2
ret i8** %92
}

LLVM IR (-O2):
@__const.split_tokens.hexmap = [16 x i8] c"0123456789ABCDEF"
@split_tokens.token_list = internal global [32 x i8*] zeroinitializer
define i8** @split_tokens(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 36
br i1 %4, label %5, label %51
5: ; preds = %1
store i8* %2, i8** getelementptr inbounds ([32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 0)
br label %6
6: ; preds = %48, %5
%7 = phi i8* [ %2, %5 ], [ %50, %48 ]
%8 = phi i32 [ 0, %5 ], [ %41, %48 ]
%9 = phi i32 [ 0, %5 ], [ %49, %48 ]
%10 = load i8, i8* %7
switch i8 %10, label %39 [
i8 0, label %51
i8 42, label %11
]
11: ; preds = %6
store i8 0, i8* %7
%12 = add nsw i32 %9, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 %13
store i8* null, i8** %14
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = load i8, i8* %15
%17 = ashr i32 %8, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.split_tokens.hexmap, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %16, %20
br i1 %21, label %22, label %51
22: ; preds = %11
%23 = getelementptr inbounds i8, i8* %7, i64 2
%24 = load i8, i8* %23
%25 = and i32 %8, 15
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [16 x i8], [16 x i8]* @__const.split_tokens.hexmap, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %24, %28
br i1 %29, label %30, label %51
30: ; preds = %22
%31 = getelementptr inbounds i8, i8* %7, i64 3
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 13
br i1 %33, label %34, label %51
34: ; preds = %30
%35 = getelementptr inbounds i8, i8* %7, i64 4
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 10
%38 = select i1 %37, i8** getelementptr inbounds ([32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 0), i8** null
br label %51
39: ; preds = %6
%40 = sext i8 %10 to i32
%41 = xor i32 %8, %40
%42 = icmp eq i8 %10, 44
br i1 %42, label %43, label %48
43: ; preds = %39
store i8 0, i8* %7
%44 = getelementptr inbounds i8, i8* %7, i64 1
%45 = add nsw i32 %9, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [32 x i8*], [32 x i8*]* @split_tokens.token_list, i64 0, i64 %46
store i8* %44, i8** %47
br label %48
48: ; preds = %43, %39
%49 = phi i32 [ %45, %43 ], [ %9, %39 ]
%50 = getelementptr inbounds i8, i8* %7, i64 1
br label %6
51: ; preds = %6, %34, %30, %11, %22, %1
%52 = phi i8** [ null, %1 ], [ null, %22 ], [ null, %11 ], [ null, %30 ], [ %38, %34 ], [ null, %6 ]
ret i8** %52
}