#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 *, char *);
void test2(int e) {
  char *s = e == 0 ? "0" : e == 1 ? "1" : e == 2 ? "2" : "> 2";
  printf("%s\n", s);
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1135 <test2+0x25>
lea    0xed4(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1173 <test2+0x63>
cmpl   $0x1,-0x4(%rbp)
jne    114f <test2+0x3f>
lea    0xebc(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    116b <test2+0x5b>
mov    -0x4(%rbp),%edx
lea    0xeab(%rip),%rax
lea    0xea6(%rip),%rcx
cmp    $0x2,%edx
cmove  %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
test   %edi,%edi
je     112c <test2+0x1c>
cmp    $0x1,%edi
jne    113f <test2+0x2f>
lea    0xee2(%rip),%rsi
lea    0xee1(%rip),%rdi
jmp    1030 <printf@plt>
lea    0xecd(%rip),%rsi
lea    0xece(%rip),%rdi
jmp    1030 <printf@plt>
cmp    $0x2,%edi
lea    0xebd(%rip),%rax
lea    0xeb4(%rip),%rsi
cmove  %rax,%rsi
lea    0xead(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [4 x i8] c"> 2\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @test2(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %18
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %7
br label %16
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 2
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
br label %16
16: ; preds = %11, %10
%17 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %10 ], [ %15, %11 ]
br label %18
18: ; preds = %16, %6
%19 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %6 ], [ %17, %16 ]
store i8* %19, i8** %3
%20 = load i8*, i8** %3
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [4 x i8] c"> 2\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define void @test2(i32 %0) {
switch i32 %0, label %2 [
i32 0, label %6
i32 1, label %5
]
2: ; preds = %1
%3 = icmp eq i32 %0, 2
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
br label %6
5: ; preds = %1
br label %6
6: ; preds = %1, %5, %2
%7 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %1 ], [ %4, %2 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %5 ]
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %7)
ret void
}