#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*/ flip_sign_row(long **, int);
int /*<<< orphan*/ matmul(long **, long **, long **);
void make_diagA_positive(long A[3][3], long P[3][3]) {
  int i;
  long L[3][3];
  for (i = 0; i < 3; i++) {
    if (A[i][i] < 0) {
      flip_sign_row(L, i);
      matmul(A, L, A);
      matmul(P, L, P);
    }
  }
}


x86 assembly (clang, -O0):
<make_diagA_positive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11a0 <make_diagA_positive+0x80>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jge    118d <make_diagA_positive+0x6d>
lea    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <flip_sign_row@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>
jmp    1192 <make_diagA_positive+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <make_diagA_positive+0x17>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_diagA_positive>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
js     114d <make_diagA_positive+0x2d>
cmpq   $0x0,0x20(%rbx)
js     117d <make_diagA_positive+0x5d>
cmpq   $0x0,0x40(%rbx)
js     11b0 <make_diagA_positive+0x90>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <flip_sign_row@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <matmul@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <matmul@plt>
cmpq   $0x0,0x20(%rbx)
jns    113c <make_diagA_positive+0x1c>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1030 <flip_sign_row@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <matmul@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <matmul@plt>
cmpq   $0x0,0x40(%rbx)
jns    1143 <make_diagA_positive+0x23>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x2,%esi
call   1030 <flip_sign_row@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <matmul@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <matmul@plt>
jmp    1143 <make_diagA_positive+0x23>

LLVM IR (-O0):
define void @make_diagA_positive([3 x i64]* %0, [3 x i64]* %1) {
%3 = alloca [3 x i64]*
%4 = alloca [3 x i64]*
%5 = alloca i32
%6 = alloca [3 x [3 x i64]]
store [3 x i64]* %0, [3 x i64]** %3
store [3 x i64]* %1, [3 x i64]** %4
store i32 0, i32* %5
br label %7
7: ; preds = %40, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %43
10: ; preds = %7
%11 = load [3 x i64]*, [3 x i64]** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [3 x i64], [3 x i64]* %11, i64 %13
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x i64], [3 x i64]* %14, i64 0, i64 %16
%18 = load i64, i64* %17
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %10
%21 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%22 = bitcast [3 x i64]* %21 to i64**
%23 = load i32, i32* %5
%24 = call i32 @flip_sign_row(i64** %22, i32 %23)
%25 = load [3 x i64]*, [3 x i64]** %3
%26 = bitcast [3 x i64]* %25 to i64**
%27 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%28 = bitcast [3 x i64]* %27 to i64**
%29 = load [3 x i64]*, [3 x i64]** %3
%30 = bitcast [3 x i64]* %29 to i64**
%31 = call i32 @matmul(i64** %26, i64** %28, i64** %30)
%32 = load [3 x i64]*, [3 x i64]** %4
%33 = bitcast [3 x i64]* %32 to i64**
%34 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%35 = bitcast [3 x i64]* %34 to i64**
%36 = load [3 x i64]*, [3 x i64]** %4
%37 = bitcast [3 x i64]* %36 to i64**
%38 = call i32 @matmul(i64** %33, i64** %35, i64** %37)
br label %39
39: ; preds = %20, %10
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %7
43: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @make_diagA_positive([3 x i64]* %0, [3 x i64]* %1) {
%3 = alloca [3 x [3 x i64]]
%4 = bitcast [3 x [3 x i64]]* %3 to i8*
%5 = bitcast [3 x [3 x i64]]* %3 to i64**
%6 = bitcast [3 x i64]* %0 to i64**
%7 = bitcast [3 x i64]* %1 to i64**
%8 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 0, i64 0
%9 = load i64, i64* %8
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = call i32 @flip_sign_row(i64** %5, i32 0)
%13 = call i32 @matmul(i64** %6, i64** %5, i64** %6)
%14 = call i32 @matmul(i64** %7, i64** %5, i64** %7)
br label %15
15: ; preds = %2, %11
%16 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 1, i64 1
%17 = load i64, i64* %16
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = call i32 @flip_sign_row(i64** %5, i32 1)
%21 = call i32 @matmul(i64** %6, i64** %5, i64** %6)
%22 = call i32 @matmul(i64** %7, i64** %5, i64** %7)
br label %23
23: ; preds = %19, %15
%24 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 2, i64 2
%25 = load i64, i64* %24
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = call i32 @flip_sign_row(i64** %5, i32 2)
%29 = call i32 @matmul(i64** %6, i64** %5, i64** %6)
%30 = call i32 @matmul(i64** %7, i64** %5, i64** %7)
br label %31
31: ; preds = %27, %23
ret void
}