#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 ident_size(char const *);
int number_size(char const *);
int string_size(char const *);
int token_type(char const *, unsigned int);
int token_size(const char *s, unsigned int offset) {
  switch (token_type(s, offset)) {
  case 2:
    return 1;
  case 1:
    return ident_size(s + offset);
  case 5:
    return number_size(s + offset);
  case 3:
    return string_size(s + offset);
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<token_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <token_type@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     11d2 <token_size+0x92>
mov    -0x20(%rbp),%rax
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    11d9 <token_size+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
call   1030 <ident_size@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <token_size+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
call   1040 <number_size@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <token_size+0x99>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
call   1050 <string_size@plt>
mov    %eax,-0x4(%rbp)
jmp    11d9 <token_size+0x99>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_size>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1060 <token_type@plt>
cmp    $0x5,%eax
je     116f <token_size+0x2f>
cmp    $0x3,%eax
je     1182 <token_size+0x42>
cmp    $0x1,%eax
jne    1195 <token_size+0x55>
mov    %ebp,%eax
add    %rax,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <ident_size@plt>
mov    %ebp,%eax
add    %rax,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <number_size@plt>
mov    %ebp,%eax
add    %rax,%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <string_size@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @token_size(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = load i32, i32* %5
%8 = call i32 @token_type(i8* %6, i32 %7)
switch i32 %8, label %28 [
i32 2, label %9
i32 1, label %10
i32 5, label %16
i32 3, label %22
]
9: ; preds = %2
store i32 1, i32* %3
br label %29
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = call i32 @ident_size(i8* %14)
store i32 %15, i32* %3
br label %29
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 @number_size(i8* %20)
store i32 %21, i32* %3
br label %29
22: ; preds = %2
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = call i32 @string_size(i8* %26)
store i32 %27, i32* %3
br label %29
28: ; preds = %2
store i32 1, i32* %3
br label %29
29: ; preds = %28, %22, %16, %10, %9
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @token_size(i8* %0, i32 %1) {
%3 = tail call i32 @token_type(i8* %0, i32 %1)
switch i32 %3, label %16 [
i32 3, label %12
i32 1, label %4
i32 5, label %8
]
4: ; preds = %2
%5 = zext i32 %1 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = tail call i32 @ident_size(i8* %6)
br label %16
8: ; preds = %2
%9 = zext i32 %1 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = tail call i32 @number_size(i8* %10)
br label %16
12: ; preds = %2
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = tail call i32 @string_size(i8* %14)
br label %16
16: ; preds = %2, %12, %8, %4
%17 = phi i32 [ %15, %12 ], [ %11, %8 ], [ %7, %4 ], [ 1, %2 ]
ret i32 %17
}