int shift_const(unsigned int shamt) {
  switch (shamt) {
  case 1:
    return 0x80000000;
  case 2:
    return 0xC0000000;
  case 3:
    return 0xE0000000;
  case 4:
    return 0xF0000000;
  case 5:
    return 0xF8000000;
  case 6:
    return 0xFC000000;
  case 7:
    return 0xFE000000;
  case 8:
    return 0xFF000000;
  case 9:
    return 0xFF800000;
  case 10:
    return 0xFFC00000;
  case 11:
    return 0xFFE00000;
  case 12:
    return 0xFFF00000;
  case 13:
    return 0xFFF80000;
  case 14:
    return 0xFFFC0000;
  case 15:
    return 0xFFFE0000;
  case 16:
    return 0xFFFF0000;
  case 17:
    return 0xFFFF8000;
  case 18:
    return 0xFFFFC000;
  case 19:
    return 0xFFFFE000;
  case 20:
    return 0xFFFFF000;
  case 21:
    return 0xFFFFF800;
  case 22:
    return 0xFFFFFC00;
  case 23:
    return 0xFFFFFE00;
  case 24:
    return 0xFFFFFF00;
  case 25:
    return 0xFFFFFF80;
  case 26:
    return 0xFFFFFFC0;
  case 27:
    return 0xFFFFFFE0;
  case 28:
    return 0xFFFFFFF0;
  case 29:
    return 0xFFFFFFF8;
  case 30:
    return 0xFFFFFFFC;
  case 31:
    return 0xFFFFFFFE;
  case 0:
    return 0x00000000;
  }
  return 0;
}


x86 assembly (clang, -O0):
<shift_const>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x1f,%rax
ja     12ac <shift_const+0x1ac>
mov    -0x10(%rbp),%rax
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x80000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xc0000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xe0000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xf0000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xf8000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfc000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfe000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xff000000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xff800000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffc00000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffe00000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfff00000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfff80000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffc0000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffe0000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffff0000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffff8000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffc000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffe000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffff000,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffff800,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffc00,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffe00,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffff00,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffff80,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffffc0,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xffffffe0,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffff0,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffff8,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffffc,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0xfffffffe,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0x0,-0x4(%rbp)
jmp    12b3 <shift_const+0x1b3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_const>:
xor    %eax,%eax
cmp    $0x1f,%edi
ja     1114 <shift_const+0x14>
movslq %edi,%rax
lea    0xeef(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @shift_const(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %37 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
i32 9, label %13
i32 10, label %14
i32 11, label %15
i32 12, label %16
i32 13, label %17
i32 14, label %18
i32 15, label %19
i32 16, label %20
i32 17, label %21
i32 18, label %22
i32 19, label %23
i32 20, label %24
i32 21, label %25
i32 22, label %26
i32 23, label %27
i32 24, label %28
i32 25, label %29
i32 26, label %30
i32 27, label %31
i32 28, label %32
i32 29, label %33
i32 30, label %34
i32 31, label %35
i32 0, label %36
]
5: ; preds = %1
store i32 -2147483648, i32* %2
br label %38
6: ; preds = %1
store i32 -1073741824, i32* %2
br label %38
7: ; preds = %1
store i32 -536870912, i32* %2
br label %38
8: ; preds = %1
store i32 -268435456, i32* %2
br label %38
9: ; preds = %1
store i32 -134217728, i32* %2
br label %38
10: ; preds = %1
store i32 -67108864, i32* %2
br label %38
11: ; preds = %1
store i32 -33554432, i32* %2
br label %38
12: ; preds = %1
store i32 -16777216, i32* %2
br label %38
13: ; preds = %1
store i32 -8388608, i32* %2
br label %38
14: ; preds = %1
store i32 -4194304, i32* %2
br label %38
15: ; preds = %1
store i32 -2097152, i32* %2
br label %38
16: ; preds = %1
store i32 -1048576, i32* %2
br label %38
17: ; preds = %1
store i32 -524288, i32* %2
br label %38
18: ; preds = %1
store i32 -262144, i32* %2
br label %38
19: ; preds = %1
store i32 -131072, i32* %2
br label %38
20: ; preds = %1
store i32 -65536, i32* %2
br label %38
21: ; preds = %1
store i32 -32768, i32* %2
br label %38
22: ; preds = %1
store i32 -16384, i32* %2
br label %38
23: ; preds = %1
store i32 -8192, i32* %2
br label %38
24: ; preds = %1
store i32 -4096, i32* %2
br label %38
25: ; preds = %1
store i32 -2048, i32* %2
br label %38
26: ; preds = %1
store i32 -1024, i32* %2
br label %38
27: ; preds = %1
store i32 -512, i32* %2
br label %38
28: ; preds = %1
store i32 -256, i32* %2
br label %38
29: ; preds = %1
store i32 -128, i32* %2
br label %38
30: ; preds = %1
store i32 -64, i32* %2
br label %38
31: ; preds = %1
store i32 -32, i32* %2
br label %38
32: ; preds = %1
store i32 -16, i32* %2
br label %38
33: ; preds = %1
store i32 -8, i32* %2
br label %38
34: ; preds = %1
store i32 -4, i32* %2
br label %38
35: ; preds = %1
store i32 -2, i32* %2
br label %38
36: ; preds = %1
store i32 0, i32* %2
br label %38
37: ; preds = %1
store i32 0, i32* %2
br label %38
38: ; preds = %37, %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@switch.table.shift_const = [32 x i32] [i32 0, i32 -2147483648, i32 -1073741824, i32 -536870912, i32 -268435456, i32 -134217728, i32 -67108864, i32 -33554432, i32 -16777216, i32 -8388608, i32 -4194304, i32 -2097152, i32 -1048576, i32 -524288, i32 -262144, i32 -131072, i32 -65536, i32 -32768, i32 -16384, i32 -8192, i32 -4096, i32 -2048, i32 -1024, i32 -512, i32 -256, i32 -128, i32 -64, i32 -32, i32 -16, i32 -8, i32 -4, i32 -2]
define i32 @shift_const(i32 %0) {
%2 = icmp ult i32 %0, 32
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds [32 x i32], [32 x i32]* @switch.table.shift_const, i64 0, i64 %4
%6 = load i32, i32* %5
br label %7
7: ; preds = %1, %3
%8 = phi i32 [ %6, %3 ], [ 0, %1 ]
ret i32 %8
}