int bar(unsigned int v, int w) {
  const char *s;
  switch (v) {
  case 0:
    s = "foo";
    break;
  case 1:
    s = "bar";
    break;
  case 2:
    s = "spam";
    break;
  default:
    __builtin_printf("baz\n");
    if (v > 25)
      __builtin_printf("bl1\n");
    else
      __builtin_printf("bl2\n");
    goto lab;
  }
  __builtin_printf("%s\n", s);
  if (w > 25)
    __builtin_printf("cl1\n");
  else
    __builtin_printf("cl2\n");
lab:
  __builtin_printf("dl\n");
  return v + w;
}


x86 assembly (clang, -O0):
<bar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1153 <bar+0x43>
jmp    1131 <bar+0x21>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1163 <bar+0x53>
jmp    1142 <bar+0x32>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1173 <bar+0x63>
jmp    1183 <bar+0x73>
lea    0xea6(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <bar+0xb1>
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <bar+0xb1>
lea    0xe8e(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <bar+0xb1>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x19,-0x4(%rbp)
jbe    11ae <bar+0x9e>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bc <bar+0xac>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1203 <bar+0xf3>
mov    -0x10(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x19,-0x8(%rbp)
jle    11f0 <bar+0xe0>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fe <bar+0xee>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1203 <bar+0xf3>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bar>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
cmp    $0x3,%edi
jae    1149 <bar+0x39>
movslq %ebp,%rax
lea    0xefe(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
cmp    $0x1a,%ebx
lea    0xed8(%rip),%rax
lea    0xeca(%rip),%rdi
cmovge %rax,%rdi
jmp    116a <bar+0x5a>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1a,%ebp
lea    0xec1(%rip),%rax
lea    0xeb6(%rip),%rdi
cmovae %rax,%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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 = [5 x i8] c"baz\0A\00"
@.str.4 = [5 x i8] c"bl1\0A\00"
@.str.5 = [5 x i8] c"bl2\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [5 x i8] c"cl1\0A\00"
@.str.8 = [5 x i8] c"cl2\0A\00"
@.str.9 = [4 x i8] c"dl\0A\00"
define i32 @bar(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
switch i32 %6, label %10 [
i32 0, label %7
i32 1, label %8
i32 2, label %9
]
7: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %5
br label %19
8: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %19
9: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %19
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %3
%13 = icmp ugt i32 %12, 25
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %18
16: ; preds = %10
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
br label %29
19: ; preds = %9, %8, %7
%20 = load i8*, i8** %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 25
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %28
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
br label %29
29: ; preds = %28, %18
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = add i32 %31, %32
ret i32 %33
}

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"
@str = [4 x i8] c"cl2\00"
@str.10 = [3 x i8] c"dl\00"
@str.11 = [4 x i8] c"cl1\00"
@str.12 = [4 x i8] c"baz\00"
@str.13 = [4 x i8] c"bl2\00"
@str.14 = [4 x i8] c"bl1\00"
@reltable.bar = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.bar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.bar to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.bar to i64)) to i32)]
define i32 @bar(i32 %0, i32 %1) {
%3 = icmp ult i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.12, i64 0, i64 0))
%6 = icmp ugt i32 %0, 25
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.14, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.13, i64 0, i64 0)
br label %15
8: ; preds = %2
%9 = sext i32 %0 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.bar to i8*), i64 %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = icmp sgt i32 %1, 25
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.11, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0)
br label %15
15: ; preds = %8, %4
%16 = phi i8* [ %7, %4 ], [ %14, %8 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%19 = add i32 %1, %0
ret i32 %19
}