#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ portWrite(char *);
int /*<<< orphan*/ stderr;
int selectAPTrackingMode(int trackMode) {
  switch (trackMode) {
  case 0:
    fprintf(stderr, "Setting tracking mode to lunar.\n");
    if (portWrite("#:RT0#") < 0)
      return -1;
    break;
  case 1:
    fprintf(stderr, "Setting tracking mode to solar.\n");
    if (portWrite("#:RT1#") < 0)
      return -1;
    break;
  case 2:
    fprintf(stderr, "Setting tracking mode to sidereal.\n");
    if (portWrite("#:RT2#") < 0)
      return -1;
    break;
  case 3:
    fprintf(stderr, "Setting tracking mode to zero.\n");
    if (portWrite("#:RT9#") < 0)
      return -1;
    break;
  default:
    return -1;
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<selectAPTrackingMode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     123c <selectAPTrackingMode+0x11c>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xec5(%rip),%rdi
call   1040 <portWrite@plt>
cmp    $0x0,%eax
jge    1186 <selectAPTrackingMode+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <selectAPTrackingMode+0x12f>
jmp    1248 <selectAPTrackingMode+0x128>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xeb2(%rip),%rdi
call   1040 <portWrite@plt>
cmp    $0x0,%eax
jge    11c1 <selectAPTrackingMode+0xa1>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <selectAPTrackingMode+0x12f>
jmp    1248 <selectAPTrackingMode+0x128>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xea2(%rip),%rdi
call   1040 <portWrite@plt>
cmp    $0x0,%eax
jge    11fc <selectAPTrackingMode+0xdc>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <selectAPTrackingMode+0x12f>
jmp    1248 <selectAPTrackingMode+0x128>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <portWrite@plt>
cmp    $0x0,%eax
jge    1237 <selectAPTrackingMode+0x117>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <selectAPTrackingMode+0x12f>
jmp    1248 <selectAPTrackingMode+0x128>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <selectAPTrackingMode+0x12f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectAPTrackingMode>:
push   %rbx
mov    $0xffffffff,%ebx
cmp    $0x3,%edi
ja     11c2 <selectAPTrackingMode+0xa2>
mov    %edi,%eax
lea    0xec8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xed4(%rip),%rdi
jmp    11b7 <selectAPTrackingMode+0x97>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xede(%rip),%rdi
jmp    11b7 <selectAPTrackingMode+0x97>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xeeb(%rip),%rdi
jmp    11b7 <selectAPTrackingMode+0x97>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xee0(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xef4(%rip),%rdi
call   1040 <portWrite@plt>
test   %eax,%eax
js     11c2 <selectAPTrackingMode+0xa2>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Setting tracking mode to lunar.\0A\00"
@.str.1 = [7 x i8] c"#:RT0#\00"
@.str.2 = [33 x i8] c"Setting tracking mode to solar.\0A\00"
@.str.3 = [7 x i8] c"#:RT1#\00"
@.str.4 = [36 x i8] c"Setting tracking mode to sidereal.\0A\00"
@.str.5 = [7 x i8] c"#:RT2#\00"
@.str.6 = [32 x i8] c"Setting tracking mode to zero.\0A\00"
@.str.7 = [7 x i8] c"#:RT9#\00"
define i32 @selectAPTrackingMode(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %33 [
i32 0, label %5
i32 1, label %12
i32 2, label %19
i32 3, label %26
]
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
store i32 -1, i32* %2
br label %35
11: ; preds = %5
br label %34
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %2
br label %35
18: ; preds = %12
br label %34
19: ; preds = %1
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 -1, i32* %2
br label %35
25: ; preds = %19
br label %34
26: ; preds = %1
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 -1, i32* %2
br label %35
32: ; preds = %26
br label %34
33: ; preds = %1
store i32 -1, i32* %2
br label %35
34: ; preds = %32, %25, %18, %11
store i32 0, i32* %2
br label %35
35: ; preds = %34, %33, %31, %24, %17, %10
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Setting tracking mode to lunar.\0A\00"
@.str.1 = [7 x i8] c"#:RT0#\00"
@.str.2 = [33 x i8] c"Setting tracking mode to solar.\0A\00"
@.str.3 = [7 x i8] c"#:RT1#\00"
@.str.4 = [36 x i8] c"Setting tracking mode to sidereal.\0A\00"
@.str.5 = [7 x i8] c"#:RT2#\00"
@.str.6 = [32 x i8] c"Setting tracking mode to zero.\0A\00"
@.str.7 = [7 x i8] c"#:RT9#\00"
define i32 @selectAPTrackingMode(i32 %0) {
switch i32 %0, label %23 [
i32 0, label %2
i32 1, label %7
i32 2, label %12
i32 3, label %17
]
2: ; preds = %1
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp slt i32 %5, 0
br i1 %6, label %23, label %22
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp slt i32 %10, 0
br i1 %11, label %23, label %22
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%16 = icmp slt i32 %15, 0
br i1 %16, label %23, label %22
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%20 = tail call i32 @portWrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%21 = icmp slt i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %17, %12, %7, %2
br label %23
23: ; preds = %1, %17, %12, %7, %2, %22
%24 = phi i32 [ 0, %22 ], [ -1, %2 ], [ -1, %7 ], [ -1, %12 ], [ -1, %17 ], [ -1, %1 ]
ret i32 %24
}