#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 min(int, int);
int strlen(char *);
scalar_t__ suffix(char *, int, int, char);
void compute_transition_function(char *pattern, int *array, int numchars) {
  int m = strlen(pattern);
  int q;
  for (q = 0; q <= m; q++) {
    int chars;
    for (chars = 0; chars < numchars; chars++) {
      int k = min(m, q + 1);
      while (k) {
        char ch = 'a' + chars;
        if (suffix(pattern, k, q, ch))
          break;
        k--;
      }
      array[q * numchars + chars] = k;
    }
  }
}


x86 assembly (clang, -O0):
<compute_transition_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1201 <compute_transition_function+0xd1>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ee <compute_transition_function+0xbe>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
call   1040 <min@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11c9 <compute_transition_function+0x99>
mov    -0x20(%rbp),%eax
add    $0x61,%eax
mov    %al,-0x25(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsbl -0x25(%rbp),%ecx
call   1050 <suffix@plt>
cmp    $0x0,%rax
je     11bb <compute_transition_function+0x8b>
jmp    11c9 <compute_transition_function+0x99>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1186 <compute_transition_function+0x56>
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1169 <compute_transition_function+0x39>
jmp    11f3 <compute_transition_function+0xc3>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <compute_transition_function+0x26>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_transition_function>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     1221 <compute_transition_function+0xf1>
movslq (%rsp),%rcx
mov    0x4(%rsp),%eax
add    $0x1,%eax
mov    %rax,0x18(%rsp)
mov    %rcx,0x10(%rsp)
mov    %ecx,%eax
mov    %rax,0x20(%rsp)
xor    %ebx,%ebx
jmp    1193 <compute_transition_function+0x63>
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rax
mov    %rax,%rbx
cmp    0x18(%rsp),%rax
je     1221 <compute_transition_function+0xf1>
lea    0x1(%rbx),%rax
mov    %rax,0x8(%rsp)
cmpl   $0x0,(%rsp)
jle    1180 <compute_transition_function+0x50>
mov    %rbx,%rax
imul   0x10(%rsp),%rax
mov    %rax,0x30(%rsp)
xor    %r13d,%r13d
jmp    11dc <compute_transition_function+0xac>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x30(%rsp),%rax
add    %r13,%rax
mov    0x28(%rsp),%rcx
mov    %r15d,(%rcx,%rax,4)
add    $0x1,%r13
cmp    0x20(%rsp),%r13
je     1180 <compute_transition_function+0x50>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%rsi
call   1040 <min@plt>
mov    %eax,%r14d
lea    0x61(%r13),%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%r15d
sub    $0x1,%r14d
jb     11c0 <compute_transition_function+0x90>
movsbl %r12b,%ecx
mov    %rbp,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
call   1050 <suffix@plt>
test   %rax,%rax
je     1200 <compute_transition_function+0xd0>
jmp    11c0 <compute_transition_function+0x90>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @compute_transition_function(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %7
store i32 0, i32* %8
br label %14
14: ; preds = %59, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %62
18: ; preds = %14
store i32 0, i32* %9
br label %19
19: ; preds = %55, %18
%20 = load i32, i32* %9
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %58
23: ; preds = %19
%24 = load i32, i32* %7
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
%27 = call i32 @min(i32 %24, i32 %26)
store i32 %27, i32* %10
br label %28
28: ; preds = %42, %23
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i32, i32* %9
%33 = add nsw i32 97, %32
%34 = trunc i32 %33 to i8
store i8 %34, i8* %11
%35 = load i8*, i8** %4
%36 = load i32, i32* %10
%37 = load i32, i32* %8
%38 = load i8, i8* %11
%39 = call i64 @suffix(i8* %35, i32 %36, i32 %37, i8 signext %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %31
br label %45
42: ; preds = %31
%43 = load i32, i32* %10
%44 = add nsw i32 %43, -1
store i32 %44, i32* %10
br label %28
45: ; preds = %41, %28
%46 = load i32, i32* %10
%47 = load i32*, i32** %5
%48 = load i32, i32* %8
%49 = load i32, i32* %6
%50 = mul nsw i32 %48, %49
%51 = load i32, i32* %9
%52 = add nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %47, i64 %53
store i32 %46, i32* %54
br label %55
55: ; preds = %45
%56 = load i32, i32* %9
%57 = add nsw i32 %56, 1
store i32 %57, i32* %9
br label %19
58: ; preds = %19
br label %59
59: ; preds = %58
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %14
62: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @compute_transition_function(i8* %0, i32* nocapture writeonly %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %38, label %6
6: ; preds = %3
%7 = icmp sgt i32 %2, 0
%8 = sext i32 %2 to i64
%9 = add nuw i32 %4, 1
%10 = zext i32 %9 to i64
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %6, %36
%13 = phi i64 [ 0, %6 ], [ %14, %36 ]
%14 = add nuw nsw i64 %13, 1
br i1 %7, label %15, label %36
15: ; preds = %12
%16 = mul nsw i64 %13, %8
%17 = trunc i64 %14 to i32
%18 = trunc i64 %13 to i32
br label %19
19: ; preds = %15, %31
%20 = phi i64 [ 0, %15 ], [ %34, %31 ]
%21 = tail call i32 @min(i32 %4, i32 %17)
%22 = trunc i64 %20 to i8
%23 = add i8 %22, 97
br label %24
24: ; preds = %27, %19
%25 = phi i32 [ %21, %19 ], [ %30, %27 ]
%26 = icmp eq i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = tail call i64 @suffix(i8* %0, i32 %25, i32 %18, i8 signext %23)
%29 = icmp eq i64 %28, 0
%30 = add nsw i32 %25, -1
br i1 %29, label %24, label %31
31: ; preds = %27, %24
%32 = add nsw i64 %20, %16
%33 = getelementptr inbounds i32, i32* %1, i64 %32
store i32 %25, i32* %33
%34 = add nuw nsw i64 %20, 1
%35 = icmp eq i64 %34, %11
br i1 %35, label %36, label %19
36: ; preds = %31, %12
%37 = icmp eq i64 %14, %10
br i1 %37, label %38, label %12
38: ; preds = %36, %3
ret void
}