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


x86 assembly (clang, -O0):
<dbwt_sais>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1143 <dbwt_sais+0x33>
cmpq   $0x0,-0x18(%rbp)
je     1143 <dbwt_sais+0x33>
cmpl   $0x0,-0x1c(%rbp)
jge    114f <dbwt_sais+0x3f>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <dbwt_sais+0x8a>
cmpl   $0x1,-0x1c(%rbp)
jg     1179 <dbwt_sais+0x69>
cmpl   $0x1,-0x1c(%rbp)
jne    116d <dbwt_sais+0x5d>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    119a <dbwt_sais+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
call   1030 <dbwt_sais_main@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dbwt_sais>:
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1137 <dbwt_sais+0x27>
test   %rsi,%rsi
je     1137 <dbwt_sais+0x27>
mov    %edx,%ecx
test   %edx,%edx
js     1137 <dbwt_sais+0x27>
cmp    $0x1,%ecx
ja     1138 <dbwt_sais+0x28>
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1137 <dbwt_sais+0x27>
movl   $0x0,(%rsi)
ret
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
jmp    1030 <dbwt_sais_main@plt>

LLVM IR (-O0):
define i32 @dbwt_sais(i8* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %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 i32*, i32** %6
%12 = icmp eq i32* %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 i32*, i32** %6
%25 = getelementptr inbounds i32, i32* %24, i64 0
store i32 0, i32* %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 i32*, i32** %6
%30 = load i32, i32* %7
%31 = call i32 @dbwt_sais_main(i8* %28, i32* %29, i32 0, i32 %30, i32 256, i32 1)
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 @dbwt_sais(i8* %0, i32* %1, i32 %2) {
%4 = icmp eq i8* %0, null
%5 = icmp eq i32* %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 i32 0, i32* %1
br label %16
14: ; preds = %9
%15 = tail call i32 @dbwt_sais_main(i8* %0, i32* %1, i32 0, i32 %2, i32 256, i32 1)
br label %16
16: ; preds = %11, %13, %3, %14
%17 = phi i32 [ %15, %14 ], [ -1, %3 ], [ 0, %13 ], [ 0, %11 ]
ret i32 %17
}