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


x86 assembly (clang, -O0):
<sais64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     113a <sais64+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    1146 <sais64+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    119c <sais64+0x8c>
cmpq   $0x1,-0x20(%rbp)
ja     1173 <sais64+0x63>
cmpq   $0x1,-0x20(%rbp)
jne    1167 <sais64+0x57>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    119c <sais64+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
movl   $0x0,(%rsp)
call   1030 <sais64_main@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sais64>:
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1138 <sais64+0x28>
test   %rsi,%rsi
je     1138 <sais64+0x28>
mov    %rdx,%rcx
cmp    $0x1,%rdx
ja     113a <sais64+0x2a>
xor    %eax,%eax
cmp    $0x1,%rcx
jne    1138 <sais64+0x28>
movq   $0x0,(%rsi)
pop    %rcx
ret
movl   $0x0,(%rsp)
xor    %edx,%edx
mov    $0x100,%r8d
mov    $0x1,%r9d
call   1030 <sais64_main@plt>
pop    %rcx
ret

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

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