#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*/ finalize_disturb(long **, long **, int, int);
int /*<<< orphan*/ finalize_sort(long **, long **, long **);
int /*<<< orphan*/ first(long **, long **, long **);
int /*<<< orphan*/ flip_PQ(long **, long **);
int /*<<< orphan*/ make_diagA_positive(long **, long **);
int /*<<< orphan*/ second(long **, long **, long **);
void finalize(long A[3][3], long P[3][3], long Q[3][3]) {
  make_diagA_positive(A, P);
  finalize_sort(A, P, Q);
  finalize_disturb(A, Q, 0, 1);
  first(A, P, Q);
  finalize_sort(A, P, Q);
  finalize_disturb(A, Q, 1, 2);
  second(A, P, Q);
  flip_PQ(P, Q);
}


x86 assembly (clang, -O0):
<finalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <make_diagA_positive@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <finalize_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <finalize_disturb@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <first@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <finalize_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1050 <finalize_disturb@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <second@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <flip_PQ@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finalize>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <make_diagA_positive@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <finalize_sort@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
mov    $0x1,%ecx
call   1050 <finalize_disturb@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <first@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <finalize_sort@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1050 <finalize_disturb@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <second@plt>
mov    %r14,%rdi
mov    %r15,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <flip_PQ@plt>

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

LLVM IR (-O2):
define void @finalize([3 x i64]* %0, [3 x i64]* %1, [3 x i64]* %2) {
%4 = bitcast [3 x i64]* %0 to i64**
%5 = bitcast [3 x i64]* %1 to i64**
%6 = tail call i32 @make_diagA_positive(i64** %4, i64** %5)
%7 = bitcast [3 x i64]* %2 to i64**
%8 = tail call i32 @finalize_sort(i64** %4, i64** %5, i64** %7)
%9 = tail call i32 @finalize_disturb(i64** %4, i64** %7, i32 0, i32 1)
%10 = tail call i32 @first(i64** %4, i64** %5, i64** %7)
%11 = tail call i32 @finalize_sort(i64** %4, i64** %5, i64** %7)
%12 = tail call i32 @finalize_disturb(i64** %4, i64** %7, i32 1, i32 2)
%13 = tail call i32 @second(i64** %4, i64** %5, i64** %7)
%14 = tail call i32 @flip_PQ(i64** %5, i64** %7)
ret void
}