#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*/ matmul(long **, long **, long **);
int /*<<< orphan*/ swap_rows(long **, int const, int const);
int /*<<< orphan*/ transpose(long **);
void swap_diag_elems(long A[3][3], long P[3][3], long Q[3][3], const int i,
                     const int j) {
  long L[3][3];
  swap_rows(L, i, j);
  matmul(A, L, A);
  matmul(P, L, P);
  transpose(A);
  swap_rows(L, i, j);
  matmul(A, L, A);
  matmul(Q, L, Q);
  transpose(A);
}


x86 assembly (clang, -O0):
<swap_diag_elems>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <swap_rows@plt>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1050 <matmul@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <matmul@plt>
mov    -0x8(%rbp),%rdi
call   1030 <transpose@plt>
lea    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <swap_rows@plt>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1050 <matmul@plt>
mov    -0x18(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <matmul@plt>
mov    -0x8(%rbp),%rdi
call   1030 <transpose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_diag_elems>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    %ecx,%esi
mov    %r8d,%edx
call   1040 <swap_rows@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <matmul@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1050 <matmul@plt>
mov    %rbx,%rdi
call   1030 <transpose@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
call   1040 <swap_rows@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <matmul@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <matmul@plt>
mov    %rbx,%rdi
call   1030 <transpose@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @swap_diag_elems([3 x i64]* %0, [3 x i64]* %1, [3 x i64]* %2, i32 %3, i32 %4) {
%6 = alloca [3 x i64]*
%7 = alloca [3 x i64]*
%8 = alloca [3 x i64]*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x [3 x i64]]
store [3 x i64]* %0, [3 x i64]** %6
store [3 x i64]* %1, [3 x i64]** %7
store [3 x i64]* %2, [3 x i64]** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%13 = bitcast [3 x i64]* %12 to i64**
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = call i32 @swap_rows(i64** %13, i32 %14, i32 %15)
%17 = load [3 x i64]*, [3 x i64]** %6
%18 = bitcast [3 x i64]* %17 to i64**
%19 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%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 @matmul(i64** %18, i64** %20, i64** %22)
%24 = load [3 x i64]*, [3 x i64]** %7
%25 = bitcast [3 x i64]* %24 to i64**
%26 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%27 = bitcast [3 x i64]* %26 to i64**
%28 = load [3 x i64]*, [3 x i64]** %7
%29 = bitcast [3 x i64]* %28 to i64**
%30 = call i32 @matmul(i64** %25, i64** %27, i64** %29)
%31 = load [3 x i64]*, [3 x i64]** %6
%32 = bitcast [3 x i64]* %31 to i64**
%33 = call i32 @transpose(i64** %32)
%34 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%35 = bitcast [3 x i64]* %34 to i64**
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = call i32 @swap_rows(i64** %35, i32 %36, i32 %37)
%39 = load [3 x i64]*, [3 x i64]** %6
%40 = bitcast [3 x i64]* %39 to i64**
%41 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%42 = bitcast [3 x i64]* %41 to i64**
%43 = load [3 x i64]*, [3 x i64]** %6
%44 = bitcast [3 x i64]* %43 to i64**
%45 = call i32 @matmul(i64** %40, i64** %42, i64** %44)
%46 = load [3 x i64]*, [3 x i64]** %8
%47 = bitcast [3 x i64]* %46 to i64**
%48 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %11, i64 0, i64 0
%49 = bitcast [3 x i64]* %48 to i64**
%50 = load [3 x i64]*, [3 x i64]** %8
%51 = bitcast [3 x i64]* %50 to i64**
%52 = call i32 @matmul(i64** %47, i64** %49, i64** %51)
%53 = load [3 x i64]*, [3 x i64]** %6
%54 = bitcast [3 x i64]* %53 to i64**
%55 = call i32 @transpose(i64** %54)
ret void
}

LLVM IR (-O2):
define void @swap_diag_elems([3 x i64]* %0, [3 x i64]* %1, [3 x i64]* %2, i32 %3, i32 %4) {
%6 = alloca [3 x [3 x i64]]
%7 = bitcast [3 x [3 x i64]]* %6 to i8*
%8 = bitcast [3 x [3 x i64]]* %6 to i64**
%9 = call i32 @swap_rows(i64** %8, i32 %3, i32 %4)
%10 = bitcast [3 x i64]* %0 to i64**
%11 = call i32 @matmul(i64** %10, i64** %8, i64** %10)
%12 = bitcast [3 x i64]* %1 to i64**
%13 = call i32 @matmul(i64** %12, i64** %8, i64** %12)
%14 = call i32 @transpose(i64** %10)
%15 = call i32 @swap_rows(i64** %8, i32 %3, i32 %4)
%16 = call i32 @matmul(i64** %10, i64** %8, i64** %10)
%17 = bitcast [3 x i64]* %2 to i64**
%18 = call i32 @matmul(i64** %17, i64** %8, i64** %17)
%19 = call i32 @transpose(i64** %10)
ret void
}