#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*/ disturb_rows(long **, int const, int const);
int /*<<< orphan*/ matmul(long **, long **, long **);
int /*<<< orphan*/ transpose(long **);
void finalize_disturb(long A[3][3], long Q[3][3], const int i, const int j) {
  long L[3][3];
  if (A[j][j] % A[i][i] != 0) {
    transpose(A);
    disturb_rows(L, i, j);
    matmul(A, L, A);
    matmul(Q, L, Q);
    transpose(A);
  }
}


x86 assembly (clang, -O0):
<finalize_disturb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
imul   $0x18,%rdx,%rdx
add    %rdx,%rcx
movslq -0x14(%rbp),%rsi
cqto
idivq  (%rcx,%rsi,8)
cmp    $0x0,%rdx
je     11c3 <finalize_disturb+0x93>
mov    -0x8(%rbp),%rdi
call   1030 <transpose@plt>
lea    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <disturb_rows@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1040 <matmul@plt>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <matmul@plt>
mov    -0x8(%rbp),%rdi
call   1030 <transpose@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finalize_disturb>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
movslq %ecx,%rax
lea    (%rax,%rax,2),%rcx
lea    (%rdi,%rcx,8),%rcx
mov    (%rcx,%rax,8),%rax
movslq %edx,%rcx
lea    (%rcx,%rcx,2),%rdx
lea    (%rdi,%rdx,8),%rdx
mov    (%rdx,%rcx,8),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     11c4 <finalize_disturb+0x94>
cqto
idiv   %rcx
test   %rdx,%rdx
je     11b7 <finalize_disturb+0x87>
mov    %rbx,%rdi
call   1030 <transpose@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1050 <disturb_rows@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <matmul@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <matmul@plt>
mov    %rbx,%rdi
call   1030 <transpose@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    117b <finalize_disturb+0x4b>
jmp    11b7 <finalize_disturb+0x87>

LLVM IR (-O0):
define void @finalize_disturb([3 x i64]* %0, [3 x i64]* %1, i32 %2, i32 %3) {
%5 = alloca [3 x i64]*
%6 = alloca [3 x i64]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x [3 x i64]]
store [3 x i64]* %0, [3 x i64]** %5
store [3 x i64]* %1, [3 x i64]** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load [3 x i64]*, [3 x i64]** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [3 x i64], [3 x i64]* %10, i64 %12
%14 = load i32, i32* %8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [3 x i64], [3 x i64]* %13, i64 0, i64 %15
%17 = load i64, i64* %16
%18 = load [3 x i64]*, [3 x i64]** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x i64], [3 x i64]* %18, i64 %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x i64], [3 x i64]* %21, i64 0, i64 %23
%25 = load i64, i64* %24
%26 = srem i64 %17, %25
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %54
28: ; preds = %4
%29 = load [3 x i64]*, [3 x i64]** %5
%30 = bitcast [3 x i64]* %29 to i64**
%31 = call i32 @transpose(i64** %30)
%32 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 0
%33 = bitcast [3 x i64]* %32 to i64**
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @disturb_rows(i64** %33, i32 %34, i32 %35)
%37 = load [3 x i64]*, [3 x i64]** %5
%38 = bitcast [3 x i64]* %37 to i64**
%39 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 0
%40 = bitcast [3 x i64]* %39 to i64**
%41 = load [3 x i64]*, [3 x i64]** %5
%42 = bitcast [3 x i64]* %41 to i64**
%43 = call i32 @matmul(i64** %38, i64** %40, i64** %42)
%44 = load [3 x i64]*, [3 x i64]** %6
%45 = bitcast [3 x i64]* %44 to i64**
%46 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %9, i64 0, i64 0
%47 = bitcast [3 x i64]* %46 to i64**
%48 = load [3 x i64]*, [3 x i64]** %6
%49 = bitcast [3 x i64]* %48 to i64**
%50 = call i32 @matmul(i64** %45, i64** %47, i64** %49)
%51 = load [3 x i64]*, [3 x i64]** %5
%52 = bitcast [3 x i64]* %51 to i64**
%53 = call i32 @transpose(i64** %52)
br label %54
54: ; preds = %28, %4
ret void
}

LLVM IR (-O2):
define void @finalize_disturb([3 x i64]* %0, [3 x i64]* %1, i32 %2, i32 %3) {
%5 = alloca [3 x [3 x i64]]
%6 = bitcast [3 x [3 x i64]]* %5 to i8*
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 %7, i64 %7
%9 = load i64, i64* %8
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 %10, i64 %10
%12 = load i64, i64* %11
%13 = srem i64 %9, %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %4
%16 = bitcast [3 x i64]* %0 to i64**
%17 = tail call i32 @transpose(i64** %16)
%18 = bitcast [3 x [3 x i64]]* %5 to i64**
%19 = call i32 @disturb_rows(i64** %18, i32 %2, i32 %3)
%20 = call i32 @matmul(i64** %16, i64** %18, i64** %16)
%21 = bitcast [3 x i64]* %1 to i64**
%22 = call i32 @matmul(i64** %21, i64** %18, i64** %21)
%23 = call i32 @transpose(i64** %16)
br label %24
24: ; preds = %15, %4
ret void
}