#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 sais_main(unsigned char const *, int *, int *, int /*<<< orphan*/, int, int,
              int, int /*<<< orphan*/, int);
int sais(const unsigned char *T, int *SA, int *LCP, int n) {
  if ((T == NULL) || (SA == NULL) || (LCP == NULL) || (n < 0)) {
    return -1;
  }
  if (n <= 1) {
    if (n == 1) {
      SA[0] = 0;
      LCP[0] = 0;
    }
    return 0;
  }
  return sais_main(T, SA, LCP, 0, n, 256, sizeof(unsigned char), 0, 1);
}


x86 assembly (clang, -O0):
<sais>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1152 <sais+0x42>
cmpq   $0x0,-0x18(%rbp)
je     1152 <sais+0x42>
cmpq   $0x0,-0x20(%rbp)
je     1152 <sais+0x42>
cmpl   $0x0,-0x24(%rbp)
jge    115e <sais+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c9 <sais+0xb9>
cmpl   $0x1,-0x24(%rbp)
jg     1192 <sais+0x82>
cmpl   $0x1,-0x24(%rbp)
jne    1186 <sais+0x76>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c9 <sais+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%r8d
xor    %ecx,%ecx
mov    $0x100,%r9d
movl   $0x1,(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x1,0x10(%rsp)
call   1030 <sais_main@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sais>:
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1163 <sais+0x53>
test   %rsi,%rsi
je     1163 <sais+0x53>
test   %rdx,%rdx
je     1163 <sais+0x53>
mov    %ecx,%r8d
test   %ecx,%ecx
js     1163 <sais+0x53>
cmp    $0x1,%r8d
ja     1148 <sais+0x38>
xor    %eax,%eax
cmp    $0x1,%r8d
jne    1163 <sais+0x53>
movl   $0x0,(%rsi)
movl   $0x0,(%rdx)
pop    %rcx
ret
sub    $0x8,%rsp
xor    %ecx,%ecx
mov    $0x100,%r9d
push   $0x1
push   $0x0
push   $0x1
call   1030 <sais_main@plt>
add    $0x20,%rsp
pop    %rcx
ret

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

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