#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*/ RotMxMultiply(int *, int const *, int const *);
int /*<<< orphan*/ SetSgError(char *);
int CBR_RMx(int *RRMx, const int *CBMxR, const int *RMx, const int *InvCBMxR) {
  int i, BufMx[9];
  RotMxMultiply(BufMx, RMx, InvCBMxR);
  RotMxMultiply(RRMx, CBMxR, BufMx);
  for (i = 0; i < 9; i++) {
    if (RRMx[i] % (12 * 12)) {
      SetSgError("Internal Error: CBR_SMx()");
      return -1;
    }
    RRMx[i] /= (12 * 12);
  }
  return 0;
}


x86 assembly (clang, -O0):
<CBR_RMx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <RotMxMultiply@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1030 <RotMxMultiply@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x9,-0x2c(%rbp)
jge    11cd <CBR_RMx+0xad>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x90,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     119f <CBR_RMx+0x7f>
lea    0xe72(%rip),%rdi
call   1040 <SetSgError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <CBR_RMx+0xb4>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    $0x90,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x58(%rbp),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1161 <CBR_RMx+0x41>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CBR_RMx>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1030 <RotMxMultiply@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <RotMxMultiply@plt>
movslq (%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c71,%ecx
jae    1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,(%r14)
movslq 0x4(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x4(%r14)
movslq 0x8(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x8(%r14)
movslq 0xc(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0xc(%r14)
movslq 0x10(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x10(%r14)
movslq 0x14(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x14(%r14)
movslq 0x18(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x18(%r14)
movslq 0x1c(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
ja     1317 <CBR_RMx+0x1f7>
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x1c(%r14)
movslq 0x20(%r14),%rax
imul   $0x38e38e39,%eax,%ecx
add    $0xe38e380,%ecx
ror    $0x4,%ecx
cmp    $0x1c71c70,%ecx
jbe    1332 <CBR_RMx+0x212>
lea    0xce2(%rip),%rdi
call   1040 <SetSgError@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
mov    %eax,0x20(%r14)
xor    %eax,%eax
jmp    1328 <CBR_RMx+0x208>

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

LLVM IR (-O2):
@.str = [26 x i8] c"Internal Error: CBR_SMx()\00"
define i32 @CBR_RMx(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca [9 x i32]
%6 = bitcast [9 x i32]* %5 to i8*
%7 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%8 = call i32 @RotMxMultiply(i32* %7, i32* %2, i32* %3)
%9 = call i32 @RotMxMultiply(i32* %0, i32* %1, i32* %7)
%10 = load i32, i32* %0
%11 = srem i32 %10, 144
%12 = sdiv i32 %10, 144
%13 = icmp eq i32 %11, 0
br i1 %13, label %16, label %14
14: ; preds = %58, %52, %46, %40, %34, %28, %22, %16, %4
%15 = call i32 @SetSgError(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %65
16: ; preds = %4
store i32 %12, i32* %0
%17 = getelementptr inbounds i32, i32* %0, i64 1
%18 = load i32, i32* %17
%19 = srem i32 %18, 144
%20 = sdiv i32 %18, 144
%21 = icmp eq i32 %19, 0
br i1 %21, label %22, label %14
22: ; preds = %16
store i32 %20, i32* %17
%23 = getelementptr inbounds i32, i32* %0, i64 2
%24 = load i32, i32* %23
%25 = srem i32 %24, 144
%26 = sdiv i32 %24, 144
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %14
28: ; preds = %22
store i32 %26, i32* %23
%29 = getelementptr inbounds i32, i32* %0, i64 3
%30 = load i32, i32* %29
%31 = srem i32 %30, 144
%32 = sdiv i32 %30, 144
%33 = icmp eq i32 %31, 0
br i1 %33, label %34, label %14
34: ; preds = %28
store i32 %32, i32* %29
%35 = getelementptr inbounds i32, i32* %0, i64 4
%36 = load i32, i32* %35
%37 = srem i32 %36, 144
%38 = sdiv i32 %36, 144
%39 = icmp eq i32 %37, 0
br i1 %39, label %40, label %14
40: ; preds = %34
store i32 %38, i32* %35
%41 = getelementptr inbounds i32, i32* %0, i64 5
%42 = load i32, i32* %41
%43 = srem i32 %42, 144
%44 = sdiv i32 %42, 144
%45 = icmp eq i32 %43, 0
br i1 %45, label %46, label %14
46: ; preds = %40
store i32 %44, i32* %41
%47 = getelementptr inbounds i32, i32* %0, i64 6
%48 = load i32, i32* %47
%49 = srem i32 %48, 144
%50 = sdiv i32 %48, 144
%51 = icmp eq i32 %49, 0
br i1 %51, label %52, label %14
52: ; preds = %46
store i32 %50, i32* %47
%53 = getelementptr inbounds i32, i32* %0, i64 7
%54 = load i32, i32* %53
%55 = srem i32 %54, 144
%56 = sdiv i32 %54, 144
%57 = icmp eq i32 %55, 0
br i1 %57, label %58, label %14
58: ; preds = %52
store i32 %56, i32* %53
%59 = getelementptr inbounds i32, i32* %0, i64 8
%60 = load i32, i32* %59
%61 = srem i32 %60, 144
%62 = sdiv i32 %60, 144
%63 = icmp eq i32 %61, 0
br i1 %63, label %64, label %14
64: ; preds = %58
store i32 %62, i32* %59
br label %65
65: ; preds = %64, %14
%66 = phi i32 [ -1, %14 ], [ 0, %64 ]
ret i32 %66
}