int tofreq(char sig, int sys, int *type) {
  const unsigned char types[6][6] = {
      {1, 3, 20, 18, 26, 12}, {1, 13, 0, 18, 26, 12}, {1, 0, 0, 0, 26, 0},
      {12, 39, 29, 0, 26, 0}, {1, 2, 19, 14, 0, 0},   {1, 0, 0, 0, 14, 0}};
  const int freqs[6][6] = {{1, 1, 2, 2, 3, 1}, {1, 1, 0, 2, 3, 1},
                           {1, 0, 0, 0, 3, 0}, {1, 6, 5, 0, 3, 0},
                           {1, 1, 2, 2, 0, 0}, {1, 0, 0, 0, 2, 0}};
  int i, j;
  switch (sig) {
  case 'c':
  case 'C':
    i = 0;
    break;
  case '1':
    i = 1;
    break;
  case '2':
    i = 2;
    break;
  case '3':
    i = 3;
    break;
  case '5':
    i = 4;
    break;
  case 'l':
    i = 5;
    break;
  default:
    return -1;
  }
  switch (sys) {
  case 0x01:
    j = 0;
    break;
  case 0x10:
    j = 1;
    break;
  case 0x02:
    j = 2;
    break;
  case 0x08:
    j = 3;
    break;
  case 0x04:
    j = 4;
    break;
  case 0x20:
    j = 5;
    break;
  default:
    return -1;
  }
  *type = types[j][i];
  return freqs[j][i] <= 3 ? freqs[j][i] - 1 : -1;
}


x86 assembly (clang, -O0):
<tofreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x1062(%rip),%eax
mov    %eax,-0x20(%rbp)
movaps 0x1048(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movaps 0x102d(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
lea    0x1052(%rip),%rsi
lea    -0xd0(%rbp),%rdi
mov    $0x90,%edx
call   1030 <memcpy@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0xe0(%rbp)
sub    $0x3b,%eax
ja     11e9 <tofreq+0xd9>
mov    -0xe0(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0x1,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0x2,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0x3,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0x4,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0x5,-0xd4(%rbp)
jmp    11f5 <tofreq+0xe5>
movl   $0xffffffff,-0x4(%rbp)
jmp    1319 <tofreq+0x209>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0xe8(%rbp)
sub    $0x1f,%eax
ja     127e <tofreq+0x16e>
mov    -0xe8(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0x1,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0x2,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0x3,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0x4,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0x5,-0xd8(%rbp)
jmp    128a <tofreq+0x17a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1319 <tofreq+0x209>
movslq -0xd8(%rbp),%rcx
lea    -0x40(%rbp),%rax
imul   $0x6,%rcx,%rcx
add    %rcx,%rax
movslq -0xd4(%rbp),%rcx
movzbl (%rax,%rcx,1),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movslq -0xd8(%rbp),%rcx
lea    -0xd0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xd4(%rbp),%rcx
cmpl   $0x3,(%rax,%rcx,4)
jg     1300 <tofreq+0x1f0>
movslq -0xd8(%rbp),%rcx
lea    -0xd0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xd4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
sub    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    1310 <tofreq+0x200>
mov    $0xffffffff,%eax
mov    %eax,-0xec(%rbp)
jmp    1310 <tofreq+0x200>
mov    -0xec(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tofreq>:
mov    $0xffffffff,%eax
add    $0xffffffcf,%edi
cmp    $0x3b,%edi
ja     11b8 <tofreq+0xb8>
xor    %r8d,%r8d
lea    0xee5(%rip),%rcx
movslq (%rcx,%rdi,4),%rdi
add    %rcx,%rdi
jmp    *%rdi
mov    $0x1,%r8d
jmp    114a <tofreq+0x4a>
mov    $0x2,%r8d
jmp    114a <tofreq+0x4a>
mov    $0x3,%r8d
jmp    114a <tofreq+0x4a>
mov    $0x4,%r8d
jmp    114a <tofreq+0x4a>
mov    $0x5,%r8d
add    $0xffffffff,%esi
cmp    $0x1f,%esi
ja     11b8 <tofreq+0xb8>
xor    %edi,%edi
lea    0xf95(%rip),%rcx
movslq (%rcx,%rsi,4),%rsi
add    %rcx,%rsi
jmp    *%rsi
mov    $0x2,%edi
jmp    1185 <tofreq+0x85>
mov    $0x4,%edi
jmp    1185 <tofreq+0x85>
mov    $0x3,%edi
jmp    1185 <tofreq+0x85>
mov    $0x1,%edi
jmp    1185 <tofreq+0x85>
mov    $0x5,%edi
lea    0xfe4(%rip),%rax
lea    (%rdi,%rdi,2),%rcx
lea    (%rax,%rcx,2),%rax
movzbl (%r8,%rax,1),%eax
mov    %eax,(%rdx)
lea    0xffe(%rip),%rax
lea    (%rax,%rcx,8),%rax
mov    (%rax,%r8,4),%eax
lea    -0x1(%rax),%ecx
cmp    $0x4,%eax
mov    $0xffffffff,%eax
cmovl  %ecx,%eax
ret

LLVM IR (-O0):
@__const.tofreq.types = [6 x [6 x i8]] [[6 x i8] c"\01\03\14\12\1A\0C", [6 x i8] c"\01\0D\00\12\1A\0C", [6 x i8] c"\01\00\00\00\1A\00", [6 x i8] c"\0C'\1D\00\1A\00", [6 x i8] c"\01\02\13\0E\00\00", [6 x i8] c"\01\00\00\00\0E\00"]
@__const.tofreq.freqs = [6 x [6 x i32]] [[6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 3, i32 1], [6 x i32] [i32 1, i32 1, i32 0, i32 2, i32 3, i32 1], [6 x i32] [i32 1, i32 0, i32 0, i32 0, i32 3, i32 0], [6 x i32] [i32 1, i32 6, i32 5, i32 0, i32 3, i32 0], [6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 0, i32 0], [6 x i32] [i32 1, i32 0, i32 0, i32 0, i32 2, i32 0]]
define i32 @tofreq(i8 signext %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [6 x [6 x i8]]
%9 = alloca [6 x [6 x i32]]
%10 = alloca i32
%11 = alloca i32
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%12 = bitcast [6 x [6 x i8]]* %8 to i8*
%13 = bitcast [6 x [6 x i32]]* %9 to i8*
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
switch i32 %15, label %22 [
i32 99, label %16
i32 67, label %16
i32 49, label %17
i32 50, label %18
i32 51, label %19
i32 53, label %20
i32 108, label %21
]
16: ; preds = %3, %3
store i32 0, i32* %10
br label %23
17: ; preds = %3
store i32 1, i32* %10
br label %23
18: ; preds = %3
store i32 2, i32* %10
br label %23
19: ; preds = %3
store i32 3, i32* %10
br label %23
20: ; preds = %3
store i32 4, i32* %10
br label %23
21: ; preds = %3
store i32 5, i32* %10
br label %23
22: ; preds = %3
store i32 -1, i32* %4
br label %62
23: ; preds = %21, %20, %19, %18, %17, %16
%24 = load i32, i32* %6
switch i32 %24, label %31 [
i32 1, label %25
i32 16, label %26
i32 2, label %27
i32 8, label %28
i32 4, label %29
i32 32, label %30
]
25: ; preds = %23
store i32 0, i32* %11
br label %32
26: ; preds = %23
store i32 1, i32* %11
br label %32
27: ; preds = %23
store i32 2, i32* %11
br label %32
28: ; preds = %23
store i32 3, i32* %11
br label %32
29: ; preds = %23
store i32 4, i32* %11
br label %32
30: ; preds = %23
store i32 5, i32* %11
br label %32
31: ; preds = %23
store i32 -1, i32* %4
br label %62
32: ; preds = %30, %29, %28, %27, %26, %25
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* %8, i64 0, i64 %34
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %35, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = load i32*, i32** %7
store i32 %40, i32* %41
%42 = load i32, i32* %11
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [6 x [6 x i32]], [6 x [6 x i32]]* %9, i64 0, i64 %43
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [6 x i32], [6 x i32]* %44, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = icmp sle i32 %48, 3
br i1 %49, label %50, label %59
50: ; preds = %32
%51 = load i32, i32* %11
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [6 x [6 x i32]], [6 x [6 x i32]]* %9, i64 0, i64 %52
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [6 x i32], [6 x i32]* %53, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = sub nsw i32 %57, 1
br label %60
59: ; preds = %32
br label %60
60: ; preds = %59, %50
%61 = phi i32 [ %58, %50 ], [ -1, %59 ]
store i32 %61, i32* %4
br label %62
62: ; preds = %60, %31, %22
%63 = load i32, i32* %4
ret i32 %63
}

LLVM IR (-O2):
@__const.tofreq.types = [6 x [6 x i8]] [[6 x i8] c"\01\03\14\12\1A\0C", [6 x i8] c"\01\0D\00\12\1A\0C", [6 x i8] c"\01\00\00\00\1A\00", [6 x i8] c"\0C'\1D\00\1A\00", [6 x i8] c"\01\02\13\0E\00\00", [6 x i8] c"\01\00\00\00\0E\00"]
@__const.tofreq.freqs = [6 x [6 x i32]] [[6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 3, i32 1], [6 x i32] [i32 1, i32 1, i32 0, i32 2, i32 3, i32 1], [6 x i32] [i32 1, i32 0, i32 0, i32 0, i32 3, i32 0], [6 x i32] [i32 1, i32 6, i32 5, i32 0, i32 3, i32 0], [6 x i32] [i32 1, i32 1, i32 2, i32 2, i32 0, i32 0], [6 x i32] [i32 1, i32 0, i32 0, i32 0, i32 2, i32 0]]
define i32 @tofreq(i8 signext %0, i32 %1, i32* nocapture writeonly %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %27 [
i32 99, label %10
i32 67, label %10
i32 49, label %5
i32 50, label %6
i32 51, label %7
i32 53, label %8
i32 108, label %9
]
5: ; preds = %3
br label %10
6: ; preds = %3
br label %10
7: ; preds = %3
br label %10
8: ; preds = %3
br label %10
9: ; preds = %3
br label %10
10: ; preds = %3, %3, %9, %8, %7, %6, %5
%11 = phi i64 [ 5, %9 ], [ 4, %8 ], [ 3, %7 ], [ 2, %6 ], [ 1, %5 ], [ 0, %3 ], [ 0, %3 ]
switch i32 %1, label %27 [
i32 1, label %17
i32 16, label %12
i32 2, label %13
i32 8, label %14
i32 4, label %15
i32 32, label %16
]
12: ; preds = %10
br label %17
13: ; preds = %10
br label %17
14: ; preds = %10
br label %17
15: ; preds = %10
br label %17
16: ; preds = %10
br label %17
17: ; preds = %10, %16, %15, %14, %13, %12
%18 = phi i64 [ 5, %16 ], [ 4, %15 ], [ 3, %14 ], [ 2, %13 ], [ 1, %12 ], [ 0, %10 ]
%19 = getelementptr inbounds [6 x [6 x i8]], [6 x [6 x i8]]* @__const.tofreq.types, i64 0, i64 %18, i64 %11
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
store i32 %21, i32* %2
%22 = getelementptr inbounds [6 x [6 x i32]], [6 x [6 x i32]]* @__const.tofreq.freqs, i64 0, i64 %18, i64 %11
%23 = load i32, i32* %22
%24 = icmp slt i32 %23, 4
%25 = add nsw i32 %23, -1
%26 = select i1 %24, i32 %25, i32 -1
br label %27
27: ; preds = %10, %3, %17
%28 = phi i32 [ %26, %17 ], [ -1, %3 ], [ -1, %10 ]
ret i32 %28
}