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


x86 assembly (clang, -O0):
<dbwt_sais_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1150 <dbwt_sais_int+0x40>
cmpq   $0x0,-0x18(%rbp)
je     1150 <dbwt_sais_int+0x40>
cmpl   $0x0,-0x1c(%rbp)
jl     1150 <dbwt_sais_int+0x40>
cmpl   $0x0,-0x20(%rbp)
jg     115c <dbwt_sais_int+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <dbwt_sais_int+0x95>
cmpl   $0x1,-0x1c(%rbp)
jg     1186 <dbwt_sais_int+0x76>
cmpl   $0x1,-0x1c(%rbp)
jne    117a <dbwt_sais_int+0x6a>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11a5 <dbwt_sais_int+0x95>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
xor    %edx,%edx
mov    $0x4,%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_int>:
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     113f <dbwt_sais_int+0x2f>
test   %rsi,%rsi
je     113f <dbwt_sais_int+0x2f>
mov    %ecx,%r8d
mov    %edx,%ecx
test   %edx,%edx
js     113f <dbwt_sais_int+0x2f>
test   %r8d,%r8d
jle    113f <dbwt_sais_int+0x2f>
cmp    $0x1,%ecx
ja     1140 <dbwt_sais_int+0x30>
xor    %eax,%eax
cmp    $0x1,%ecx
jne    113f <dbwt_sais_int+0x2f>
movl   $0x0,(%rsi)
ret
xor    %edx,%edx
mov    $0x4,%r9d
jmp    1030 <dbwt_sais_main@plt>

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

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