#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 /*<<< orphan*/, int, int, int,
              int /*<<< orphan*/);
int 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 sais_main((const unsigned char *)T, SA, 0, n, k, sizeof(int), 0);
}


x86 assembly (clang, -O0):
<sais_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1150 <sais_int+0x40>
cmpq   $0x0,-0x18(%rbp)
je     1150 <sais_int+0x40>
cmpl   $0x0,-0x1c(%rbp)
jl     1150 <sais_int+0x40>
cmpl   $0x0,-0x20(%rbp)
jg     115c <sais_int+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ac <sais_int+0x9c>
cmpl   $0x1,-0x1c(%rbp)
jg     1186 <sais_int+0x76>
cmpl   $0x1,-0x1c(%rbp)
jne    117a <sais_int+0x6a>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11ac <sais_int+0x9c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
xor    %edx,%edx
mov    $0x4,%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):
<sais_int>:
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1156 <sais_int+0x46>
test   %rsi,%rsi
je     1156 <sais_int+0x46>
mov    %ecx,%r8d
mov    %edx,%ecx
test   %edx,%edx
js     1156 <sais_int+0x46>
test   %r8d,%r8d
jle    1156 <sais_int+0x46>
cmp    $0x1,%ecx
ja     1142 <sais_int+0x32>
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1156 <sais_int+0x46>
movl   $0x0,(%rsi)
pop    %rcx
ret
movl   $0x0,(%rsp)
xor    %edx,%edx
mov    $0x4,%r9d
call   1030 <sais_main@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @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 @sais_main(i8* %34, i32* %35, i32 0, i32 %36, i32 %37, i32 4, i32 0)
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 @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 @sais_main(i8* %18, i32* %1, i32 0, i32 %2, i32 %3, i32 4, i32 0)
br label %20
20: ; preds = %14, %16, %4, %17
%21 = phi i32 [ %19, %17 ], [ -1, %4 ], [ 0, %16 ], [ 0, %14 ]
ret i32 %21
}