int ZopfliGetDistSymbol(int dist) {
  if (dist < 193) {
    if (dist < 13) {
      if (dist < 5)
        return dist - 1;
      else if (dist < 7)
        return 4;
      else if (dist < 9)
        return 5;
      else
        return 6;
    } else {
      if (dist < 17)
        return 7;
      else if (dist < 25)
        return 8;
      else if (dist < 33)
        return 9;
      else if (dist < 49)
        return 10;
      else if (dist < 65)
        return 11;
      else if (dist < 97)
        return 12;
      else if (dist < 129)
        return 13;
      else
        return 14;
    }
  } else {
    if (dist < 2049) {
      if (dist < 257)
        return 15;
      else if (dist < 385)
        return 16;
      else if (dist < 513)
        return 17;
      else if (dist < 769)
        return 18;
      else if (dist < 1025)
        return 19;
      else if (dist < 1537)
        return 20;
      else
        return 21;
    } else {
      if (dist < 3073)
        return 22;
      else if (dist < 4097)
        return 23;
      else if (dist < 6145)
        return 24;
      else if (dist < 8193)
        return 25;
      else if (dist < 12289)
        return 26;
      else if (dist < 16385)
        return 27;
      else if (dist < 24577)
        return 28;
      else
        return 29;
    }
  }
}


x86 assembly (clang, -O0):
<ZopfliGetDistSymbol>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xc1,-0x8(%rbp)
jge    1217 <ZopfliGetDistSymbol+0x117>
cmpl   $0xd,-0x8(%rbp)
jge    116e <ZopfliGetDistSymbol+0x6e>
cmpl   $0x5,-0x8(%rbp)
jge    1136 <ZopfliGetDistSymbol+0x36>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x7,-0x8(%rbp)
jge    114c <ZopfliGetDistSymbol+0x4c>
movl   $0x4,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x9,-0x8(%rbp)
jge    1162 <ZopfliGetDistSymbol+0x62>
movl   $0x5,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
movl   $0x6,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x11,-0x8(%rbp)
jge    1184 <ZopfliGetDistSymbol+0x84>
movl   $0x7,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x19,-0x8(%rbp)
jge    119a <ZopfliGetDistSymbol+0x9a>
movl   $0x8,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x21,-0x8(%rbp)
jge    11b0 <ZopfliGetDistSymbol+0xb0>
movl   $0x9,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x31,-0x8(%rbp)
jge    11c6 <ZopfliGetDistSymbol+0xc6>
movl   $0xa,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x41,-0x8(%rbp)
jge    11dc <ZopfliGetDistSymbol+0xdc>
movl   $0xb,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x61,-0x8(%rbp)
jge    11f2 <ZopfliGetDistSymbol+0xf2>
movl   $0xc,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x81,-0x8(%rbp)
jge    120b <ZopfliGetDistSymbol+0x10b>
movl   $0xd,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
movl   $0xe,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x801,-0x8(%rbp)
jge    12c6 <ZopfliGetDistSymbol+0x1c6>
cmpl   $0x101,-0x8(%rbp)
jge    123d <ZopfliGetDistSymbol+0x13d>
movl   $0xf,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x181,-0x8(%rbp)
jge    1256 <ZopfliGetDistSymbol+0x156>
movl   $0x10,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x201,-0x8(%rbp)
jge    126f <ZopfliGetDistSymbol+0x16f>
movl   $0x11,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x301,-0x8(%rbp)
jge    1288 <ZopfliGetDistSymbol+0x188>
movl   $0x12,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x401,-0x8(%rbp)
jge    12a1 <ZopfliGetDistSymbol+0x1a1>
movl   $0x13,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x601,-0x8(%rbp)
jge    12ba <ZopfliGetDistSymbol+0x1ba>
movl   $0x14,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
movl   $0x15,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0xc01,-0x8(%rbp)
jge    12df <ZopfliGetDistSymbol+0x1df>
movl   $0x16,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x1001,-0x8(%rbp)
jge    12f8 <ZopfliGetDistSymbol+0x1f8>
movl   $0x17,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x1801,-0x8(%rbp)
jge    1311 <ZopfliGetDistSymbol+0x211>
movl   $0x18,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x2001,-0x8(%rbp)
jge    132a <ZopfliGetDistSymbol+0x22a>
movl   $0x19,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x3001,-0x8(%rbp)
jge    1343 <ZopfliGetDistSymbol+0x243>
movl   $0x1a,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x4001,-0x8(%rbp)
jge    135c <ZopfliGetDistSymbol+0x25c>
movl   $0x1b,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
cmpl   $0x6001,-0x8(%rbp)
jge    1375 <ZopfliGetDistSymbol+0x275>
movl   $0x1c,-0x4(%rbp)
jmp    137c <ZopfliGetDistSymbol+0x27c>
movl   $0x1d,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ZopfliGetDistSymbol>:
cmp    $0xc0,%edi
jg     1120 <ZopfliGetDistSymbol+0x20>
cmp    $0xc,%edi
jg     1191 <ZopfliGetDistSymbol+0x91>
cmp    $0x4,%edi
jg     1249 <ZopfliGetDistSymbol+0x149>
add    $0xffffffff,%edi
mov    %edi,%eax
ret
cmp    $0x800,%edi
ja     11ee <ZopfliGetDistSymbol+0xee>
mov    $0xf,%eax
cmp    $0x101,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x10,%eax
cmp    $0x181,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x11,%eax
cmp    $0x201,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x12,%eax
cmp    $0x301,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x13,%eax
cmp    $0x401,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
cmp    $0x601,%edi
mov    $0x15,%eax
jmp    125b <ZopfliGetDistSymbol+0x15b>
mov    $0x7,%eax
cmp    $0x11,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x8,%eax
cmp    $0x19,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x9,%eax
cmp    $0x21,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0xa,%eax
cmp    $0x31,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0xb,%eax
cmp    $0x41,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0xc,%eax
cmp    $0x61,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
cmp    $0x81,%edi
mov    $0xe,%eax
jmp    125b <ZopfliGetDistSymbol+0x15b>
mov    $0x16,%eax
cmp    $0xc01,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x17,%eax
cmp    $0x1001,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x18,%eax
cmp    $0x1801,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x19,%eax
cmp    $0x2001,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x1a,%eax
cmp    $0x3001,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
mov    $0x1b,%eax
cmp    $0x4001,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
cmp    $0x6001,%edi
mov    $0x1d,%eax
jmp    125b <ZopfliGetDistSymbol+0x15b>
mov    $0x4,%eax
cmp    $0x7,%edi
jb     125e <ZopfliGetDistSymbol+0x15e>
cmp    $0x9,%edi
mov    $0x6,%eax
sbb    $0x0,%eax
ret

LLVM IR (-O0):
define i32 @ZopfliGetDistSymbol(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 193
br i1 %5, label %6, label %53
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 13
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %2
br label %110
15: ; preds = %9
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 7
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 4, i32* %2
br label %110
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 9
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 5, i32* %2
br label %110
23: ; preds = %19
store i32 6, i32* %2
br label %110
24: ; preds = %6
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 17
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 7, i32* %2
br label %110
28: ; preds = %24
%29 = load i32, i32* %3
%30 = icmp slt i32 %29, 25
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 8, i32* %2
br label %110
32: ; preds = %28
%33 = load i32, i32* %3
%34 = icmp slt i32 %33, 33
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 9, i32* %2
br label %110
36: ; preds = %32
%37 = load i32, i32* %3
%38 = icmp slt i32 %37, 49
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 10, i32* %2
br label %110
40: ; preds = %36
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 65
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 11, i32* %2
br label %110
44: ; preds = %40
%45 = load i32, i32* %3
%46 = icmp slt i32 %45, 97
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 12, i32* %2
br label %110
48: ; preds = %44
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 129
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 13, i32* %2
br label %110
52: ; preds = %48
store i32 14, i32* %2
br label %110
53: ; preds = %1
%54 = load i32, i32* %3
%55 = icmp slt i32 %54, 2049
br i1 %55, label %56, label %81
56: ; preds = %53
%57 = load i32, i32* %3
%58 = icmp slt i32 %57, 257
br i1 %58, label %59, label %60
59: ; preds = %56
store i32 15, i32* %2
br label %110
60: ; preds = %56
%61 = load i32, i32* %3
%62 = icmp slt i32 %61, 385
br i1 %62, label %63, label %64
63: ; preds = %60
store i32 16, i32* %2
br label %110
64: ; preds = %60
%65 = load i32, i32* %3
%66 = icmp slt i32 %65, 513
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 17, i32* %2
br label %110
68: ; preds = %64
%69 = load i32, i32* %3
%70 = icmp slt i32 %69, 769
br i1 %70, label %71, label %72
71: ; preds = %68
store i32 18, i32* %2
br label %110
72: ; preds = %68
%73 = load i32, i32* %3
%74 = icmp slt i32 %73, 1025
br i1 %74, label %75, label %76
75: ; preds = %72
store i32 19, i32* %2
br label %110
76: ; preds = %72
%77 = load i32, i32* %3
%78 = icmp slt i32 %77, 1537
br i1 %78, label %79, label %80
79: ; preds = %76
store i32 20, i32* %2
br label %110
80: ; preds = %76
store i32 21, i32* %2
br label %110
81: ; preds = %53
%82 = load i32, i32* %3
%83 = icmp slt i32 %82, 3073
br i1 %83, label %84, label %85
84: ; preds = %81
store i32 22, i32* %2
br label %110
85: ; preds = %81
%86 = load i32, i32* %3
%87 = icmp slt i32 %86, 4097
br i1 %87, label %88, label %89
88: ; preds = %85
store i32 23, i32* %2
br label %110
89: ; preds = %85
%90 = load i32, i32* %3
%91 = icmp slt i32 %90, 6145
br i1 %91, label %92, label %93
92: ; preds = %89
store i32 24, i32* %2
br label %110
93: ; preds = %89
%94 = load i32, i32* %3
%95 = icmp slt i32 %94, 8193
br i1 %95, label %96, label %97
96: ; preds = %93
store i32 25, i32* %2
br label %110
97: ; preds = %93
%98 = load i32, i32* %3
%99 = icmp slt i32 %98, 12289
br i1 %99, label %100, label %101
100: ; preds = %97
store i32 26, i32* %2
br label %110
101: ; preds = %97
%102 = load i32, i32* %3
%103 = icmp slt i32 %102, 16385
br i1 %103, label %104, label %105
104: ; preds = %101
store i32 27, i32* %2
br label %110
105: ; preds = %101
%106 = load i32, i32* %3
%107 = icmp slt i32 %106, 24577
br i1 %107, label %108, label %109
108: ; preds = %105
store i32 28, i32* %2
br label %110
109: ; preds = %105
store i32 29, i32* %2
br label %110
110: ; preds = %109, %108, %104, %100, %96, %92, %88, %84, %80, %79, %75, %71, %67, %63, %59, %52, %51, %47, %43, %39, %35, %31, %27, %23, %22, %18, %12
%111 = load i32, i32* %2
ret i32 %111
}

LLVM IR (-O2):
define i32 @ZopfliGetDistSymbol(i32 %0) {
%2 = icmp slt i32 %0, 193
br i1 %2, label %3, label %29
3: ; preds = %1
%4 = icmp slt i32 %0, 13
br i1 %4, label %5, label %14
5: ; preds = %3
%6 = icmp slt i32 %0, 5
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = add nsw i32 %0, -1
br label %59
9: ; preds = %5
%10 = icmp ult i32 %0, 7
br i1 %10, label %59, label %11
11: ; preds = %9
%12 = icmp ult i32 %0, 9
%13 = select i1 %12, i32 5, i32 6
br label %59
14: ; preds = %3
%15 = icmp ult i32 %0, 17
br i1 %15, label %59, label %16
16: ; preds = %14
%17 = icmp ult i32 %0, 25
br i1 %17, label %59, label %18
18: ; preds = %16
%19 = icmp ult i32 %0, 33
br i1 %19, label %59, label %20
20: ; preds = %18
%21 = icmp ult i32 %0, 49
br i1 %21, label %59, label %22
22: ; preds = %20
%23 = icmp ult i32 %0, 65
br i1 %23, label %59, label %24
24: ; preds = %22
%25 = icmp ult i32 %0, 97
br i1 %25, label %59, label %26
26: ; preds = %24
%27 = icmp ult i32 %0, 129
%28 = select i1 %27, i32 13, i32 14
br label %59
29: ; preds = %1
%30 = icmp ult i32 %0, 2049
br i1 %30, label %31, label %44
31: ; preds = %29
%32 = icmp ult i32 %0, 257
br i1 %32, label %59, label %33
33: ; preds = %31
%34 = icmp ult i32 %0, 385
br i1 %34, label %59, label %35
35: ; preds = %33
%36 = icmp ult i32 %0, 513
br i1 %36, label %59, label %37
37: ; preds = %35
%38 = icmp ult i32 %0, 769
br i1 %38, label %59, label %39
39: ; preds = %37
%40 = icmp ult i32 %0, 1025
br i1 %40, label %59, label %41
41: ; preds = %39
%42 = icmp ult i32 %0, 1537
%43 = select i1 %42, i32 20, i32 21
br label %59
44: ; preds = %29
%45 = icmp ult i32 %0, 3073
br i1 %45, label %59, label %46
46: ; preds = %44
%47 = icmp ult i32 %0, 4097
br i1 %47, label %59, label %48
48: ; preds = %46
%49 = icmp ult i32 %0, 6145
br i1 %49, label %59, label %50
50: ; preds = %48
%51 = icmp ult i32 %0, 8193
br i1 %51, label %59, label %52
52: ; preds = %50
%53 = icmp ult i32 %0, 12289
br i1 %53, label %59, label %54
54: ; preds = %52
%55 = icmp ult i32 %0, 16385
br i1 %55, label %59, label %56
56: ; preds = %54
%57 = icmp ult i32 %0, 24577
%58 = select i1 %57, i32 28, i32 29
br label %59
59: ; preds = %56, %54, %52, %50, %48, %46, %44, %41, %39, %37, %35, %33, %31, %26, %24, %22, %20, %18, %16, %14, %11, %9, %7
%60 = phi i32 [ %8, %7 ], [ 4, %9 ], [ %13, %11 ], [ 7, %14 ], [ 8, %16 ], [ 9, %18 ], [ 10, %20 ], [ 11, %22 ], [ 12, %24 ], [ %28, %26 ], [ 15, %31 ], [ 16, %33 ], [ 17, %35 ], [ 18, %37 ], [ 19, %39 ], [ %43, %41 ], [ 22, %44 ], [ 23, %46 ], [ 24, %48 ], [ 25, %50 ], [ 26, %52 ], [ 27, %54 ], [ %58, %56 ]
ret i32 %60
}