#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 mat_get_determinant_i3(int **);
int mat_get_trace_i3(int **);
int get_rotation_type(int rot[3][3]) {
  int rot_type;
  if (mat_get_determinant_i3(rot) == -1) {
    switch (mat_get_trace_i3(rot)) {
    case -2:
      rot_type = 0;
      break;
    case -1:
      rot_type = 1;
      break;
    case 0:
      rot_type = 2;
      break;
    case 1:
      rot_type = 3;
      break;
    case -3:
      rot_type = 4;
      break;
    default:
      rot_type = -1;
      break;
    }
  } else {
    switch (mat_get_trace_i3(rot)) {
    case 3:
      rot_type = 5;
      break;
    case -1:
      rot_type = 6;
      break;
    case 0:
      rot_type = 7;
      break;
    case 1:
      rot_type = 8;
      break;
    case 2:
      rot_type = 9;
      break;
    default:
      rot_type = -1;
      break;
    }
  }
  return rot_type;
}


x86 assembly (clang, -O0):
<get_rotation_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <mat_get_determinant_i3@plt>
cmp    $0xffffffff,%eax
jne    11b5 <get_rotation_type+0x95>
mov    -0x8(%rbp),%rdi
call   1030 <mat_get_trace_i3@plt>
add    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     11a9 <get_rotation_type+0x89>
mov    -0x18(%rbp),%rax
lea    0xeb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xc(%rbp)
jmp    11b0 <get_rotation_type+0x90>
movl   $0x1,-0xc(%rbp)
jmp    11b0 <get_rotation_type+0x90>
movl   $0x2,-0xc(%rbp)
jmp    11b0 <get_rotation_type+0x90>
movl   $0x3,-0xc(%rbp)
jmp    11b0 <get_rotation_type+0x90>
movl   $0x4,-0xc(%rbp)
jmp    11b0 <get_rotation_type+0x90>
movl   $0xffffffff,-0xc(%rbp)
jmp    122c <get_rotation_type+0x10c>
mov    -0x8(%rbp),%rdi
call   1030 <mat_get_trace_i3@plt>
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x4,%eax
ja     1220 <get_rotation_type+0x100>
mov    -0x20(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x5,-0xc(%rbp)
jmp    1227 <get_rotation_type+0x107>
movl   $0x6,-0xc(%rbp)
jmp    1227 <get_rotation_type+0x107>
movl   $0x7,-0xc(%rbp)
jmp    1227 <get_rotation_type+0x107>
movl   $0x8,-0xc(%rbp)
jmp    1227 <get_rotation_type+0x107>
movl   $0x9,-0xc(%rbp)
jmp    1227 <get_rotation_type+0x107>
movl   $0xffffffff,-0xc(%rbp)
jmp    122c <get_rotation_type+0x10c>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rotation_type>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <mat_get_determinant_i3@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <mat_get_trace_i3@plt>
cmp    $0xffffffff,%ebp
je     1152 <get_rotation_type+0x32>
add    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x5,%eax
jae    116e <get_rotation_type+0x4e>
cltq
lea    0xec4(%rip),%rcx
jmp    1168 <get_rotation_type+0x48>
add    $0x3,%eax
mov    $0xffffffff,%ecx
cmp    $0x5,%eax
jae    116e <get_rotation_type+0x4e>
cltq
lea    0xe98(%rip),%rcx
lea    (%rcx,%rax,4),%rax
mov    (%rax),%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_rotation_type([3 x i32]* %0) {
%2 = alloca [3 x i32]*
%3 = alloca i32
store [3 x i32]* %0, [3 x i32]** %2
%4 = load [3 x i32]*, [3 x i32]** %2
%5 = bitcast [3 x i32]* %4 to i32**
%6 = call i32 @mat_get_determinant_i3(i32** %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %19
8: ; preds = %1
%9 = load [3 x i32]*, [3 x i32]** %2
%10 = bitcast [3 x i32]* %9 to i32**
%11 = call i32 @mat_get_trace_i3(i32** %10)
switch i32 %11, label %17 [
i32 -2, label %12
i32 -1, label %13
i32 0, label %14
i32 1, label %15
i32 -3, label %16
]
12: ; preds = %8
store i32 0, i32* %3
br label %18
13: ; preds = %8
store i32 1, i32* %3
br label %18
14: ; preds = %8
store i32 2, i32* %3
br label %18
15: ; preds = %8
store i32 3, i32* %3
br label %18
16: ; preds = %8
store i32 4, i32* %3
br label %18
17: ; preds = %8
store i32 -1, i32* %3
br label %18
18: ; preds = %17, %16, %15, %14, %13, %12
br label %30
19: ; preds = %1
%20 = load [3 x i32]*, [3 x i32]** %2
%21 = bitcast [3 x i32]* %20 to i32**
%22 = call i32 @mat_get_trace_i3(i32** %21)
switch i32 %22, label %28 [
i32 3, label %23
i32 -1, label %24
i32 0, label %25
i32 1, label %26
i32 2, label %27
]
23: ; preds = %19
store i32 5, i32* %3
br label %29
24: ; preds = %19
store i32 6, i32* %3
br label %29
25: ; preds = %19
store i32 7, i32* %3
br label %29
26: ; preds = %19
store i32 8, i32* %3
br label %29
27: ; preds = %19
store i32 9, i32* %3
br label %29
28: ; preds = %19
store i32 -1, i32* %3
br label %29
29: ; preds = %28, %27, %26, %25, %24, %23
br label %30
30: ; preds = %29, %18
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@switch.table.get_rotation_type = [5 x i32] [i32 4, i32 0, i32 1, i32 2, i32 3]
@switch.table.get_rotation_type.1 = [5 x i32] [i32 6, i32 7, i32 8, i32 9, i32 5]
define i32 @get_rotation_type([3 x i32]* %0) {
%2 = bitcast [3 x i32]* %0 to i32**
%3 = tail call i32 @mat_get_determinant_i3(i32** %2)
%4 = icmp eq i32 %3, -1
%5 = tail call i32 @mat_get_trace_i3(i32** %2)
br i1 %4, label %6, label %9
6: ; preds = %1
%7 = add i32 %5, 3
%8 = icmp ult i32 %7, 5
br i1 %8, label %12, label %21
9: ; preds = %1
%10 = add i32 %5, 1
%11 = icmp ult i32 %10, 5
br i1 %11, label %15, label %21
12: ; preds = %6
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.get_rotation_type, i64 0, i64 %13
br label %18
15: ; preds = %9
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.get_rotation_type.1, i64 0, i64 %16
br label %18
18: ; preds = %12, %15
%19 = phi i32* [ %17, %15 ], [ %14, %12 ]
%20 = load i32, i32* %19
br label %21
21: ; preds = %18, %9, %6
%22 = phi i32 [ -1, %6 ], [ -1, %9 ], [ %20, %18 ]
ret i32 %22
}