#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 search_first_pivot(long **);
int /*<<< orphan*/ swap_rows(long **, int /*<<< orphan*/, int);
int /*<<< orphan*/ zero_first_column(long **, int, long **);
void first_column(long A[3][3], long P[3][3]) {
  int i;
  long L[3][3];
  i = search_first_pivot(A);
  if (i > 0) {
    swap_rows(L, 0, i);
    matmul(A, L, A);
    matmul(P, L, P);
  }
  if (i < 0) {
    goto err;
  }
  if (A[1][0] != 0) {
    zero_first_column(L, 1, A);
    matmul(A, L, A);
    matmul(P, L, P);
  }
  if (A[2][0] != 0) {
    zero_first_column(L, 2, A);
    matmul(A, L, A);
    matmul(P, L, P);
  }
err:;
}


x86 assembly (clang, -O0):
<first_column>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <search_first_pivot@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1196 <first_column+0x56>
lea    -0x60(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <swap_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>
cmpl   $0x0,-0x14(%rbp)
jge    11a5 <first_column+0x65>
jmp    1230 <first_column+0xf0>
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x18(%rax)
je     11e8 <first_column+0xa8>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1,%esi
call   1060 <zero_first_column@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),%rax
cmpq   $0x0,0x30(%rax)
je     122b <first_column+0xeb>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2,%esi
call   1060 <zero_first_column@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    1230 <first_column+0xf0>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_column>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <search_first_pivot@plt>
test   %eax,%eax
jle    1185 <first_column+0x45>
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    %eax,%edx
call   1030 <swap_rows@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    1187 <first_column+0x47>
js     11f3 <first_column+0xb3>
cmpq   $0x0,0x18(%rbx)
je     11bd <first_column+0x7d>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1060 <zero_first_column@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,0x30(%rbx)
je     11f3 <first_column+0xb3>
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1060 <zero_first_column@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>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @first_column([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
%7 = load [3 x i64]*, [3 x i64]** %3
%8 = bitcast [3 x i64]* %7 to i64**
%9 = call i32 @search_first_pivot(i64** %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %31
12: ; preds = %2
%13 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%14 = bitcast [3 x i64]* %13 to i64**
%15 = load i32, i32* %5
%16 = call i32 @swap_rows(i64** %14, i32 0, i32 %15)
%17 = load [3 x i64]*, [3 x i64]** %3
%18 = bitcast [3 x i64]* %17 to i64**
%19 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%20 = bitcast [3 x i64]* %19 to i64**
%21 = load [3 x i64]*, [3 x i64]** %3
%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]** %4
%25 = bitcast [3 x i64]* %24 to i64**
%26 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%27 = bitcast [3 x i64]* %26 to i64**
%28 = load [3 x i64]*, [3 x i64]** %4
%29 = bitcast [3 x i64]* %28 to i64**
%30 = call i32 @matmul(i64** %25, i64** %27, i64** %29)
br label %31
31: ; preds = %12, %2
%32 = load i32, i32* %5
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
br label %88
35: ; preds = %31
%36 = load [3 x i64]*, [3 x i64]** %3
%37 = getelementptr inbounds [3 x i64], [3 x i64]* %36, i64 1
%38 = getelementptr inbounds [3 x i64], [3 x i64]* %37, i64 0, i64 0
%39 = load i64, i64* %38
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %61
41: ; preds = %35
%42 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%43 = bitcast [3 x i64]* %42 to i64**
%44 = load [3 x i64]*, [3 x i64]** %3
%45 = bitcast [3 x i64]* %44 to i64**
%46 = call i32 @zero_first_column(i64** %43, i32 1, i64** %45)
%47 = load [3 x i64]*, [3 x i64]** %3
%48 = bitcast [3 x i64]* %47 to i64**
%49 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%50 = bitcast [3 x i64]* %49 to i64**
%51 = load [3 x i64]*, [3 x i64]** %3
%52 = bitcast [3 x i64]* %51 to i64**
%53 = call i32 @matmul(i64** %48, i64** %50, i64** %52)
%54 = load [3 x i64]*, [3 x i64]** %4
%55 = bitcast [3 x i64]* %54 to i64**
%56 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%57 = bitcast [3 x i64]* %56 to i64**
%58 = load [3 x i64]*, [3 x i64]** %4
%59 = bitcast [3 x i64]* %58 to i64**
%60 = call i32 @matmul(i64** %55, i64** %57, i64** %59)
br label %61
61: ; preds = %41, %35
%62 = load [3 x i64]*, [3 x i64]** %3
%63 = getelementptr inbounds [3 x i64], [3 x i64]* %62, i64 2
%64 = getelementptr inbounds [3 x i64], [3 x i64]* %63, i64 0, i64 0
%65 = load i64, i64* %64
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %87
67: ; preds = %61
%68 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%69 = bitcast [3 x i64]* %68 to i64**
%70 = load [3 x i64]*, [3 x i64]** %3
%71 = bitcast [3 x i64]* %70 to i64**
%72 = call i32 @zero_first_column(i64** %69, i32 2, i64** %71)
%73 = load [3 x i64]*, [3 x i64]** %3
%74 = bitcast [3 x i64]* %73 to i64**
%75 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%76 = bitcast [3 x i64]* %75 to i64**
%77 = load [3 x i64]*, [3 x i64]** %3
%78 = bitcast [3 x i64]* %77 to i64**
%79 = call i32 @matmul(i64** %74, i64** %76, i64** %78)
%80 = load [3 x i64]*, [3 x i64]** %4
%81 = bitcast [3 x i64]* %80 to i64**
%82 = getelementptr inbounds [3 x [3 x i64]], [3 x [3 x i64]]* %6, i64 0, i64 0
%83 = bitcast [3 x i64]* %82 to i64**
%84 = load [3 x i64]*, [3 x i64]** %4
%85 = bitcast [3 x i64]* %84 to i64**
%86 = call i32 @matmul(i64** %81, i64** %83, i64** %85)
br label %87
87: ; preds = %67, %61
br label %88
88: ; preds = %87, %34
ret void
}

LLVM IR (-O2):
define void @first_column([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 i64]* %0 to i64**
%6 = tail call i32 @search_first_pivot(i64** %5)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = bitcast [3 x [3 x i64]]* %3 to i64**
%10 = call i32 @swap_rows(i64** %9, i32 0, i32 %6)
%11 = call i32 @matmul(i64** %5, i64** %9, i64** %5)
%12 = bitcast [3 x i64]* %1 to i64**
%13 = call i32 @matmul(i64** %12, i64** %9, i64** %12)
br label %16
14: ; preds = %2
%15 = icmp slt i32 %6, 0
br i1 %15, label %36, label %16
16: ; preds = %8, %14
%17 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 1, i64 0
%18 = load i64, i64* %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %16
%21 = bitcast [3 x [3 x i64]]* %3 to i64**
%22 = call i32 @zero_first_column(i64** %21, i32 1, i64** %5)
%23 = call i32 @matmul(i64** %5, i64** %21, i64** %5)
%24 = bitcast [3 x i64]* %1 to i64**
%25 = call i32 @matmul(i64** %24, i64** %21, i64** %24)
br label %26
26: ; preds = %20, %16
%27 = getelementptr inbounds [3 x i64], [3 x i64]* %0, i64 2, i64 0
%28 = load i64, i64* %27
%29 = icmp eq i64 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %26
%31 = bitcast [3 x [3 x i64]]* %3 to i64**
%32 = call i32 @zero_first_column(i64** %31, i32 2, i64** %5)
%33 = call i32 @matmul(i64** %5, i64** %31, i64** %5)
%34 = bitcast [3 x i64]* %1 to i64**
%35 = call i32 @matmul(i64** %34, i64** %31, i64** %34)
br label %36
36: ; preds = %26, %30, %14
ret void
}