#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 /*<<< orphan*/ abort();
int /*<<< orphan*/ fail1();
int /*<<< orphan*/ fail2();
int /*<<< orphan*/ fail3();
int /*<<< orphan*/ fail4();
void foo(long x) {
  switch (x) {
  case -6:
    fail1();
    break;
  case 0:
    fail2();
    break;
  case 1:
  case 2:
    break;
  case 3:
  case 4:
  case 5:
    fail3();
    break;
  default:
    fail4();
    break;
  }
  switch (x) {
  case -3:
    fail1();
    break;
  case 0:
  case 4:
    fail2();
    break;
  case 1:
  case 3:
    break;
  case 2:
  case 8:
    abort();
    break;
  default:
    fail4();
    break;
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x10(%rbp)
sub    $0xb,%rax
ja     11af <foo+0x5f>
mov    -0x10(%rbp),%rax
lea    0xe83(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <fail1@plt>
jmp    11b6 <foo+0x66>
mov    $0x0,%al
call   1030 <fail2@plt>
jmp    11b6 <foo+0x66>
jmp    11b6 <foo+0x66>
mov    $0x0,%al
call   1060 <fail3@plt>
jmp    11b6 <foo+0x66>
mov    $0x0,%al
call   1040 <fail4@plt>
mov    -0x8(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
sub    $0xb,%rax
ja     1204 <foo+0xb4>
mov    -0x18(%rbp),%rax
lea    0xe59(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <fail1@plt>
jmp    120b <foo+0xbb>
mov    $0x0,%al
call   1030 <fail2@plt>
jmp    120b <foo+0xbb>
jmp    120b <foo+0xbb>
mov    $0x0,%al
call   1050 <abort@plt>
mov    $0x0,%al
call   1040 <fail4@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
mov    %rdi,%rbx
lea    0x6(%rdi),%rax
cmp    $0xb,%rax
ja     1180 <foo+0x30>
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1060 <fail3@plt>
jmp    1187 <foo+0x37>
xor    %eax,%eax
call   1070 <fail1@plt>
jmp    11a3 <foo+0x53>
xor    %eax,%eax
call   1040 <fail4@plt>
add    $0x3,%rbx
cmp    $0xb,%rbx
ja     11a3 <foo+0x53>
lea    0xe98(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1040 <fail4@plt>
xor    %eax,%eax
call   1030 <fail2@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <fail2@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <fail1@plt>
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
define void @foo(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
switch i64 %3, label %11 [
i64 -6, label %4
i64 0, label %6
i64 1, label %8
i64 2, label %8
i64 3, label %9
i64 4, label %9
i64 5, label %9
]
4: ; preds = %1
%5 = call i32 (...) @fail1()
br label %13
6: ; preds = %1
%7 = call i32 (...) @fail2()
br label %13
8: ; preds = %1, %1
br label %13
9: ; preds = %1, %1, %1
%10 = call i32 (...) @fail3()
br label %13
11: ; preds = %1
%12 = call i32 (...) @fail4()
br label %13
13: ; preds = %11, %9, %8, %6, %4
%14 = load i64, i64* %2
switch i64 %14, label %22 [
i64 -3, label %15
i64 0, label %17
i64 4, label %17
i64 1, label %19
i64 3, label %19
i64 2, label %20
i64 8, label %20
]
15: ; preds = %13
%16 = call i32 (...) @fail1()
br label %24
17: ; preds = %13, %13
%18 = call i32 (...) @fail2()
br label %24
19: ; preds = %13, %13
br label %24
20: ; preds = %13, %13
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %13
%23 = call i32 (...) @fail4()
br label %24
24: ; preds = %22, %19, %17, %15
ret void
}

LLVM IR (-O2):
define void @foo(i64 %0) {
switch i64 %0, label %8 [
i64 -6, label %2
i64 0, label %4
i64 5, label %6
i64 4, label %6
i64 3, label %6
i64 1, label %19
i64 2, label %15
]
2: ; preds = %1
%3 = tail call i32 (...) @fail1()
br label %17
4: ; preds = %1
%5 = tail call i32 (...) @fail2()
br label %13
6: ; preds = %1, %1, %1
%7 = tail call i32 (...) @fail3()
br label %10
8: ; preds = %1
%9 = tail call i32 (...) @fail4()
br label %10
10: ; preds = %8, %6
switch i64 %0, label %17 [
i64 -3, label %11
i64 0, label %13
i64 4, label %13
i64 1, label %19
i64 3, label %19
i64 8, label %15
]
11: ; preds = %10
%12 = tail call i32 (...) @fail1()
br label %19
13: ; preds = %4, %10, %10
%14 = tail call i32 (...) @fail2()
br label %19
15: ; preds = %10, %1
%16 = tail call i32 (...) @abort()
unreachable
17: ; preds = %2, %10
%18 = tail call i32 (...) @fail4()
br label %19
19: ; preds = %1, %10, %10, %17, %13, %11
ret void
}