void frobulate_for_gcc(unsigned int v) {
  const char *s;
  switch (v) {
  case 0:
    s = "foo";
    break;
  case 1:
    s = "bar";
    break;
  case 2:
    s = "spam";
    break;
  default:
    s = (const char *)0;
    break;
  }
  if (!s)
    __builtin_abort();
  __builtin_printf("%s\n", s);
}


x86 assembly (clang, -O0):
<frobulate_for_gcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1160 <frobulate_for_gcc+0x40>
jmp    113e <frobulate_for_gcc+0x1e>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1170 <frobulate_for_gcc+0x50>
jmp    114f <frobulate_for_gcc+0x2f>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1180 <frobulate_for_gcc+0x60>
jmp    1190 <frobulate_for_gcc+0x70>
lea    0xe99(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <frobulate_for_gcc+0x78>
lea    0xe8d(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <frobulate_for_gcc+0x78>
lea    0xe81(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <frobulate_for_gcc+0x78>
movq   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a8 <frobulate_for_gcc+0x88>
call   1030 <abort@plt>
mov    -0x10(%rbp),%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frobulate_for_gcc>:
push   %rax
cmp    $0x3,%edi
jae    113d <frobulate_for_gcc+0x1d>
movslq %edi,%rax
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rax
jmp    1040 <puts@plt>
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [5 x i8] c"spam\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define void @frobulate_for_gcc(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %8 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
]
5: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %9
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %9
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %9
8: ; preds = %1
store i8* null, i8** %3
br label %9
9: ; preds = %8, %7, %6, %5
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %9
unreachable
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [4 x i8] c"bar\00"
@.str.2 = [5 x i8] c"spam\00"
@reltable.frobulate_for_gcc = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.frobulate_for_gcc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.frobulate_for_gcc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.frobulate_for_gcc to i64)) to i32)]
define void @frobulate_for_gcc(i32 %0) {
%2 = icmp ult i32 %0, 3
br i1 %2, label %4, label %3
3: ; preds = %1
tail call void @abort()
unreachable
4: ; preds = %1
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.frobulate_for_gcc to i8*), i64 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
ret void
}