#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*/ second_finalize(long **, long **);
int /*<<< orphan*/ second_one_loop(long **, long **, long **);
int second(long A[3][3], long P[3][3], long Q[3][3]) {
  long L[3][3];
  second_one_loop(A, P, Q);
  if (A[2][1] == 0) {
    return 1;
  }
  if (A[2][1] % A[1][1] == 0) {
    second_finalize(L, A);
    matmul(A, L, A);
    matmul(P, L, P);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<second>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <second_one_loop@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x38(%rax)
jne    1170 <second+0x40>
movl   $0x1,-0x4(%rbp)
jmp    11ce <second+0x9e>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rax
mov    -0x10(%rbp),%rcx
cqto
idivq  0x20(%rcx)
cmp    $0x0,%rdx
jne    11c7 <second+0x97>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <second_finalize@plt>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1050 <matmul@plt>
mov    -0x18(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <matmul@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ce <second+0x9e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<second>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <second_one_loop@plt>
mov    0x38(%rbx),%rax
mov    $0x1,%ecx
test   %rax,%rax
je     11a3 <second+0x73>
mov    0x20(%rbx),%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
je     1169 <second+0x39>
cqto
idiv   %rcx
jmp    116d <second+0x3d>
xor    %edx,%edx
div    %ecx
xor    %ecx,%ecx
test   %rdx,%rdx
jne    11a3 <second+0x73>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <second_finalize@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    $0x1,%ecx
mov    %ecx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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