#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 *chatdat_get_token(char const *);
int chatdat_line_type(const char *line) {
  char *token = chatdat_get_token(line);
  switch (*token) {
  case '\r':
  case '\n':
  case '\0':
    return 0;
  case '#':
    return 1;
  case '$':
    return 2;
  case '@':
    return 3;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<chatdat_line_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <chatdat_get_token@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1195 <chatdat_line_type+0x85>
jmp    1140 <chatdat_line_type+0x30>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1195 <chatdat_line_type+0x85>
jmp    1151 <chatdat_line_type+0x41>
mov    -0x1c(%rbp),%eax
sub    $0xd,%eax
je     1195 <chatdat_line_type+0x85>
jmp    1162 <chatdat_line_type+0x52>
mov    -0x1c(%rbp),%eax
sub    $0x23,%eax
je     11a1 <chatdat_line_type+0x91>
jmp    1173 <chatdat_line_type+0x63>
mov    -0x1c(%rbp),%eax
sub    $0x24,%eax
je     11ad <chatdat_line_type+0x9d>
jmp    1184 <chatdat_line_type+0x74>
mov    -0x1c(%rbp),%eax
sub    $0x40,%eax
je     11b9 <chatdat_line_type+0xa9>
jmp    11c5 <chatdat_line_type+0xb5>
movl   $0x0,-0x4(%rbp)
jmp    11cc <chatdat_line_type+0xbc>
movl   $0x1,-0x4(%rbp)
jmp    11cc <chatdat_line_type+0xbc>
movl   $0x2,-0x4(%rbp)
jmp    11cc <chatdat_line_type+0xbc>
movl   $0x3,-0x4(%rbp)
jmp    11cc <chatdat_line_type+0xbc>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chatdat_line_type>:
push   %rax
call   1030 <chatdat_get_token@plt>
movsbl (%rax),%ecx
cmp    $0x24,%ecx
ja     1132 <chatdat_line_type+0x22>
xor    %eax,%eax
lea    0xed9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
pop    %rcx
ret
cmp    $0x40,%ecx
jne    113e <chatdat_line_type+0x2e>
mov    $0x3,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @chatdat_line_type(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @chatdat_get_token(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %14 [
i32 13, label %10
i32 10, label %10
i32 0, label %10
i32 35, label %11
i32 36, label %12
i32 64, label %13
]
10: ; preds = %1, %1, %1
store i32 0, i32* %2
br label %15
11: ; preds = %1
store i32 1, i32* %2
br label %15
12: ; preds = %1
store i32 2, i32* %2
br label %15
13: ; preds = %1
store i32 3, i32* %2
br label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %15
15: ; preds = %14, %13, %12, %11, %10
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @chatdat_line_type(i8* %0) {
%2 = tail call i8* @chatdat_get_token(i8* %0)
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
switch i32 %4, label %8 [
i32 13, label %9
i32 10, label %9
i32 0, label %9
i32 35, label %5
i32 36, label %6
i32 64, label %7
]
5: ; preds = %1
br label %9
6: ; preds = %1
br label %9
7: ; preds = %1
br label %9
8: ; preds = %1
br label %9
9: ; preds = %1, %1, %1, %8, %7, %6, %5
%10 = phi i32 [ -1, %8 ], [ 3, %7 ], [ 2, %6 ], [ 1, %5 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ]
ret i32 %10
}