#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 *);
void fred(int x) {
  switch (x) {
  case 1:
    printf("1\n");
    return;
  case 2:
    printf("2\n");
    break;
  case 3:
    printf("3\n");
    return;
  }
  printf("out\n");
}


x86 assembly (clang, -O0):
<fred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     1151 <fred+0x41>
jmp    112f <fred+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1162 <fred+0x52>
jmp    1140 <fred+0x30>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     1173 <fred+0x63>
jmp    1184 <fred+0x74>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <fred+0x80>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    1184 <fred+0x74>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    1190 <fred+0x80>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fred>:
cmp    $0x1,%edi
je     113c <fred+0x2c>
cmp    $0x3,%edi
je     1148 <fred+0x38>
cmp    $0x2,%edi
jne    1130 <fred+0x20>
push   %rax
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
lea    0xecd(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xec5(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xeb1(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"1\0A\00"
@.str.1 = [3 x i8] c"2\0A\00"
@.str.2 = [3 x i8] c"3\0A\00"
@.str.3 = [5 x i8] c"out\0A\00"
define void @fred(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
switch i32 %3, label %10 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %1
%5 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
10: ; preds = %1, %6
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %8, %4
ret void
}

LLVM IR (-O2):
@str = [2 x i8] c"3\00"
@str.4 = [2 x i8] c"2\00"
@str.5 = [4 x i8] c"out\00"
@str.6 = [2 x i8] c"1\00"
define void @fred(i32 %0) {
switch i32 %0, label %5 [
i32 1, label %6
i32 2, label %2
i32 3, label %4
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.4, i64 0, i64 0))
br label %5
4: ; preds = %1
br label %6
5: ; preds = %1, %2
br label %6
6: ; preds = %1, %5, %4
%7 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0), %1 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
ret void
}