const char *do_switch(int x) {
  switch (x) {
  case 0:
    return "zero";
  case 1:
    return "one";
  case 2:
    return "two";
  case 3:
    return "three";
  case 4:
    return "four";
  case 5:
    return "five";
  case 6:
    return "six";
  case 7:
    return "seven";
  case 8:
    return "eight";
  case 9:
    return "nine";
  case 10:
    return "ten";
  case 100500:
    return "stopyatsot";
  default:
    return "many";
  };
}


x86 assembly (clang, -O0):
<do_switch>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11d7 <do_switch+0xd7>
jmp    111a <do_switch+0x1a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     11e7 <do_switch+0xe7>
jmp    112b <do_switch+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11f7 <do_switch+0xf7>
jmp    113c <do_switch+0x3c>
mov    -0x10(%rbp),%eax
sub    $0x3,%eax
je     1207 <do_switch+0x107>
jmp    114d <do_switch+0x4d>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     1217 <do_switch+0x117>
jmp    115e <do_switch+0x5e>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     1227 <do_switch+0x127>
jmp    116f <do_switch+0x6f>
mov    -0x10(%rbp),%eax
sub    $0x6,%eax
je     1237 <do_switch+0x137>
jmp    1180 <do_switch+0x80>
mov    -0x10(%rbp),%eax
sub    $0x7,%eax
je     1247 <do_switch+0x147>
jmp    1191 <do_switch+0x91>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
je     1257 <do_switch+0x157>
jmp    11a2 <do_switch+0xa2>
mov    -0x10(%rbp),%eax
sub    $0x9,%eax
je     1267 <do_switch+0x167>
jmp    11b3 <do_switch+0xb3>
mov    -0x10(%rbp),%eax
sub    $0xa,%eax
je     1277 <do_switch+0x177>
jmp    11c4 <do_switch+0xc4>
mov    -0x10(%rbp),%eax
sub    $0x18894,%eax
je     1287 <do_switch+0x187>
jmp    1297 <do_switch+0x197>
lea    0xe22(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xe17(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xe0b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdff(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdf5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdea(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xddf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdd3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdc9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdbf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xdb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xda8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12a2 <do_switch+0x1a2>
lea    0xda3(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_switch>:
cmp    $0xa,%edi
ja     1126 <do_switch+0x26>
lea    0xf20(%rip),%rax
mov    %edi,%ecx
lea    0xeeb(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0xf0c(%rip),%rax
ret
cmp    $0x18894,%edi
jne    117e <do_switch+0x7e>
lea    0xf2d(%rip),%rax
ret
lea    0xef8(%rip),%rax
ret
lea    0xef4(%rip),%rax
ret
lea    0xef2(%rip),%rax
ret
lea    0xeef(%rip),%rax
ret
lea    0xeec(%rip),%rax
ret
lea    0xee8(%rip),%rax
ret
lea    0xee6(%rip),%rax
ret
lea    0xee4(%rip),%rax
ret
lea    0xee1(%rip),%rax
ret
lea    0xee8(%rip),%rax
ret

LLVM IR (-O0):
@.str = [5 x i8] c"zero\00"
@.str.1 = [4 x i8] c"one\00"
@.str.2 = [4 x i8] c"two\00"
@.str.3 = [6 x i8] c"three\00"
@.str.4 = [5 x i8] c"four\00"
@.str.5 = [5 x i8] c"five\00"
@.str.6 = [4 x i8] c"six\00"
@.str.7 = [6 x i8] c"seven\00"
@.str.8 = [6 x i8] c"eight\00"
@.str.9 = [5 x i8] c"nine\00"
@.str.10 = [4 x i8] c"ten\00"
@.str.11 = [11 x i8] c"stopyatsot\00"
@.str.12 = [5 x i8] c"many\00"
define i8* @do_switch(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
i32 3, label %8
i32 4, label %9
i32 5, label %10
i32 6, label %11
i32 7, label %12
i32 8, label %13
i32 9, label %14
i32 10, label %15
i32 100500, label %16
]
5: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %18
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %18
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %18
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %18
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %18
10: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %18
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %18
12: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %18
13: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %18
14: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %18
15: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %18
16: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %18
17: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %18
18: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"zero\00"
@.str.1 = [4 x i8] c"one\00"
@.str.2 = [4 x i8] c"two\00"
@.str.3 = [6 x i8] c"three\00"
@.str.4 = [5 x i8] c"four\00"
@.str.5 = [5 x i8] c"five\00"
@.str.6 = [4 x i8] c"six\00"
@.str.7 = [6 x i8] c"seven\00"
@.str.8 = [6 x i8] c"eight\00"
@.str.9 = [5 x i8] c"nine\00"
@.str.10 = [4 x i8] c"ten\00"
@.str.11 = [11 x i8] c"stopyatsot\00"
@.str.12 = [5 x i8] c"many\00"
define i8* @do_switch(i32 %0) {
switch i32 %0, label %13 [
i32 0, label %14
i32 1, label %2
i32 2, label %3
i32 3, label %4
i32 4, label %5
i32 5, label %6
i32 6, label %7
i32 7, label %8
i32 8, label %9
i32 9, label %10
i32 10, label %11
i32 100500, label %12
]
2: ; preds = %1
br label %14
3: ; preds = %1
br label %14
4: ; preds = %1
br label %14
5: ; preds = %1
br label %14
6: ; preds = %1
br label %14
7: ; preds = %1
br label %14
8: ; preds = %1
br label %14
9: ; preds = %1
br label %14
10: ; preds = %1
br label %14
11: ; preds = %1
br label %14
12: ; preds = %1
br label %14
13: ; preds = %1
br label %14
14: ; preds = %1, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%15 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %15
}