#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef scalar_t__ int32_t;

/* Variables and functions */
scalar_t__ libsais_main(int /*<<< orphan*/ const *, scalar_t__ *, scalar_t__,
                        int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/ *, scalar_t__, int);
int32_t libsais(const uint8_t *T, int32_t *SA, int32_t n, int32_t fs) {
  if ((T == NULL) || (SA == NULL) || (n < 0) || (fs < 0)) {
    return -1;
  } else if (n < 2) {
    if (n == 1) {
      SA[0] = 0;
    }
    return 0;
  }
  return libsais_main(T, SA, n, 0, 0, NULL, fs, 1);
}


x86 assembly (clang, -O0):
<libsais>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1154 <libsais+0x44>
cmpq   $0x0,-0x18(%rbp)
je     1154 <libsais+0x44>
cmpq   $0x0,-0x20(%rbp)
jl     1154 <libsais+0x44>
cmpq   $0x0,-0x28(%rbp)
jge    1161 <libsais+0x51>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11c4 <libsais+0xb4>
cmpq   $0x2,-0x20(%rbp)
jge    118f <libsais+0x7f>
cmpq   $0x1,-0x20(%rbp)
jne    1182 <libsais+0x72>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11c4 <libsais+0xb4>
jmp    1194 <libsais+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rax
xor    %r8d,%r8d
xor    %ecx,%ecx
mov    %ecx,%r9d
mov    %r8d,%ecx
mov    %rax,(%rsp)
movl   $0x1,0x8(%rsp)
call   1030 <libsais_main@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libsais>:
push   %rax
mov    $0xffffffffffffffff,%rax
test   %rdi,%rdi
je     1152 <libsais+0x42>
test   %rsi,%rsi
je     1152 <libsais+0x42>
mov    %rcx,%r10
or     %rdx,%rcx
js     1152 <libsais+0x42>
cmp    $0x1,%rdx
jg     113d <libsais+0x2d>
jne    1139 <libsais+0x29>
movq   $0x0,(%rsi)
xor    %eax,%eax
pop    %rcx
ret
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x1
push   %r10
call   1030 <libsais_main@plt>
add    $0x10,%rsp
pop    %rcx
ret

LLVM IR (-O0):
define i64 @libsais(i32* %0, i64* %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %6
store i64* %1, i64** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
%10 = load i32*, i32** %6
%11 = icmp eq i32* %10, null
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load i64*, i64** %7
%14 = icmp eq i64* %13, null
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load i64, i64* %8
%17 = icmp slt i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i64, i64* %9
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18, %15, %12, %4
store i64 -1, i64* %5
br label %39
22: ; preds = %18
%23 = load i64, i64* %8
%24 = icmp slt i64 %23, 2
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i64, i64* %8
%27 = icmp eq i64 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i64*, i64** %7
%30 = getelementptr inbounds i64, i64* %29, i64 0
store i64 0, i64* %30
br label %31
31: ; preds = %28, %25
store i64 0, i64* %5
br label %39
32: ; preds = %22
br label %33
33: ; preds = %32
%34 = load i32*, i32** %6
%35 = load i64*, i64** %7
%36 = load i64, i64* %8
%37 = load i64, i64* %9
%38 = call i64 @libsais_main(i32* %34, i64* %35, i64 %36, i32 0, i32 0, i32* null, i64 %37, i32 1)
store i64 %38, i64* %5
br label %39
39: ; preds = %33, %31, %21
%40 = load i64, i64* %5
ret i64 %40
}

LLVM IR (-O2):
define i64 @libsais(i32* %0, i64* %1, i64 %2, i64 %3) {
%5 = icmp eq i32* %0, null
%6 = icmp eq i64* %1, null
%7 = or i1 %5, %6
%8 = or i64 %3, %2
%9 = icmp slt i64 %8, 0
%10 = or i1 %7, %9
br i1 %10, label %18, label %11
11: ; preds = %4
%12 = icmp slt i64 %2, 2
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = icmp eq i64 %2, 1
br i1 %14, label %15, label %18
15: ; preds = %13
store i64 0, i64* %1
br label %18
16: ; preds = %11
%17 = tail call i64 @libsais_main(i32* %0, i64* %1, i64 %2, i32 0, i32 0, i32* null, i64 %3, i32 1)
br label %18
18: ; preds = %13, %15, %4, %16
%19 = phi i64 [ %17, %16 ], [ -1, %4 ], [ 0, %15 ], [ 0, %13 ]
ret i64 %19
}