#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*/ printf(char *, long);
long switchFunc(long x) {
  long retVal = 0;
  switch (x) {
  case 0:
    retVal = 0;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 1:
    retVal = 1;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 2:
    retVal = 22;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 3:
    retVal = 333;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 4:
    retVal = 4444;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 5:
    retVal = 55555;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 6:
    retVal = 666666;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 7:
    retVal = 7777777;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 8:
    retVal = 88888888;
    printf("\nReturning %ld\n\n", retVal);
    break;
  case 9:
    retVal = 999999999;
    printf("\nReturning %ld\n\n", retVal);
    break;
  default:
    retVal = -1;
    printf("\nReturning %ld\n\n", retVal);
    break;
  }
  return retVal;
}


x86 assembly (clang, -O0):
<switchFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     126c <switchFunc+0x15c>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x16,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x14d,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x115c,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0xd903,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0xa2c2a,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x76adf1,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe00(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x54c5638,-0x10(%rbp)
05
mov    -0x10(%rbp),%rsi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0x3b9ac9ff,-0x10(%rbp)
3b
mov    -0x10(%rbp),%rsi
lea    0xdc6(%rip),%rdi
call   1030 <printf@plt>
jmp    1284 <switchFunc+0x174>
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    -0x10(%rbp),%rsi
lea    0xda9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switchFunc>:
push   %rbx
mov    $0xffffffffffffffff,%rbx
cmp    $0x9,%rdi
ja     1129 <switchFunc+0x19>
lea    0xef3(%rip),%rax
mov    (%rax,%rdi,8),%rbx
lea    0xed0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0AReturning %ld\0A\0A\00"
define i64 @switchFunc(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
%4 = load i64, i64* %2
switch i64 %4, label %35 [
i64 0, label %5
i64 1, label %8
i64 2, label %11
i64 3, label %14
i64 4, label %17
i64 5, label %20
i64 6, label %23
i64 7, label %26
i64 8, label %29
i64 9, label %32
]
5: ; preds = %1
store i64 0, i64* %3
%6 = load i64, i64* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %6)
br label %38
8: ; preds = %1
store i64 1, i64* %3
%9 = load i64, i64* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %38
11: ; preds = %1
store i64 22, i64* %3
%12 = load i64, i64* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %38
14: ; preds = %1
store i64 333, i64* %3
%15 = load i64, i64* %3
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %15)
br label %38
17: ; preds = %1
store i64 4444, i64* %3
%18 = load i64, i64* %3
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %18)
br label %38
20: ; preds = %1
store i64 55555, i64* %3
%21 = load i64, i64* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %21)
br label %38
23: ; preds = %1
store i64 666666, i64* %3
%24 = load i64, i64* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %24)
br label %38
26: ; preds = %1
store i64 7777777, i64* %3
%27 = load i64, i64* %3
%28 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %27)
br label %38
29: ; preds = %1
store i64 88888888, i64* %3
%30 = load i64, i64* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %30)
br label %38
32: ; preds = %1
store i64 999999999, i64* %3
%33 = load i64, i64* %3
%34 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %33)
br label %38
35: ; preds = %1
store i64 -1, i64* %3
%36 = load i64, i64* %3
%37 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %36)
br label %38
38: ; preds = %35, %32, %29, %26, %23, %20, %17, %14, %11, %8, %5
%39 = load i64, i64* %3
ret i64 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0AReturning %ld\0A\0A\00"
@switch.table.switchFunc = [10 x i64] [i64 0, i64 1, i64 22, i64 333, i64 4444, i64 55555, i64 666666, i64 7777777, i64 88888888, i64 999999999]
define i64 @switchFunc(i64 %0) {
%2 = icmp ult i64 %0, 10
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = getelementptr inbounds [10 x i64], [10 x i64]* @switch.table.switchFunc, i64 0, i64 %0
%5 = load i64, i64* %4
br label %6
6: ; preds = %1, %3
%7 = phi i64 [ %5, %3 ], [ -1, %1 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %7)
ret i64 %7
}