#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*/ RotMx_t_Vector(int *, int const *, int const *, int);
int /*<<< orphan*/ SetSgError(char *);
int SetInvCBMxT(const int *CBMxT, const int *InvCBMxR, int *InvCBMxT) {
  int i;
  RotMx_t_Vector(InvCBMxT, InvCBMxR, CBMxT, 12 * 72);
  for (i = 0; i < 3; i++) {
    if (InvCBMxT[i] % 12) {
      SetSgError("Internal Error: SetInvCBMxT()");
      return -1;
    }
    if (InvCBMxT[i])
      InvCBMxT[i] = 72 - InvCBMxT[i] / 12;
  }
  return 0;
}


x86 assembly (clang, -O0):
<SetInvCBMxT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0x360,%ecx
call   1030 <RotMx_t_Vector@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11d9 <SetInvCBMxT+0xb9>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     118f <SetInvCBMxT+0x6f>
lea    0xe82(%rip),%rdi
call   1040 <SetSgError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e0 <SetInvCBMxT+0xc0>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     11c6 <SetInvCBMxT+0xa6>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    $0x48,%edx
sub    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11cb <SetInvCBMxT+0xab>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1151 <SetInvCBMxT+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetInvCBMxT>:
push   %rbx
mov    %rdx,%rbx
mov    %rdi,%rdx
mov    %rbx,%rdi
mov    $0x360,%ecx
call   1030 <RotMx_t_Vector@plt>
mov    (%rbx),%eax
imul   $0xaaaaaaab,%eax,%ecx
add    $0x2aaaaaa8,%ecx
ror    $0x2,%ecx
cmp    $0x15555555,%ecx
jae    11be <SetInvCBMxT+0x9e>
test   %eax,%eax
je     116c <SetInvCBMxT+0x4c>
cltq
imul   $0xffffffffd5555555,%rax,%rax
mov    %rax,%rcx
sar    $0x21,%rcx
shr    $0x3f,%rax
add    %ecx,%eax
add    $0x48,%eax
mov    %eax,(%rbx)
mov    0x4(%rbx),%eax
imul   $0xaaaaaaab,%eax,%ecx
add    $0x2aaaaaa8,%ecx
ror    $0x2,%ecx
cmp    $0x15555554,%ecx
ja     11be <SetInvCBMxT+0x9e>
test   %eax,%eax
je     11a6 <SetInvCBMxT+0x86>
cltq
imul   $0xffffffffd5555555,%rax,%rax
mov    %rax,%rcx
sar    $0x21,%rcx
shr    $0x3f,%rax
add    %ecx,%eax
add    $0x48,%eax
mov    %eax,0x4(%rbx)
mov    0x8(%rbx),%ecx
imul   $0xaaaaaaab,%ecx,%eax
add    $0x2aaaaaa8,%eax
ror    $0x2,%eax
cmp    $0x15555554,%eax
jbe    11d1 <SetInvCBMxT+0xb1>
lea    0xe3b(%rip),%rdi
call   1040 <SetSgError@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
test   %ecx,%ecx
je     11f4 <SetInvCBMxT+0xd4>
movslq %ecx,%rcx
imul   $0xffffffffd5555555,%rcx,%rcx
mov    %rcx,%rdx
sar    $0x21,%rdx
shr    $0x3f,%rcx
add    %edx,%ecx
add    $0x48,%ecx
mov    %ecx,0x8(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Internal Error: SetInvCBMxT()\00"
define i32 @SetInvCBMxT(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
%9 = load i32*, i32** %7
%10 = load i32*, i32** %6
%11 = load i32*, i32** %5
%12 = call i32 @RotMx_t_Vector(i32* %9, i32* %10, i32* %11, i32 864)
store i32 0, i32* %8
br label %13
13: ; preds = %46, %3
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %49
16: ; preds = %13
%17 = load i32*, i32** %7
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = srem i32 %21, 12
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 @SetSgError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %50
26: ; preds = %16
%27 = load i32*, i32** %7
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %45
33: ; preds = %26
%34 = load i32*, i32** %7
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = sdiv i32 %38, 12
%40 = sub nsw i32 72, %39
%41 = load i32*, i32** %7
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %33, %26
br label %46
46: ; preds = %45
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %13
49: ; preds = %13
store i32 0, i32* %4
br label %50
50: ; preds = %49, %24
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@.str = [30 x i8] c"Internal Error: SetInvCBMxT()\00"
define i32 @SetInvCBMxT(i32* %0, i32* %1, i32* %2) {
%4 = tail call i32 @RotMx_t_Vector(i32* %2, i32* %1, i32* %0, i32 864)
%5 = load i32, i32* %2
%6 = srem i32 %5, 12
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %25, %15, %3
%9 = tail call i32 @SetSgError(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %35
10: ; preds = %3
%11 = icmp eq i32 %5, 0
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = sdiv i32 %5, -12
%14 = add nsw i32 %13, 72
store i32 %14, i32* %2
br label %15
15: ; preds = %10, %12
%16 = getelementptr inbounds i32, i32* %2, i64 1
%17 = load i32, i32* %16
%18 = srem i32 %17, 12
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %8
20: ; preds = %15
%21 = icmp eq i32 %17, 0
br i1 %21, label %25, label %22
22: ; preds = %20
%23 = sdiv i32 %17, -12
%24 = add nsw i32 %23, 72
store i32 %24, i32* %16
br label %25
25: ; preds = %22, %20
%26 = getelementptr inbounds i32, i32* %2, i64 2
%27 = load i32, i32* %26
%28 = srem i32 %27, 12
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %8
30: ; preds = %25
%31 = icmp eq i32 %27, 0
br i1 %31, label %35, label %32
32: ; preds = %30
%33 = sdiv i32 %27, -12
%34 = add nsw i32 %33, 72
store i32 %34, i32* %26
br label %35
35: ; preds = %30, %32, %8
%36 = phi i32 [ -1, %8 ], [ 0, %32 ], [ 0, %30 ]
ret i32 %36
}