#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);
int /*<<< orphan*/ stderr;
int get_gridnav_projection(int wrf_projection) {
  int gridnav_projection;
  switch (wrf_projection) {
  case 0:
  case 6:
    gridnav_projection = 0;
    break;
  case 3:
    gridnav_projection = 1;
    break;
  case 1:
    gridnav_projection = 3;
    break;
  case 2:
    gridnav_projection = 5;
    break;
  default:
    fprintf(stderr, "Error, invalid projection: %d\n", wrf_projection);
    gridnav_projection = -1;
  }
  return gridnav_projection;
}


x86 assembly (clang, -O0):
<get_gridnav_projection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x6,%rax
ja     1170 <get_gridnav_projection+0x60>
mov    -0x10(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x8(%rbp)
jmp    118f <get_gridnav_projection+0x7f>
movl   $0x1,-0x8(%rbp)
jmp    118f <get_gridnav_projection+0x7f>
movl   $0x3,-0x8(%rbp)
jmp    118f <get_gridnav_projection+0x7f>
movl   $0x5,-0x8(%rbp)
jmp    118f <get_gridnav_projection+0x7f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_gridnav_projection>:
push   %rax
mov    %edi,%edx
cmp    $0x7,%edi
jae    1122 <get_gridnav_projection+0x12>
mov    $0x4f,%eax
bt     %edx,%eax
jb     113e <get_gridnav_projection+0x2e>
mov    0x2eb7(%rip),%rax
mov    (%rax),%edi
lea    0xece(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
movslq %edx,%rax
lea    0xed8(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Error, invalid projection: %d\0A\00"
define i32 @get_gridnav_projection(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %9 [
i32 0, label %5
i32 6, label %5
i32 3, label %6
i32 1, label %7
i32 2, label %8
]
5: ; preds = %1, %1
store i32 0, i32* %3
br label %13
6: ; preds = %1
store i32 1, i32* %3
br label %13
7: ; preds = %1
store i32 3, i32* %3
br label %13
8: ; preds = %1
store i32 5, i32* %3
br label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i32, i32* %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 -1, i32* %3
br label %13
13: ; preds = %9, %8, %7, %6, %5
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Error, invalid projection: %d\0A\00"
@switch.table.get_gridnav_projection = [7 x i32] [i32 0, i32 3, i32 5, i32 1, i32 0, i32 0, i32 0]
define i32 @get_gridnav_projection(i32 %0) {
%2 = icmp ult i32 %0, 7
br i1 %2, label %6, label %3
3: ; preds = %6, %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %15
6: ; preds = %1
%7 = trunc i32 %0 to i8
%8 = lshr i8 79, %7
%9 = and i8 %8, 1
%10 = icmp eq i8 %9, 0
br i1 %10, label %3, label %11
11: ; preds = %6
%12 = sext i32 %0 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.get_gridnav_projection, i64 0, i64 %12
%14 = load i32, i32* %13
br label %15
15: ; preds = %11, %3
%16 = phi i32 [ -1, %3 ], [ %14, %11 ]
ret i32 %16
}