#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 scalar_t__ off_t;

/* Variables and functions */
int sais_main(unsigned char const *, scalar_t__ *, int /*<<< orphan*/, int, int,
              int, int /*<<< orphan*/);
int sporkel_sais(const unsigned char *T, off_t *SA, int n) {
  if ((T == NULL) || (SA == NULL) || (n < 0)) {
    return -1;
  }
  if (n <= 1) {
    if (n == 1) {
      SA[0] = 0;
    }
    return 0;
  }
  return sais_main(T, SA, 0, n, 256, sizeof(unsigned char), 0);
}


x86 assembly (clang, -O0):
<sporkel_sais>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1143 <sporkel_sais+0x33>
cmpq   $0x0,-0x18(%rbp)
je     1143 <sporkel_sais+0x33>
cmpl   $0x0,-0x1c(%rbp)
jge    114f <sporkel_sais+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a2 <sporkel_sais+0x92>
cmpl   $0x1,-0x1c(%rbp)
jg     117a <sporkel_sais+0x6a>
cmpl   $0x1,-0x1c(%rbp)
jne    116e <sporkel_sais+0x5e>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11a2 <sporkel_sais+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
movl   $0x0,(%rsp)
call   1030 <sais_main@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sporkel_sais>:
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1155 <sporkel_sais+0x45>
test   %rsi,%rsi
je     1155 <sporkel_sais+0x45>
mov    %edx,%ecx
test   %edx,%edx
js     1155 <sporkel_sais+0x45>
cmp    $0x1,%ecx
ja     113b <sporkel_sais+0x2b>
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1155 <sporkel_sais+0x45>
movq   $0x0,(%rsi)
pop    %rcx
ret
movl   $0x0,(%rsp)
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
call   1030 <sais_main@plt>
pop    %rcx
ret

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

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