void switches() {
  static int weights[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5};
  switch (weights[0]) {
  default:
    break;
  }
  for (int i = 0, len = sizeof(weights) / sizeof(weights[0]); i < len; ++i) {
    switch (i[weights]) {
    case 1:
      if (i) {
      }
    case 2:
      if (i) {
      }
      break;
    case 3:
      if (i) {
      }
      continue;
    case 4:
      if (i) {
      }
      switch (i) {
      case 6 ... 9:
        if (i) {
        }
        continue;
      }
    default:
      if (i == len - 1)
        return;
    }
  }
  if (weights[0]) {
  }
}


x86 assembly (clang, -O0):
<switches>:
push   %rbp
mov    %rsp,%rbp
jmp    1109 <switches+0x9>
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fd <switches+0xfd>
movslq -0x4(%rbp),%rcx
lea    0x2f02(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11cf <switches+0xcf>
mov    -0x10(%rbp),%rax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x4(%rbp)
je     1166 <switches+0x66>
jmp    1166 <switches+0x66>
jmp    116b <switches+0x6b>
cmpl   $0x0,-0x4(%rbp)
je     117a <switches+0x7a>
jmp    117a <switches+0x7a>
jmp    11ea <switches+0xea>
cmpl   $0x0,-0x4(%rbp)
je     118e <switches+0x8e>
jmp    118e <switches+0x8e>
jmp    11ef <switches+0xef>
cmpl   $0x0,-0x4(%rbp)
je     11a2 <switches+0xa2>
jmp    11a2 <switches+0xa2>
mov    -0x4(%rbp),%eax
add    $0xfffffffa,%eax
sub    $0x3,%eax
ja     11ca <switches+0xca>
jmp    11b6 <switches+0xb6>
cmpl   $0x0,-0x4(%rbp)
je     11c5 <switches+0xc5>
jmp    11c5 <switches+0xc5>
jmp    11ef <switches+0xef>
jmp    11cf <switches+0xcf>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11e5 <switches+0xe5>
jmp    120f <switches+0x10f>
jmp    11ea <switches+0xea>
jmp    11ef <switches+0xef>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1117 <switches+0x17>
cmpl   $0x0,0x2e2c(%rip)
je     120f <switches+0x10f>
jmp    120f <switches+0x10f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<switches>:
ret

LLVM IR (-O0):
@switches.weights = internal global [15 x i32] [i32 1, i32 2, i32 2, i32 3, i32 3, i32 3, i32 4, i32 4, i32 4, i32 4, i32 5, i32 5, i32 5, i32 5, i32 5]
define void @switches() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* getelementptr inbounds ([15 x i32], [15 x i32]* @switches.weights, i64 0, i64 0)
switch i32 %3, label %4 [
]
4: ; preds = %0
br label %5
5: ; preds = %4
store i32 0, i32* %1
store i32 15, i32* %2
br label %6
6: ; preds = %50, %5
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %53
10: ; preds = %6
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [15 x i32], [15 x i32]* @switches.weights, i64 0, i64 %12
%14 = load i32, i32* %13
switch i32 %14, label %42 [
i32 1, label %15
i32 2, label %20
i32 3, label %25
i32 4, label %30
]
15: ; preds = %10
%16 = load i32, i32* %1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
br label %19
19: ; preds = %18, %15
br label %20
20: ; preds = %10, %19
%21 = load i32, i32* %1
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
br label %24
24: ; preds = %23, %20
br label %49
25: ; preds = %10
%26 = load i32, i32* %1
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
br label %29
29: ; preds = %28, %25
br label %50
30: ; preds = %10
%31 = load i32, i32* %1
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30
br label %34
34: ; preds = %33, %30
%35 = load i32, i32* %1
switch i32 %35, label %41 [
i32 6, label %36
i32 7, label %36
i32 8, label %36
i32 9, label %36
]
36: ; preds = %34, %34, %34, %34
%37 = load i32, i32* %1
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36
br label %40
40: ; preds = %39, %36
br label %50
41: ; preds = %34
br label %42
42: ; preds = %10, %41
%43 = load i32, i32* %1
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 1
%46 = icmp eq i32 %43, %45
br i1 %46, label %47, label %48
47: ; preds = %42
br label %57
48: ; preds = %42
br label %49
49: ; preds = %48, %24
br label %50
50: ; preds = %49, %40, %29
%51 = load i32, i32* %1
%52 = add nsw i32 %51, 1
store i32 %52, i32* %1
br label %6
53: ; preds = %6
%54 = load i32, i32* getelementptr inbounds ([15 x i32], [15 x i32]* @switches.weights, i64 0, i64 0)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %53
br label %57
57: ; preds = %47, %56, %53
ret void
}

LLVM IR (-O2):
define void @switches() {
ret void
}