#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(long **, long **, long **);
scalar_t__ first(long **, long **, long **);
int /*<<< orphan*/ initialize_PQ(long **, long **);
scalar_t__ second(long **, long **, long **);
int /*<<< orphan*/ transpose(long **);
int snf3x3(long A[3][3], long P[3][3], long Q[3][3]) {
  int i;
  initialize_PQ(P, Q);
  for (i = 0; i < 100; i++) {
    if (first(A, P, Q)) {
      if (second(A, P, Q)) {
        finalize(A, P, Q);
        transpose(Q);
        goto succeeded;
      }
    }
  }
  return 0;
succeeded:
  return 1;
}


x86 assembly (clang, -O0):
<snf3x3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <initialize_PQ@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x64,-0x24(%rbp)
jge    11ef <snf3x3+0x9f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <first@plt>
cmp    $0x0,%rax
je     11dc <snf3x3+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <second@plt>
cmp    $0x0,%rax
je     11d7 <snf3x3+0x87>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <finalize@plt>
mov    -0x20(%rbp),%rdi
call   1040 <transpose@plt>
jmp    11fb <snf3x3+0xab>
jmp    11dc <snf3x3+0x8c>
jmp    11e1 <snf3x3+0x91>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1178 <snf3x3+0x28>
movl   $0x0,-0x4(%rbp)
jmp    1202 <snf3x3+0xb2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snf3x3>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1060 <initialize_PQ@plt>
mov    $0x64,%ebp
jmp    1185 <snf3x3+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     11c8 <snf3x3+0x78>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1070 <first@plt>
test   %rax,%rax
je     1180 <snf3x3+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <second@plt>
test   %rax,%rax
je     1180 <snf3x3+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <finalize@plt>
mov    %r14,%rdi
call   1040 <transpose@plt>
mov    $0x1,%eax
jmp    11ca <snf3x3+0x7a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @snf3x3([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 i32
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]** %6
%10 = bitcast [3 x i64]* %9 to i64**
%11 = load [3 x i64]*, [3 x i64]** %7
%12 = bitcast [3 x i64]* %11 to i64**
%13 = call i32 @initialize_PQ(i64** %10, i64** %12)
store i32 0, i32* %8
br label %14
14: ; preds = %48, %3
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 100
br i1 %16, label %17, label %51
17: ; preds = %14
%18 = load [3 x i64]*, [3 x i64]** %5
%19 = bitcast [3 x i64]* %18 to i64**
%20 = load [3 x i64]*, [3 x i64]** %6
%21 = bitcast [3 x i64]* %20 to i64**
%22 = load [3 x i64]*, [3 x i64]** %7
%23 = bitcast [3 x i64]* %22 to i64**
%24 = call i64 @first(i64** %19, i64** %21, i64** %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %47
26: ; preds = %17
%27 = load [3 x i64]*, [3 x i64]** %5
%28 = bitcast [3 x i64]* %27 to i64**
%29 = load [3 x i64]*, [3 x i64]** %6
%30 = bitcast [3 x i64]* %29 to i64**
%31 = load [3 x i64]*, [3 x i64]** %7
%32 = bitcast [3 x i64]* %31 to i64**
%33 = call i64 @second(i64** %28, i64** %30, i64** %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %46
35: ; preds = %26
%36 = load [3 x i64]*, [3 x i64]** %5
%37 = bitcast [3 x i64]* %36 to i64**
%38 = load [3 x i64]*, [3 x i64]** %6
%39 = bitcast [3 x i64]* %38 to i64**
%40 = load [3 x i64]*, [3 x i64]** %7
%41 = bitcast [3 x i64]* %40 to i64**
%42 = call i32 @finalize(i64** %37, i64** %39, i64** %41)
%43 = load [3 x i64]*, [3 x i64]** %7
%44 = bitcast [3 x i64]* %43 to i64**
%45 = call i32 @transpose(i64** %44)
br label %52
46: ; preds = %26
br label %47
47: ; preds = %46, %17
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %14
51: ; preds = %14
store i32 0, i32* %4
br label %53
52: ; preds = %35
store i32 1, i32* %4
br label %53
53: ; preds = %52, %51
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @snf3x3([3 x i64]* %0, [3 x i64]* %1, [3 x i64]* %2) {
%4 = bitcast [3 x i64]* %1 to i64**
%5 = bitcast [3 x i64]* %2 to i64**
%6 = tail call i32 @initialize_PQ(i64** %4, i64** %5)
%7 = bitcast [3 x i64]* %0 to i64**
br label %8
8: ; preds = %3, %18
%9 = phi i32 [ 0, %3 ], [ %19, %18 ]
%10 = tail call i64 @first(i64** %7, i64** %4, i64** %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %8
%13 = tail call i64 @second(i64** %7, i64** %4, i64** %5)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @finalize(i64** %7, i64** %4, i64** %5)
%17 = tail call i32 @transpose(i64** %5)
br label %21
18: ; preds = %8, %12
%19 = add nuw nsw i32 %9, 1
%20 = icmp eq i32 %19, 100
br i1 %20, label %21, label %8
21: ; preds = %18, %15
%22 = phi i32 [ 1, %15 ], [ 0, %18 ]
ret i32 %22
}