#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*/ portWrite(char *);
int selectSite(int siteNum) {
  switch (siteNum) {
  case 1:
    if (portWrite("#:W1#") < 0)
      return -1;
    break;
  case 2:
    if (portWrite("#:W2#") < 0)
      return -1;
    break;
  case 3:
    if (portWrite("#:W3#") < 0)
      return -1;
    break;
  case 4:
    if (portWrite("#:W4#") < 0)
      return -1;
    break;
  default:
    return -1;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<selectSite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11dc <selectSite+0xcc>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec5(%rip),%rdi
call   1030 <portWrite@plt>
cmp    $0x0,%eax
jge    1165 <selectSite+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <selectSite+0xdf>
jmp    11e8 <selectSite+0xd8>
lea    0xea5(%rip),%rdi
call   1030 <portWrite@plt>
cmp    $0x0,%eax
jge    118b <selectSite+0x7b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <selectSite+0xdf>
jmp    11e8 <selectSite+0xd8>
lea    0xe85(%rip),%rdi
call   1030 <portWrite@plt>
cmp    $0x0,%eax
jge    11b1 <selectSite+0xa1>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <selectSite+0xdf>
jmp    11e8 <selectSite+0xd8>
lea    0xe65(%rip),%rdi
call   1030 <portWrite@plt>
cmp    $0x0,%eax
jge    11d7 <selectSite+0xc7>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <selectSite+0xdf>
jmp    11e8 <selectSite+0xd8>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ef <selectSite+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectSite>:
push   %rbx
mov    $0xffffffff,%ebx
add    $0xffffffff,%edi
cmp    $0x3,%edi
ja     115b <selectSite+0x4b>
lea    0xedb(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xedb(%rip),%rdi
jmp    1150 <selectSite+0x40>
lea    0xed8(%rip),%rdi
jmp    1150 <selectSite+0x40>
lea    0xed5(%rip),%rdi
jmp    1150 <selectSite+0x40>
lea    0xed2(%rip),%rdi
call   1030 <portWrite@plt>
test   %eax,%eax
js     115b <selectSite+0x4b>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"#:W1#\00"
@.str.1 = [6 x i8] c"#:W2#\00"
@.str.2 = [6 x i8] c"#:W3#\00"
@.str.3 = [6 x i8] c"#:W4#\00"
define i32 @selectSite(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %25 [
i32 1, label %5
i32 2, label %10
i32 3, label %15
i32 4, label %20
]
5: ; preds = %1
%6 = call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 -1, i32* %2
br label %27
9: ; preds = %5
br label %26
10: ; preds = %1
%11 = call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 -1, i32* %2
br label %27
14: ; preds = %10
br label %26
15: ; preds = %1
%16 = call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 -1, i32* %2
br label %27
19: ; preds = %15
br label %26
20: ; preds = %1
%21 = call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 -1, i32* %2
br label %27
24: ; preds = %20
br label %26
25: ; preds = %1
store i32 -1, i32* %2
br label %27
26: ; preds = %24, %19, %14, %9
store i32 0, i32* %2
br label %27
27: ; preds = %26, %25, %23, %18, %13, %8
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"#:W1#\00"
@.str.1 = [6 x i8] c"#:W2#\00"
@.str.2 = [6 x i8] c"#:W3#\00"
@.str.3 = [6 x i8] c"#:W4#\00"
define i32 @selectSite(i32 %0) {
switch i32 %0, label %15 [
i32 1, label %2
i32 2, label %5
i32 3, label %8
i32 4, label %11
]
2: ; preds = %1
%3 = tail call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %3, 0
br i1 %4, label %15, label %14
5: ; preds = %1
%6 = tail call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp slt i32 %6, 0
br i1 %7, label %15, label %14
8: ; preds = %1
%9 = tail call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i32 %9, 0
br i1 %10, label %15, label %14
11: ; preds = %1
%12 = tail call i32 @portWrite(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp slt i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11, %8, %5, %2
br label %15
15: ; preds = %1, %11, %8, %5, %2, %14
%16 = phi i32 [ 0, %14 ], [ -1, %2 ], [ -1, %5 ], [ -1, %8 ], [ -1, %11 ], [ -1, %1 ]
ret i32 %16
}